Tahoma Binding compatible with OH2

He @Timmi, what exactly did you do wrong? Or did you do to solve your problem in this post?

Hi Ondrej,

wow, this was fast! Now, I have the temperature sensors “Thermis Wirefree io1” and “
 io2” in OpenHAB.
According to the “Connexoon Window” app both sensors tell 21°C. But your binding gives me 0.21°C for io1 (wrong!) and 21.2°C for io2 (correct!).

2018-10-31 19:50:18.383 [vent.ItemStateChangedEvent] - 
somfytahoma_temperaturesensor_dba014af_0400bf03_115d_4938_8250_92982e8b32c3_temperature changed from NULL to 0.21 °C
2018-10-31 19:50:20.652 [vent.ItemStateChangedEvent] - somfytahoma_temperaturesensor_dba014af_0b5b4c92_d13d_451b_a903_7c443c0192c7_temperature changed from NULL to 21.200000000000045 °C

What is the difference, what is wrong?

Regards,
Manfred

Hi,

that’s really weird, could you enable trace

log:set trace org.openhab.binding.somfytahoma.handler.SomfyTahomaBridgeHandler

and PM me with the detail log, please?
Thanks.
Ondrej

Really strange! I entered your command, and surprise: The temperatures of both sensors are correct!

2018-10-31 22:06:12.258 [DEBUG] [oma.handler.SomfyTahomaBridgeHandler] - Updating Tahoma States...
2018-10-31 22:06:12.258 [TRACE] [oma.handler.SomfyTahomaBridgeHandler] - Sending PUT to Tahoma to url: https://www.tahomalink.com/enduser-mobile-web/enduserAPI/setup/devices/states/refresh
2018-10-31 22:06:12.293 [TRACE] [oma.handler.SomfyTahomaBridgeHandler] - Response: {}
2018-10-31 22:06:14.058 [DEBUG] [oma.handler.SomfyTahomaBridgeHandler] - Getting states for a device: io://0803-2384-0205/14175861
2018-10-31 22:06:14.059 [DEBUG] [oma.handler.SomfyTahomaBridgeHandler] - Formatted parameters: {"name": "core:StatusState"},{"name": "core:TemperatureState"}
2018-10-31 22:06:14.059 [TRACE] [oma.handler.SomfyTahomaBridgeHandler] - Sending POST to Tahoma to url: https://www.tahomalink.com/enduser-mobile-web/externalAPI/json/getStates with data: [{"deviceURL": "io://0803-2384-0205/14175861", "states": [{"name": "core:StatusState"},{"name": "core:TemperatureState"}]}]
2018-10-31 22:06:14.098 [TRACE] [oma.handler.SomfyTahomaBridgeHandler] - Response: {"devices":[{"label":"IO (14175861)","deviceURL":"io://0803-2384-0205/14175861","shortcut":false,"states":[{"name":"core:StatusState","type":3,"value":"available"},{"name":"core:TemperatureState","type":2,"value":20.900000000000034}],"available":false,"enabled":false,"type":1}],"events":[]}
2018-10-31 22:06:17.318 [DEBUG] [oma.handler.SomfyTahomaBridgeHandler] - Getting states for a device: io://0803-2384-0205/4023842
2018-10-31 22:06:17.319 [DEBUG] [oma.handler.SomfyTahomaBridgeHandler] - Formatted parameters: {"name": "core:StatusState"},{"name": "core:TemperatureState"}
2018-10-31 22:06:17.319 [TRACE] [oma.handler.SomfyTahomaBridgeHandler] - Sending POST to Tahoma to url: https://www.tahomalink.com/enduser-mobile-web/externalAPI/json/getStates with data: [{"deviceURL": "io://0803-2384-0205/4023842", "states": [{"name": "core:StatusState"},{"name": "core:TemperatureState"}]}]
2018-10-31 22:06:17.359 [TRACE] [oma.handler.SomfyTahomaBridgeHandler] - Response: {"devices":[{"label":"IO (4023842)","deviceURL":"io://0803-2384-0205/4023842","shortcut":false,"states":[{"name":"core:StatusState","type":3,"value":"available"},{"name":"core:TemperatureState","type":2,"value":21.200000000000045}],"available":false,"enabled":false,"type":1}],"events":[]}

Regards,
Manfred

Thanks, maybe the binding has problems with parsing only some values got from the sensor. Please keep an eye on it and let me know if it appears again.
Thanks
Ondrej

I will do.
Thanks for your support 
 and your great work.
Manfred

Hello Ondrej,
unfortunately even with the new version I still have the problem to get the correct state in openhab after the rollershutter position was changed with an external remote control. However, I realized that I get the correct state when I send the STOP command in openhab. Below you can find my trace with some comments from me:

#auto update from the binding
10:37:28.561 [DEBUG] [homa.handler.SomfyTahomaBridgeHandler] - Updating Tahoma States...
10:37:28.572 [TRACE] [homa.handler.SomfyTahomaBridgeHandler] - Sending POST to Tahoma to url: https://www.tahomalink.com/enduser-mobile-web/externalAPI/json/getEvents with data:
10:37:28.835 [TRACE] [homa.handler.SomfyTahomaBridgeHandler] - Response: []
10:37:28.844 [DEBUG] [homa.handler.SomfyTahomaBridgeHandler] - Got total of 0 events
10:37:28.855 [DEBUG] [homa.handler.SomfyTahomaBridgeHandler] - Getting states for a device: io://0808-8597-0717/11695357
10:37:28.864 [DEBUG] [homa.handler.SomfyTahomaBridgeHandler] - Formatted parameters: {"name": "core:StatusState"},{"name": "core:ClosureState"}
10:37:28.873 [TRACE] [homa.handler.SomfyTahomaBridgeHandler] - Sending POST to Tahoma to url: https://www.tahomalink.com/enduser-mobile-web/externalAPI/json/getStates with data: [{"deviceURL": "io://0808-8597-0717/11695357", "states": [{"name": "core:StatusState"},{"name": "core:ClosureState"}]}]
10:37:28.925 [TRACE] [homa.handler.SomfyTahomaBridgeHandler] - Response: {"devices":[{"label":"IO (11695357)","deviceURL":"io://0808-8597-0717/11695357","shortcut":false,"states":[{"name":"core:StatusState","type":3,"value":"available"},{"name":"core:ClosureState","type":1,"value":27}],"available":false,"enabled":false,"type":1}],"events":[]}
#postion 27 is incorrect as the rollershutter was closed by the remote control

#pressed stop button from io://0808-8597-0717/11695357 (Rollo Kueche)
10:39:39.157 [TRACE] [homa.handler.SomfyTahomaBridgeHandler] - Sending POST to Tahoma to url: https://www.tahomalink.com/enduser-mobile-web/externalAPI/json/getCurrentExecutions with data:
10:39:39.429 [TRACE] [homa.handler.SomfyTahomaBridgeHandler] - Response: {"executions":[],"events":[]}
10:39:39.441 [TRACE] [homa.handler.SomfyTahomaBridgeHandler] - Sending POST to Tahoma to url: https://www.tahomalink.com/enduser-mobile-web/externalAPI/json/apply with data: {"label":"Rollo Kueche - my - OH2","actions":[{"deviceURL":"io://0808-8597-0717/11695357","commands":[{"name":"my","parameters":[]}]}]}
10:39:39.495 [TRACE] [homa.handler.SomfyTahomaBridgeHandler] - Response: {"execId":"cea48152-d9b6-8679-101a-3a0a324f5f4b","events":[]}
10:39:39.505 [DEBUG] [homa.handler.SomfyTahomaBridgeHandler] - Exec id: cea48152-d9b6-8679-101a-3a0a324f5f4b

#auto update from the binding
10:40:01.187 [DEBUG] [homa.handler.SomfyTahomaBridgeHandler] - Updating Tahoma States...
10:40:01.196 [TRACE] [homa.handler.SomfyTahomaBridgeHandler] - Sending POST to Tahoma to url: https://www.tahomalink.com/enduser-mobile-web/externalAPI/json/getEvents with data:
10:40:01.469 [TRACE] [homa.handler.SomfyTahomaBridgeHandler] - Response: [
    {
    "name": "ExecutionRegisteredEvent",
    "ts": "1541065179475",
    "setupOID": "eba45643-9821-4bc5-8e81-599c4a0b803e",
    "execId": "cea48152-d9b6-8679-101a-3a0a324f5f4b",
    "label": "Rollo Kueche - my - OH2",
    "metadata": [],
    "type": "1",
    "subType": "1",
    "triggerId": [],
    "action":     {
      "deviceURL": "io://0808-8597-0717/11695357",
      "command": {"name": "my"}
    }
  },
    {
    "name": "ExecutionStateChangedEvent",
    "ts": "1541065179475",
    "setupOID": "eba45643-9821-4bc5-8e81-599c4a0b803e",
    "execId": "cea48152-d9b6-8679-101a-3a0a324f5f4b",
    "newState": "1",
    "ownerKey": "eba45643-9821-4bc5-8e81-599c4a0b803e",
    "type": "1",
    "subType": "1",
    "oldState": "0",
    "timeToNextState": "0"
  },
    {
    "name": "GatewaySynchronizationStartedEvent",
    "ts": "1541065179476",
    "gatewayId": "0808-8597-0717"
  },
    {
    "name": "ExecutionStateChangedEvent",
    "ts": "1541065179477",
    "setupOID": "eba45643-9821-4bc5-8e81-599c4a0b803e",
    "execId": "cea48152-d9b6-8679-101a-3a0a324f5f4b",
    "newState": "2",
    "ownerKey": "eba45643-9821-4bc5-8e81-599c4a0b803e",
    "type": "1",
    "subType": "1",
    "oldState": "1",
    "timeToNextState": "0"
  },
    {
    "name": "GatewaySynchronizationEndedEvent",
    "ts": "1541065179477",
    "gatewayId": "0808-8597-0717"
  },
    {
    "name": "DeviceStateChangedEvent",
    "ts": "1541065180162",
    "setupOID": "eba45643-9821-4bc5-8e81-599c4a0b803e",
    "deviceURL": "io://0808-8597-0717/11695357",
    "deviceStates":     [
            {
        "name": "core:ClosureState",
        "value": "0"
      },
            {
        "name": "core:OpenClosedState",
        "value": "open"
      }
    ]
  },
    {
    "name": "ExecutionStateChangedEvent",
    "ts": "1541065180163",
    "setupOID": "eba45643-9821-4bc5-8e81-599c4a0b803e",
    "execId": "cea48152-d9b6-8679-101a-3a0a324f5f4b",
    "newState": "3",
    "ownerKey": "eba45643-9821-4bc5-8e81-599c4a0b803e",
    "type": "1",
    "subType": "1",
    "oldState": "2",
    "timeToNextState": "0"
  },
    {
    "name": "ExecutionStateChangedEvent",
    "ts": "1541065180163",
    "setupOID": "eba45643-9821-4bc5-8e81-599c4a0b803e",
    "execId": "cea48152-d9b6-8679-101a-3a0a324f5f4b",
    "newState": "4",
    "ownerKey": "eba45643-9821-4bc5-8e81-599c4a0b803e",
    "type": "1",
    "subType": "1",
    "oldState": "3"
  }
]
10:40:01.636 [DEBUG] [homa.handler.SomfyTahomaBridgeHandler] - Got total of 1 events
10:40:01.644 [DEBUG] [homa.handler.SomfyTahomaBridgeHandler] - States for device io://0808-8597-0717/11695357 : [{name='core:ClosureState', type=0, value=0}, {name='core:OpenClosedState', type=0, value=open}]
10:40:01.653 [DEBUG] [homa.handler.SomfyTahomaBridgeHandler] - Updating status of thing: 4183d5ce-1385-46df-899d-150ddf88c9df
10:40:01.671 [DEBUG] [homa.handler.SomfyTahomaBridgeHandler] - Getting states for a device: io://0808-8597-0717/13306646
10:40:01.683 [INFO ] [smarthome.event.ItemStateChangedEvent] - eg_kueche_rollershutter changed from 27 to 0
#now the correct state is reflected in openhab

Hope the information is useful for you to find a solution.

Thank you for your great support.

Best regards,
Thomas

Hi,

thanks for the debug information. It seems OK for me - the value of 27 is returned from the cloud and there was no forced refresh in between, so the binding is correctly interpretting what gets from the cloud.
What is your configuration value for statusTimeout? The default value is 300s, so the cloud forces the gateway to send actual states once in five minutes

You can set it to lower value, once the binding gets an event about refreshedStates, it synchronizes the states with the Tahoma cloud


Thanks.
Ondrej

Hi Ondrej

Sorry to say but the temperature sensors do not update, i.e. the things keep the values which were at creation time. This behavior might be related to the incorrect value I got for one sensor in the beginning.

Maybe it is related to the issue of tkaor:

2018-11-01 17:53:07.444 [DEBUG] [oma.handler.SomfyTahomaBridgeHandler] - Updating Tahoma States...
2018-11-01 17:53:07.445 [TRACE] [oma.handler.SomfyTahomaBridgeHandler] - Sending PUT to Tahoma to url: https://www.tahomalink.com/enduser-mobile-web/enduserAPI/setup/devices/states/refresh
2018-11-01 17:53:07.556 [TRACE] [oma.handler.SomfyTahomaBridgeHandler] - Response: {}

Every 30 secs the cloud will be asked for an update but no response even if there are changes made by external remote controls.

Regards,
Manfred

The empty response for the Refresh command is OK. This forces (at least my Tahoma gateway) to refresh device states and afterwards it sends an event that means the sync has completed.
Could you please send me longer log what happened after applying the Refresh command? What the next getEvents commands returned?

This is the event I am talking about

{
    "name": "RefreshAllDevicesStatesCompletedEvent",
    "ts": "1541014825067",
    "gatewayId": "0204-4519-1234",
    "protocolType": "22"
  }

If Connexoon ignores it, I’m afraid the only solution for this is to separate logic for Tahoma and Connexoon gateways :frowning:

Ondrej

Hi,
this version sends periodically (see statusTimeout config. value) refreshAllStates command.
https://www.dropbox.com/s/mji5h7no6gl1t0x/org.openhab.binding.somfytahoma-2.4.0-SNAPSHOT.jar?dl=1

Connexoon users - please let me know if you see RefreshAllDevicesStatesCompletedEvent after applying refreshAllStates, which ensures refreshing of all states from cloud.
It works for my Tahoma Box as well as former refresh command.

Thanks.
Ondrej

Can you push your latest changes to your github account?
I had to make a slight modification because I often got Errors from the HttpClient when I send commands to many shutters at once (without reaching the APIs soft limit)

java.util.concurrent.ExecutionException: java.util.concurrent.RejectedExecutionException: org.eclipse.jetty.client.HttpClient@3a7215 is stopped
		at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118) ~[?:?]
		at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101) ~[?:?]
		at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:674) ~[?:?]
		at org.openhab.binding.somfytahoma.handler.SomfyTahomaBridgeHandler.login(SomfyTahomaBridgeHandler.java:132) ~[?:?]
		at org.openhab.binding.somfytahoma.handler.SomfyTahomaBaseThingHandler.updateChannelState(SomfyTahomaBaseThingHandler.java:273) ~[?:?]
		at org.openhab.binding.somfytahoma.handler.SomfyTahomaBridgeHandler.updateThingStates(SomfyTahomaBridgeHandler.java:420) ~[?:?]
		at org.openhab.binding.somfytahoma.handler.SomfyTahomaBridgeHandler.processEvent(SomfyTahomaBridgeHandler.java:378) ~[?:?]
		at org.openhab.binding.somfytahoma.handler.SomfyTahomaBridgeHandler.getTahomaUpdates(SomfyTahomaBridgeHandler.java:366) ~[?:?]
		at org.openhab.binding.somfytahoma.handler.SomfyTahomaBridgeHandler.lambda$1(SomfyTahomaBridgeHandler.java:103) ~[?:?]
		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
		at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
		at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
		at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
		at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.util.concurrent.RejectedExecutionException: org.eclipse.jetty.client.HttpClient@3a7215 is stopped
		at org.eclipse.jetty.client.HttpDestination.send(HttpDestination.java:215) ~[?:?]
		at org.eclipse.jetty.client.HttpClient.send(HttpClient.java:556) ~[?:?]
		at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:715) ~[?:?]
		at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:668) ~[?:?]
		... 13 more

I modified SomfyTahomaBridgeHandler#login so that the HttpClient will not get stopped everytime, but only get started if it is not started:

        if (!httpClient.isStarted()) {
            httpClient.start();
        }

In my case the “HttpClient is stopped” error disappeared and everything works as expected. I would like to incorporate this change before testing your newest version.

pushed to somfytahoma-binding branch

Thanks!

Regarding your question about RefreshAllDevicesStatesCompletedEvent. This Event is available at the getEventsEndpoint. See attached log for further detail:
openhab.log.json (215.5 KB)

Today my connexoon box hung up. I wasn’t able to control my rollershutters through the box. Even the Somfy-Connexoon App did not work. After a power cycle it now works again. I had set the Refresh States interval to 15secs. Maybe this was too often when states/refresh was also triggered so often


This version is working fine. I get updated states and see RefreshAllDevicesStatesCompletedEvent.

Manfred

Thank you,
it seems this is working for Tahoma as well for Connexoon box.
What I find weird is this line:

Getting cached state: null for url: io://0806-9473-8878/11133529

Since you are probably able to compile and debug my code, could you please find out, why there is state: null in this log? You have got rid of the former and obsolite position channel, have you? It seems it tries to find a status for channel which doesn’t exist and tries to relogin because it can’t parse the null response.
That’s why you are having problems with HttpClient starting/stopping.

I am unable to simulate this behaviour and I have never seen this statement in my log :frowning:
Thanks.
Ondrej

Hello Ondrej,
great. The new version seems to work now with Connexoon as well. I made some quick tests with Somfy rollershutter and blinds as well as Velux rollershutter. When the rollershutter were moved by a remot control the correct position is updated after the Status timeout. Thank you once again.

Best regards,
Thomas

Please see the updated last commit in my somfytahoma-branch. It should fix your problems with null states and relogins.
Thanks.
Ondrej

Thanks to you all, it seems we’ve found a compatible way for the both boxes without the need of making two slightly different implementations!
:slight_smile:
Ondrej

Hi Ondrej,
you where right. There were some old Things left, wich had the position channel. I’ll remove them and check if the Warnings “Cannot find corresponding state name for chanel” and the HttpClient Error will go away.

Thanks again for your support and great plugin!