koush / scrypted

Scrypted is a high performance video integration and automation platform
https://scrypted.app
Other
4.13k stars 247 forks source link

ZWave: EntrySensorToBarriorOperator is mapping position to state #716

Closed mikeburgh closed 1 year ago

mikeburgh commented 1 year ago

I started looking at this issue as the garage doors I added via zwave were not showing open/close properly.

I found the issue is that the position of the door, is being mapped to the entryOpen state via this line in index.ts : addCommandClassIndex(CommandClasses['Barrier Operator'], 'position', EntrySensorToBarriorOperator, 'EntrySensor');

However the position is reported in the range 0 to 100 so it does not map to the enums defined in zwave-js which are: Closed = 0, Closing = 252, Stopped = 253, Opening = 254, Open = 255

I tried changing that mapping to currentState in index.ts but then the open/close buttons went away..

Instead if I simply removed all the code in the updateState method in EntrySensorToBarriorOperator everything then worked fine. ?

I have not dug in deep enough yet to figure out how to keep the buttons and make it update against the currentState rather than the position.. can keep digging unless you see the obvious fix ?

koush commented 1 year ago

There's Entry (which performs and reports open/close) and EntrySensor (which reports open/close), and it seems your device might have both? I suspect removing the EntrySensorToBarrierOperator mapping completely would fix it because it would allow EntryToBarrierOperator to work correctly.

mikeburgh commented 1 year ago

Fixed in https://github.com/koush/scrypted/pull/719

koush commented 1 year ago

beta build out now

mikeburgh commented 1 year ago

I run it under docker, so will try the beta once it's updated there.

Got to say, really nice dev experience the way you have it set up with VS code and the plugins, made it so easy to work with the real server and devices and debug the code!

koush commented 1 year ago

the beta does not require a new docker build or anything, you can install a beta plugin from the dropdown list on zwave.

mikeburgh commented 1 year ago

Ahh, totally missed that, even more impressive! Beta installed, position now showing correctly.