Skip to content

Commit

Permalink
fix(discovery): correctly handle up/down commands for covers
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Sep 26, 2024
1 parent c98c2c4 commit d8c1f7b
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion api/lib/Gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,37 @@ 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_open) {
this._zwave
.writeValue(
{
...valueId,
property: 'Up',
},
true,
)
.catch(() => {})
return null
} else if (
payload === hassDevice.discovery_payload.payload_close
) {
this._zwave
.writeValue(
{
...valueId,
property: 'Down',
},
true,
)
.catch(() => {})

return null
}
}
}

Expand Down Expand Up @@ -2271,7 +2302,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 +2321,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 +2368,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 d8c1f7b

Please sign in to comment.