steilerDev / homebridge-openhab2-complete

A homebridge plugin for openHAB, that has the expectation to fully support all Services offered by Apple's Homekit Accessory Protocol (HAP)
GNU General Public License v3.0
52 stars 16 forks source link

0.10.2 transforms Rollershutter state from 1 to 0 #36

Closed klnsktn closed 4 years ago

klnsktn commented 4 years ago

Describe the bug I close my Rollershutter to 0% and when i try to open it 1%, the module transforms the state to 0 not to 1. I dont want any transformation. Is this a bug or wrong configuration?

Expected behavior Open the Rollershutter 1% in homekit and 1 in openhab.

Configurations "name": "Jalousien Büro", "type":"windowcovering", "item": "Office_Blind", "manuMode": "false", "inverted": "false", "multiplier": "1", "stateItemMultiplier": "1", "stateItemInverted": "false"

Logs: Jul 25 10:40:24 openHABianPi homebridge[1056]: [7/25/2019, 10:40:24 AM] [openHAB2-Complete] Received push with new state for item Office_Blind: 0 Jul 25 10:40:24 openHABianPi homebridge[1056]: [7/25/2019, 10:40:24 AM] [openHAB2-Complete] Setting new transformed state for item Office_Blind: 0 Jul 25 10:40:47 openHABianPi homebridge[1056]: [7/25/2019, 10:40:47 AM] [openHAB2-Complete] Received push with new state for item Office_Blind: 1 Jul 25 10:40:47 openHABianPi homebridge[1056]: [7/25/2019, 10:40:47 AM] [openHAB2-Complete] Setting new transformed state for item Office_Blind: 0

steilerDev commented 4 years ago

I actually experienced issues with the concept of TargetState and CurrentState of homebridge, therefore I implemented a threshold of 3 percent (can be found here).

A little bit more detailed explanation: When issuing a new TargetState to HomeKit, homebridge will send the value as a command to openHAB. The HomeKit UI will show "opening" or "closing" (depending on the difference between the values of TargetState and CurrentState). My accessories and/or openHAB not always actually go to to the exact value as sent by the command and therefore the object never reached TargetState and always shows as "closing" or "opening". Therefore I added a window of 3%, in which the TargetState and CurrentState are reported as equal. You can change the linked line from above to 0 and this should fix your issue, but might bring the "opening/closing" bug back. Your decision, but I will keep it that way, since I don't think a window of 3% is unnoticeable by the user, while keeping a consistent and correct interface.

E.g.: You are currently at 0% and want to go to 50%. CurrentState == 0, TargetState == 50, therefore the UI shows "opening". Now the command is sent to openHAB and then to your item to go to 50%, for some reason however your item reports a final position of 49%. Therefor HomeKit still thinks it's "opening" (because CurrentState < TargetState).

I hope that makes sense.

Frank