openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.9k stars 3.59k forks source link

[Somfy Tahoma] The state of sunshade is not synced when wind sensor opens it #17305

Open maisun opened 3 months ago

maisun commented 3 months ago

Hi, I'd like to report a bug with Somfy Tahoma Binding, I use it for the sunshade in my living room. Together with the sunshade I installed a wind sensor, which can open the shade in case it becomes windy. I think the wind sensor talks directly to the sunshade as I cannot find a way to add the wind sensor in Tahoma app. Anyways I made some automation rules to open/close sunshade based on weather conditions: for example when sunny close the sunshade, when cloudy open the sunshade, simple stuff. Today I noticed the following: 1) My automation detects it's sunny and close the sunshade 2) After a while the wind sensor detects wind and open the sunshade. 3) In OpenHAB it still thinks the sunshade is closed even after more than an hour 4) If I now ask OpenHAB to open the sunshade, it changes state from 100 -> 0 but no action is triggered. I have observed both in Tahoma app and HomeKit the sunshade is marked open when the wind sensor opens it. So for some reason. the binding doesn't seem to know the sunshade is already opened (triggered by wind sensor). This gives massive problem for automation as I don't know the state of sunshade anymore.

Expected Behavior

The state of sunshade in OpenHAB should always be synchronised with the actual state of the device.

Current Behavior

Currently the state is synchronised unless the wind sensor decides to open the sunshade, in which case the binding still thinks the blind is closed despite that it was open.

Possible Solution

Can't see any workaround

Steps to Reproduce (for Bugs)

1) My automation detects it's sunny and close the sunshade 2) After a while the wind sensor detects wind and open the sunshade. 3) In OpenHAB it still thinks the sunshade is closed even after more than an hour 4) If I now ask OpenHAB to open the sunshade, it changes state from 100 -> 0 but no action is triggered.

Context

In automation rules, I'd like to check the state of the blind and make decisions - for example when it's open, do this, when it's closed do that. If the state is not in sync I cannot run those automations reliably.

Your Environment

octa22 commented 1 month ago

Hello, could you please provide me with the trace log from the wind sensor event that triggers the sunshade to open? Most probably it changes the state to some different one from "Open" and the binding does not know it yet. I can't reproduce it in my installation, because I do not have a wind sensor. thanks. Ondrej

maisun commented 1 month ago

Hello, could you please provide me with the trace log from the wind sensor event that triggers the sunshade to open? Most probably it changes the state to some different one from "Open" and the binding does not know it yet. I can't reproduce it in my installation, because I do not have a wind sensor. thanks. Ondrej

Hi Ondrej,

Thank you for looking into it! The wind sensor is not connected to OpenHAB, in face I believe it uses some internal unpublished protocol to communicate with the blind. The issue here is when the blind is opened by wind sensor, the state of the blind is unchanged in OpenHAB. I don't know if it's because the trigger of action is not sent to OpenHAB, but in HomeKit and Somfy the state of the blind changes immediately when it's opened. Also to add: if I manually open the blind in Somfy app or HomeKit, the state is also changed in OpenHAB. So there must be some subtle difference when the blind changes state by the wind sensor

octa22 commented 1 month ago

I understand, there is no need to have the sensor connected to Tahoma, I just need to see the correct state of the blind closure when this event occurs. Most probably it sends a different closure state instead of expected Open/Closed, for instance something like "Forced Open", that is ignored so far...

maisun commented 1 month ago

I understand, there is no need to have the sensor connected to Tahoma, I just need to see the correct state of the blind closure when this event occurs. Most probably it sends a different closure state instead of expected Open/Closed, for instance something like "Forced Open", that is ignored so far...

OK, I'm not very strong technically, how can I find what value it sends? In my case it's the wind sensor that triggers "Open" (instead of "Close").

octa22 commented 1 month ago

The simplest way might be 1) enable the trace log for the tahoma binding (ssh into OH2 console and use log:set trace org.openhab.binding.somfytahoma command) 2) pause the Tahoma bridge in the OH UI for several seconds (disable) 3) enable the bridge again

search for the JSON response of /enduser-mobile-web/1/enduserAPI/setup call in the log. It should contain the actual state of your Somfy devices.

octa22 commented 1 month ago

Or you can 1) login into classic.tahomalink.com portal using your browser with developer tools enabled (F12) 2) provide me with the setup call JSON response in the Network tab

octa22 commented 1 month ago

in both cases it is necessary to let the sensor trigger the event to open the blind, otherwise the blind will have the corresponding state (Open/Closed)

maisun commented 1 month ago

in both cases it is necessary to let the sensor trigger the event to open the blind, otherwise the blind will have the corresponding state (Open/Closed)

Hi @octa22 :

I have tried the following today: 1) Enable TRACE log level 2) Close my blind to 100%, close my pergola to 50% (log shows io://2004-9850-xxxx/xxxxxxxx processing state: core:OpenClosedState with value: open) 3) Blow some wind to trigger the sensor to open blind and pergola 4) I can see afterwards Pergola has the right position 0% in openhab, however my blind shows 100% 5) Then after about 5-6 minutes, blind also updated to 0% (the log shows io://2004-9850-xxxx/xxxxxxxx processing state: core:OpenClosedState with value: closed)

So basically in step 4 I only see state change for Pergola but not blind - however in HomeKit it does change between open/close when the wind sensor triggers the event.

Edit: I repeated the above steps and got the same result - there is no update on blind but only for pergola. I then disable/enable bridge, in the log setup response I can see it still thinks the blind is open {"type":3,"name":"core:OpenClosedState","value":"open"}. This time it's strange the HomeKit also thinks the blind open. Very strange. But I think the root cause is probably missing some events?

Ok I think I get a better understanding of the potential cause: I noticed that when Somfy wind sensor is triggered, the blind/pergola both are locked, can't open or close, and looks like events are not sent during this period. So my theory is: when the wind triggers a change, the blind takes a longer time to close and hence the close event was not sent before entering the "lock state". (It's still mystery why sometimes it works with HomeKit). And when the wind sensor thinks it's safe again, I receive the event that the blind is closed. So the event is basically "blocked" by the wind lock I think.

octa22 commented 1 month ago

OK, thanks for the investigation. So if the state of pergola/blind provided by the cloud corresponds the one shown in OH, there is nothing I can do. Maybe there is an event missing or being ignored (there is no log entry when an event gets ignored, but you an see all events in the fetch event response), but without the trace log I am unable to move further, you must debug it by youself or we can close this issue...

maisun commented 1 month ago

OK, thanks for the investigation. So if the state of pergola/blind provided by the cloud corresponds the one shown in OH, there is nothing I can do. Maybe there is an event missing or being ignored (there is no log entry when an event gets ignored, but you an see all events in the fetch event response), but without the trace log I am unable to move further, you must debug it by youself or we can close this issue...

I can see the binding keeps polling every minute, and during which period the open/close state change never came for the blind for some minutes, then I disable/enable binding, in the setup (big json message) I can see the state of the blind is wrong. After the wind lock, I received the event that the state changes to close, and OH continues to work afterwards. I believe it's something at Somfy side.

octa22 commented 1 month ago

Maybe another special event triggered by the wind sensor comes during the minute polling, it may not relate to open/close state, but rather to secure position forcing. Maybe you should look for that...

octa22 commented 1 month ago

thanks, you are right, the devices are the same uiClass Awning, the pergola gets the update but the blind doesn't. No matter what state you work with (OpenClosedState, MovingState, DeploymentState), that's definitely something on the Somfy side.

maisun commented 1 month ago

thanks, you are right, the devices are the same uiClass Awning, the pergola gets the update but the blind doesn't. No matter what state you work with (OpenClosedState, MovingState, DeploymentState), that's definitely something on the Somfy side.

Thanks a lot for checking the issue, have a nice evening!