SphtKr / homebridge-zway

Homebridge plugin for (better) HomeKit support of RaZBerry and Z-Way Server
ISC License
85 stars 38 forks source link

Issue with WindowCovering #102

Open ibjr opened 7 years ago

ibjr commented 7 years ago

(There might be a relation with issue #72) (I am running the 0.50.0 hb-zway version, homebridge 0.4.16, hap-nodejs 0.4.20 and node v6.10.1).

I have zwave-motorized curtains which open/close automatically depending on time of day and daylight intensity (this automation is running within the zway environment). When I open/or close the covers from Apple's homekit app, this works fine, but when they close automatically, the icon on the homekit app keeps showing the moving circle for ever.

I did some debugging and this seems to be caused by line 1188 of index.js (of version 0.50.0). Assuming a stable start position Open (100%), this.value is 100; cx.getDefaultValue() returns always 0. When I change to position to (e.g.) 50%, from the Homekit app, first a set of the TargetPosition is received in hb-zway, so this.value = 50 from now on. When the windowcovers are closed to 50%, the Homekit icon becomes stable. However, when is change the position to 50% by via the z-way user interface directly, the motor starts moving, and hb-zway receives update of the Current Position. Within "cx instanceof Characteristic.TargetPosition ->cx.zway_getValueFromVdev", this.value stays at the old level of 100, and hence will return this old value of 100.

This cx.zway_getvalueFromVdev (in TargetPosition) is called each time an update is received from the actual level, but keeps returning the old, now incorrect value of 100. I assume Apple's homekit app considers the window covers in a moving state until target and current position are the same. (the Eve app does not show the moving circle!)

When i remove line 1188, and as a result the target position is always set to the current position, everything works as expected; but I am not sure what effects this may have.

Debugging output (I added some extra debug lines to index.js) ("Gordijnen" is the Dutch word for "Curtains"): Setting to 82% open from Homekit App: Tue, 28 Mar 2017 14:30:05 GMT ZWayServer debIno Set Targetposition, number, Got value: 81. Tue, 28 Mar 2017 14:30:05 GMT ZWayServer debIno Set Targetposition, number, Got value: 82. Tue, 28 Mar 2017 14:30:07 GMT ZWayServer Got 1 updates. Tue, 28 Mar 2017 14:30:07 GMT ZWayServer debIno this.value= 82; cx.getDefaultValue() = 0; metrics.level = 99; Tue, 28 Mar 2017 14:30:09 GMT ZWayServer Got 1 updates. Tue, 28 Mar 2017 14:30:09 GMT ZWayServer debIno Device Gordijnen, characteristic Current Position changed from 100 to 93 Tue, 28 Mar 2017 14:30:09 GMT ZWayServer Updated characteristic Current Position on Gordijnen Tue, 28 Mar 2017 14:30:09 GMT ZWayServer debIno this.value= 82; cx.getDefaultValue() = 0; metrics.level = 93; Tue, 28 Mar 2017 14:30:11 GMT ZWayServer Got 1 updates. Tue, 28 Mar 2017 14:30:11 GMT ZWayServer debIno Device Gordijnen, characteristic Current Position changed from 93 to 82 Tue, 28 Mar 2017 14:30:11 GMT ZWayServer Updated characteristic Current Position on Gordijnen Tue, 28 Mar 2017 14:30:11 GMT ZWayServer debIno this.value= 82; cx.getDefaultValue() = 0; metrics.level = 82; Tue, 28 Mar 2017 14:30:13 GMT ZWayServer Got 1 updates. Tue, 28 Mar 2017 14:30:13 GMT ZWayServer debIno this.value= 82; cx.getDefaultValue() = 0; metrics.level = 82; And everything is stable (targetpostion is 82, current position is 82).

Now the same procedure, but directly from the zway UI (to 89%): Tue, 28 Mar 2017 14:32:00 GMT ZWayServer Got 1 updates. Tue, 28 Mar 2017 14:32:00 GMT ZWayServer debIno Device Gordijnen, characteristic Current Position changed from 100 to 89 Tue, 28 Mar 2017 14:32:00 GMT ZWayServer Updated characteristic Current Position on Gordijnen Tue, 28 Mar 2017 14:32:00 GMT ZWayServer debIno this.value= 100; cx.getDefaultValue() = 0; metrics.level = 89; Tue, 28 Mar 2017 14:32:02 GMT ZWayServer Got 1 updates. Tue, 28 Mar 2017 14:32:02 GMT ZWayServer debIno this.value= 100; cx.getDefaultValue() = 0; metrics.level = 89; Tue, 28 Mar 2017 14:32:04 GMT ZWayServer Got 1 updates. Tue, 28 Mar 2017 14:32:04 GMT ZWayServer debIno this.value= 100; cx.getDefaultValue() = 0; metrics.level = 89; Homekit "gordijnen" icon keeps showing the moving circle. (Target still at 100, current position 89)

SphtKr commented 7 years ago

Thanks for the great report! I'll have to look at this more closely. I too am unsure what the full implications are of changing that line. If memory serves, I was getting a feedback loop with the value setting itself back and forth if I didn't have that check in there...Or, it was a tweak to try and make that function work for both 0-100% values and on/off values (binary switch window coverings).

tbussmann commented 7 years ago

I'm having the same issue. With the proposed change from @ibjr the behaviour is way nicer and more stable, but with this the blinds are newer shown as moving. It seems HomeKit displays a state "being opened" automatically when TargetPosition <> CurrentPosition. Regardless of PositionState which returns from Line 1255 always a Stopped state. Maybe we need to differentiate the two cases a) the request was done through homebridge and we know the target so return this and calculate a PostionState accordingly and b) the request came elsewhere, we don't know what's happening and continue to return target = current and stopped as ibjr proposed.

stich86 commented 7 years ago

Hi guys,

any news on this? I've a z-way installation with Qubino Flush Shutter, and HomeKit report need to refresh (or tap twice) to get real state.. also percentage need to do this tricks

chstoll commented 7 years ago

Hi,

I also would really like the fix for this issue. It seems almost impossible to get Z-Way / Z-Wave Blinds working correctly in HomeKit (native zWay-Homekit-Plugin outdated, does even not support blinds and shows them as dimmer, OpenHAB2 with zWay-Plugin not supported by Hombridge-openhab-plugin and so on).

Can someone in the meantime just tell me the path to the index.js from homebridge-zway so I can apply this workaround? I'm just to stupid or not nerdy enough to find it, thank you!

stich86 commented 7 years ago

on the current version is on Line 1250

https://github.com/SphtKr/homebridge-zway/blob/master/index.js#L1250

You can go to /usr/lib/node_modules/homebridge-zway and edit file index.js, just put a "//" in front of the line and restart home bridge