Skip to content

Commit

Permalink
fix(dingz): don't add D1 if not_connected
Browse files Browse the repository at this point in the history
- The dingz FW/API `1.2.x` allows users to hide dimmers from the UI
- At the same time, output/input 1 can be configured as well
when the input is disabled and the dimmer doesn't exist
- check whether `output` of the dimmer is enabled
- in that case, `D1` shouldn't be added at all
- fixes #143
- implements part of  #118

Thanks @granturismo0 for reporting
  • Loading branch information
johannrichard committed Nov 29, 2020
1 parent 999c960 commit aef7298
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dingzAccessory.ts
Expand Up @@ -1196,9 +1196,11 @@ export class DingzAccessory extends DingzDaBaseAccessory {
'D1',
) &&
(updatedDingzDeviceInfo.dip_config === 1 ||
updatedDingzDeviceInfo.dip_config === 3)
updatedDingzDeviceInfo.dip_config === 3) &&
dimmerConfig?.dimmers[0].output !== 'not_connected'
) {
// Only add Dimmer 0 if we're not in "WindowCover" mode
// Only add Dimmer 0 if we're not in "WindowCover" mode *and*
// if output is not set to `not_connected`
const dimmerConfig: DingzDeviceDimmerConfig | undefined = this
.device.dimmerConfig;

Expand Down

2 comments on commit aef7298

@johannrichard
Copy link
Owner Author

@johannrichard johannrichard commented on aef7298 Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will have to test this, would appreciate if you can help @granturism0. Pushed as homebridge-dingz@2.0.2-nightly.0 with nightly tag to npm.

PS: I don't yet implement the full code to also remove D1 if it exists but is set to not_connected. I don't think it belongs in this corner of the code. If you configure D1 as I1 and then configure it back, it should first be removed and then not be added again. Alternatively, you can, of course, remove the accessory in question and add it back again. 😀

@granturism0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @johannrichard
Perfect and you can close this bug.
Had to remove the item from the homebridge first and then restart it, but I think it's absolutely OK!

Please sign in to comment.