Skip to content

Commit

Permalink
Expose device configuration after hass is online
Browse files Browse the repository at this point in the history
  • Loading branch information
urpylka committed Feb 20, 2024
1 parent b32bd30 commit 9a9fef9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Zigbee2MQTT integrates well with (almost) every home automation solution because

### [IoBroker](https://www.iobroker.net/)
- Integration implemented in IoBroker ([documentation](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt)).

<br>

## Architecture
Expand Down
13 changes: 13 additions & 0 deletions lib/extension/homeassistant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,19 @@ export default class HomeAssistant extends Extension {
const timer = setTimeout(async () => {
// Publish all device states.
for (const entity of [...this.zigbee.devices(false), ...this.zigbee.groups()]) {

// Expose device configurations to homeassistant
// https://github.com/Koenkk/zigbee2mqtt/issues/18862
this.discover(entity, true);

if (entity.isDevice() && this.discoveredTriggers[entity.ieeeAddr]) {
for (const config of this.discoveredTriggers[entity.ieeeAddr]) {
const key = config.substring(0, config.indexOf('_'));
const value = config.substring(config.indexOf('_') + 1);
this.publishDeviceTriggerDiscover(entity, key, value, true);
}
}

if (this.state.exists(entity)) {
this.publishEntityState(entity, this.state.get(entity), 'publishCached');
}
Expand Down

0 comments on commit 9a9fef9

Please sign in to comment.