mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-10 22:11:38 +00:00
Expose cover running state to Home Assistant (#11789)
* handle cover running state in HA * add running if the expose * find running in definitionExposes
This commit is contained in:
@@ -380,6 +380,7 @@ export default class HomeAssistant extends Extension {
|
||||
} else if (firstExpose.type === 'cover') {
|
||||
const position = exposes.find((expose) => expose.features.find((e) => e.name === 'position'));
|
||||
const tilt = exposes.find((expose) => expose.features.find((e) => e.name === 'tilt'));
|
||||
const running = definitionExposes?.find((e) => e.type === 'binary' && e.name === 'running');
|
||||
|
||||
const discoveryEntry: DiscoveryEntry = {
|
||||
type: 'cover',
|
||||
@@ -396,8 +397,14 @@ export default class HomeAssistant extends Extension {
|
||||
// - https://github.com/Koenkk/zigbee-herdsman-converters/pull/2663
|
||||
if (!tilt || (tilt && position)) {
|
||||
discoveryEntry.discovery_payload.command_topic = true;
|
||||
discoveryEntry.discovery_payload.state_topic = !position;
|
||||
discoveryEntry.discovery_payload.state_topic = !!running || !position;
|
||||
discoveryEntry.discovery_payload.command_topic_prefix = endpoint;
|
||||
|
||||
if (running) {
|
||||
discoveryEntry.discovery_payload.value_template = `{% if not value_json.running %} ` +
|
||||
`stopped {% else %} {% if value_json.position > 0 %} closing {% else %} ` +
|
||||
`opening {% endif %} {% endif %}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (!position && !tilt) {
|
||||
|
||||
Reference in New Issue
Block a user