Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Somfy Tahoma] Add RTS blinds slats tilt support #16285

Open
BasvanH opened this issue Jan 15, 2024 · 17 comments
Open

[Somfy Tahoma] Add RTS blinds slats tilt support #16285

BasvanH opened this issue Jan 15, 2024 · 17 comments
Assignees
Labels
enhancement An enhancement or new feature for an existing add-on

Comments

@BasvanH
Copy link

BasvanH commented Jan 15, 2024

The new Tahoma App is launched by Somfy. They have added tilt support for slats of RTS blinds. Could you please expose the tilt option in the binding.

@BasvanH BasvanH added the enhancement An enhancement or new feature for an existing add-on label Jan 15, 2024
@BasvanH
Copy link
Author

BasvanH commented Jan 18, 2024

I have debugged the tilt requests, and there are they:

Tilt UP:

POST https://ha101-1.overkiz.com/enduser-mobile-web/enduserAPI/exec/apply?optimizeWithProtocolGroups=true HTTP/1.1
Authorization: Bearer XXXXXXXX
X-OVK-API-Key: 5a5e0523-b9f9-4111-a879-775e7d871346
X-OVK-Application-Id: tahoma3-android
User-Agent: Dalvik/2.1.0 (Linux; U; Android 14; sdk_gphone64_x86_64 Build/UE1A.230829.036.A1);tahoma
Content-Type: application/json; charset=UTF-8
Content-Length: 134
Host: ha101-1.overkiz.com
Connection: Keep-Alive
Accept-Encoding: gzip

{"label":"apply","actions":[{"deviceURL":"rts:\/\/1227-9296-2XXX\/16746XXX","commands":[{"name":"tiltNegative","parameters":[3,0]}]}]}

Tilt DOWN:

POST https://ha101-1.overkiz.com/enduser-mobile-web/enduserAPI/exec/apply?optimizeWithProtocolGroups=true HTTP/1.1
Authorization: Bearer XXXXXX
X-OVK-API-Key: 5a5e0523-b9f9-4111-a879-775e7d871346
X-OVK-Application-Id: tahoma3-android
User-Agent: Dalvik/2.1.0 (Linux; U; Android 14; sdk_gphone64_x86_64 Build/UE1A.230829.036.A1);tahoma
Content-Type: application/json; charset=UTF-8
Content-Length: 134
Host: ha101-1.overkiz.com
Connection: Keep-Alive
Accept-Encoding: gzip

{"label":"apply","actions":[{"deviceURL":"rts:\/\/1227-9296-2XXX\/16746XXX","commands":[{"name":"tiltPositive","parameters":[3,0]}]}]}

The number in this captures is 3 but can be in range of 1 to 5. This is the amount of tilt need to be applied.

The result of both requests is:

HTTP/1.1 200
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-XSS-Protection: 1; mode=block
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Thu, 18 Jan 2024 10:05:58 GMT
Server: overkiz

31
{"execId":"1c08dbcb-0a19-0482-5287-3eb946266230"}
0

@BasvanH BasvanH changed the title [Somfy Tahoma] Add blinds tilt support [Somfy Tahoma] Add RTS blinds slats tilt support Jan 18, 2024
@BasvanH
Copy link
Author

BasvanH commented Jan 19, 2024

This is a screenshot of the feature.

The more you move the slider up or down the number increases but nothing happens until you release the slider. Then it sends the number and the slats execute the tilt amount. When the slider is released it returns to the middle.

Slider up = tiltNegative
Slider down = tiltPositive

Screenshot_20240119-113553

@octa22 octa22 self-assigned this Jan 20, 2024
@octa22
Copy link
Contributor

octa22 commented Jan 20, 2024

OK, I get the point, how do you want to control it in OH? Two new command channels tilt_positive, tilt_negative - each incresing the specific tilt by the number provided, default 1 and max 5? thanks

@BasvanH
Copy link
Author

BasvanH commented Jan 20, 2024

Yes, like this, two number channels.

@octa22
Copy link
Contributor

octa22 commented Jan 27, 2024

Here is the latest snapshot based on the OAUTH branch and containg support for your blinds. Please remove the original blinds from OH and let it rediscover new blinds. Up/Down Venetian blinds should appear with a control and a new tilt dimmer channel. The tilt channel expects a number in <-5..5> range and decides whether to send tiltNegative or tiltPositive commands. Please let me know if it is working or not. In case it doesn't work as expected, please, provide me with the debug log. Thanks.
https://www.dropbox.com/scl/fi/iggw634q0dvhb0mx8q0da/org.openhab.binding.somfytahoma-4.2.0-SNAPSHOT.jar?rlkey=sko2uwq0anevl50xln0m8p942&dl=1

@BasvanH
Copy link
Author

BasvanH commented Jan 29, 2024

Alright, I did the testing.

I have removed a blind and added it again. It is discovered as Somfy Up/Down Venetian Blind and has the Tilt channel.

When creating a Item on the Tilt channel a Dimmer type is suggested. When using this and use the Dimmer widget the OH REST API returns a 400 Bad Request, no matter which command I send, positive, negative number. Always a 400 Bad Request.

I then added a Number type Item and linked it to the tilt channel. I then send commands to this item. The Item gets updated but nothing happens in the binding. Trace/Debug logs show no activity in the Somfy binding. Other commands on the Thing work, just the Tilt doesn't seem to do anything.

I tested this with multiple blinds, same result.

@octa22
Copy link
Contributor

octa22 commented Jan 29, 2024

OK, check this version and provide me with the trace log, if it returns 400 it must send some command, which the cloud does not support.
This version doesn't fix anythig, just adds some debug logs.
Thanks
https://www.dropbox.com/scl/fi/538lpq7i5z8iwt0p2mub7/org.openhab.binding.somfytahoma-4.2.0-SNAPSHOT.jar?rlkey=71bsqm7sseb9b5wyxdde22oua&dl=1

@BasvanH
Copy link
Author

BasvanH commented Jan 30, 2024

Thanks, cleared the cache and tmp folders and installed this new version. Same result and no log entries during the Dimmer test. It's not making any requests to Somfy and the OH API returns a 400. I checked with tcpdump, there's really no request being made.

POST http://x.x.x.x:8080/rest/items/Somfy_Keuken_Klein_raam_Tilt HTTP/1.1
Host: x.x.x.x:8080
Connection: keep-alive
Content-Length: 2
X-Requested-With: XMLHttpRequest
Authorization: Bearer xxxx
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Content-Type: text/plain
Accept: */*
Origin: http://x.x.x.x:8080
Referer: http://x.x.x.x:8080/settings/things/somfytahoma:updownvenetianblind:a52746421f:rts1227929624791674xxxx/links/Somfy_Keuken_Klein_raam_Tilt/tilt
Accept-Encoding: gzip, deflate
Accept-Language: nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7
Cookie: _pk_id.1.4f3d=1ac8c5d01478f824.1690543726.; X-OPENHAB-SESSIONID=67a357f8-d796-42e8-beae-7f1c1742a44c;

-5

Response

HTTP/1.1 400 Bad Request
Date: Tue, 30 Jan 2024 11:16:56 GMT
Content-Length: 0
Server: Jetty(9.4.52.v20230823)

@octa22
Copy link
Contributor

octa22 commented Jan 30, 2024

Thanks, I thing I fixed it, now it should work :-) The channel was marked as read-only, sorry for your time spent.
https://www.dropbox.com/scl/fi/538lpq7i5z8iwt0p2mub7/org.openhab.binding.somfytahoma-4.2.0-SNAPSHOT.jar?rlkey=71bsqm7sseb9b5wyxdde22oua&dl=1
please let me know if it works...

@BasvanH
Copy link
Author

BasvanH commented Jan 31, 2024

Sorry, still a 400 from OH API.

I noticed the <state /> element in the channels.xml closes itself, should it perhaps be like <state></state>?
Edit: This should not be a problem, this seems supported.

Is a negative value for Dimmer supported?

https://github.com/octa22/openhab2-addons/blob/71f0a861d2da638915def07f368ca10a42e58ea3/bundles/org.openhab.binding.somfytahoma/src/main/resources/OH-INF/thing/channels.xml#L892

@BasvanH
Copy link
Author

BasvanH commented Feb 1, 2024

On a side note, I wanted to test some things on the code myself but I when I compile the new binding with maven and deploy it I get this error when OH starts:

2024-02-01 08:30:17.161 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:
java.lang.NoClassDefFoundError: org/openhab/core/config/discovery/AbstractThingHandlerDiscoveryService
        at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
        at java.lang.ClassLoader.defineClass(ClassLoader.java:1017) ~[?:?]
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:283) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:716) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:639) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:607) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:587) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:566) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:335) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:397) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:500) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168) ~[org.eclipse.osgi-3.18.0.jar:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[?:?]
        at org.openhab.binding.somfytahoma.internal.handler.SomfyTahomaBridgeHandler.getServices(SomfyTahomaBridgeHandler.java:476) ~[?:?]
        at org.openhab.core.thing.binding.BaseThingHandlerFactory.registerServices(BaseThingHandlerFactory.java:146) ~[?:?]
        at org.openhab.core.thing.binding.BaseThingHandlerFactory.registerHandler(BaseThingHandlerFactory.java:140) ~[?:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.doRegisterHandler(ThingManagerImpl.java:531) ~[?:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.registerHandler(ThingManagerImpl.java:512) ~[?:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.registerAndInitializeHandler(ThingManagerImpl.java:927) ~[?:?]
        at org.openhab.core.thing.internal.ThingManagerImpl.checkMissingPrerequisites(ThingManagerImpl.java:1124) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
        at java.lang.Thread.run(Thread.java:840) [?:?]
Caused by: java.lang.ClassNotFoundException: org.openhab.core.config.discovery.AbstractThingHandlerDiscoveryService cannot be found by org.openhab.binding.somfytahoma_4.2.0.202402010726
        at org.eclipse.osgi.internal.loader.BundleLoader.generateException(BundleLoader.java:541) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass0(BundleLoader.java:487) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:416) ~[org.eclipse.osgi-3.18.0.jar:?]
        at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:168) ~[org.eclipse.osgi-3.18.0.jar:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:525) ~[?:?]
        ... 27 more

When I compile I have an extra file in the jar: /OSGI-INF/org.openhab.binding.somfytahoma.internal.discovery.SomfyTahomaItemDiscoveryService.xml

When I remove this line from internal/discovery/SomfyTahomaItemDiscoveryService.java the extra file in the jar is gone but still got the error like above.

@Component(scope = ServiceScope.PROTOTYPE, service = SomfyTahomaItemDiscoveryService.class)

Any idea whats going on here?

@BasvanH
Copy link
Author

BasvanH commented Feb 1, 2024

Ok got it solved. I cherry picked your code to the 4.1.x branch, now the binding starts without errors. Looks like something changed in the meanwhile where your code does not account for yet.

I then started testing and got the 400 REST API error solved. When I change min="-5" to min="0" it no longer gives the 400. So we need to find a other way to deal with the tilting. Negative number doesn't seem to be supported on Dimmer channel type.

We could change it to Number channel type, it support the negative number. Confirmed working.

@octa22
Copy link
Contributor

octa22 commented Feb 1, 2024

Yeah the compilation with the 4.1.1 branch is one way (but discovery is not working for the new thing), another one is to replace the SomfyTahomaItemDiscoveryService.java with the attached one and compiling with the -Dohc.version=4.1.1 parameter.
SomfyTahomaItemDiscoveryService.zip

@octa22
Copy link
Contributor

octa22 commented Feb 1, 2024

So I will change it to Number - thank you very much for testing.

@BasvanH
Copy link
Author

BasvanH commented Feb 28, 2024

Hi @octa22, have you committed the changes and is it ready to be released?

@BasvanH
Copy link
Author

BasvanH commented Apr 1, 2024

Hi @octa22, could you please finish this? Thanks in advance.

@BasvanH
Copy link
Author

BasvanH commented Jun 3, 2024

Hi @octa22, could you please finish this one to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

No branches or pull requests

2 participants