Skip to content

Commit

Permalink
fix(discovery): correctly handle up/down commands for covers (#3916)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Sep 30, 2024
1 parent 24dc718 commit 1582b2a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/hass/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const configurations: Record<HassDeviceKey, HassDevice> = {
position_closed: 0,
payload_open: '99',
payload_close: '0',
payload_stop: 'stop',
},
},
// Barrier operator support for zwave-js (numeric commands/states)
Expand Down
32 changes: 31 additions & 1 deletion api/lib/Gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,26 @@ export default class Gateway {
// for other command classes use the mode_map
payload = hassDevice.mode_map[payload]
}
} else if (
hassDevice.type === 'cover' &&
valueId.property === 'targetValue'
) {
// ref issue https://github.com/zwave-js/zwave-js-ui/issues/3862
if (
payload ===
(hassDevice.discovery_payload.payload_stop ?? 'STOP')
) {
this._zwave
.writeValue(
{
...valueId,
property: 'Up',
},
false,
)
.catch(() => {})
return null
}
}
}

Expand Down Expand Up @@ -2271,7 +2291,7 @@ export default class Gateway {
}

/**
* Handle broadcast request reeived from Mqtt client
* Handle broadcast request received from Mqtt client
*/
private async _onBroadRequest(
parts: string[],
Expand All @@ -2290,6 +2310,11 @@ export default class Gateway {
this.topicValues[values[0]],
this.topicValues[values[0]].conf,
)

if (payload === null) {
return
}

for (let i = 0; i < values.length; i++) {
await this._zwave.writeValue(
this.topicValues[values[i]],
Expand Down Expand Up @@ -2332,6 +2357,11 @@ export default class Gateway {

if (valueId) {
const value = this.parsePayload(payload, valueId, valueId.conf)

if (value === null) {
return
}

await this._zwave.writeValue(valueId, value, payload?.options)
} else {
logger.debug(`No writeable valueId found for ${valueTopic}`)
Expand Down

0 comments on commit 1582b2a

Please sign in to comment.