nikkow / node-red-contrib-tahoma

Node-RED module to control a Somfy Tahoma box (Roller shutters...). Used for home automation flows.
Apache License 2.0
19 stars 11 forks source link

Auth Problem non-matching callback #39

Open hmwelsch opened 4 years ago

hmwelsch commented 4 years ago

I am currently migrating my Node-Red installation from one machine (RPI3) to another one (RPI4 8GB). Setup is to the best of my knowledge identical. Migration to NR via import in RPI4 after fresh install. NR runs on the same local host (RPI3 or RPI4, but never concurrent). All else works fine.

Somfy on RPI3 OK (with http://127.0.0.1:1880/somfy/callback) as usual :-)

Somfy on RPI4 FAILS with non-matching callback error :-(((

I have of course also read issue #27 and tried all permutations suggested there as well.

http://127.0.0.1:1880/somfy/callback
http://127.0.0.1:1880/
http://localhost:1880/somfy/callback
http://-real IP in local network-:1880/somfy/callback
http://-hostname-:1880/somfy/callback

The result is always identical (non-matching callback), no matter what I do.

I have also waited for 24h to give time for potentially needed processing with the new Somfy app: same result.

I would appreciate very much any help on how to further debug/proceed on this issue.

BTW: I am very grateful for the excellent work on this contrib! For me this is the best solution to integrate Somfy at all.

hmwelsch commented 4 years ago

Just saw similar problem #24 being closed! Lucky jemmail! I am glad for you. However, I just tried again with same approach, but to no avail.

kwithus commented 4 years ago

Same problem here. I have redmatic installed on Homematic CCU3, successfully added your Tahoma node, registered the redmatic app with Somfy, entered key and secret to Tahoma-config. After that, I am kind of lost. When I try to create. Workflow, adding a node, click on edit and then I click on the link to reset the token, I then reach a Somfy site asking for permissions for the app, doing this I receive the above message about non-matching callback.

Any solution?

phobeus81 commented 4 years ago

I am suffering something similiar. Getting the permission from Somfy, but being unable to retrieve the tokens. Tried all combination of the callback url so far.

nikkow commented 4 years ago

Hello, I sent an email (again) to Somfy. This issue is clearly on their end. I'll keep you posted.

kwithus commented 4 years ago

Thanks, Somfy is really very unreliable. I use the Somfy Tahoma API also within my Mediola Neo Creator setting. Today same issue there (again) connection was lost and he to be re-enabled. Nothing I want to have within a Smarthome setup. For my I/o Devices, which are all Velux, I will change to Velux active. For my old Somfy RTS, I probably go back to fHEM

hmwelsch commented 4 years ago

Thank you all again too. I have also left a message for tech support on their site as well ...

nikkow commented 4 years ago

Thanks to @hmwelsch's help, we kind of sorted this out with Somfy.

For now, they are still investigating the issue, but it seems they found out the root cause (quoting them: _Issue is on our side when syncing callback_url among systems._).

As of today, the only workaround is to contact them through this contact form, so they can manually fix each affected callback in their database.

Roaders commented 4 years ago

I am having this issue as well. I spent nearly £300 on the Tahoma box and I can't log in!!! Have sent a support request to Somfy...

I have tried to set this up using the webhook example and the local network address example.

Just to clarify. The callback url should be an externally accessable url should it? This is the url the somfy server calls to send the access token to? If that is the case I think that the page here needs to be updated to make this clear and possibly include the webhooks example. I for one do not expose my node-red server to the external internet at all.

whoami-pi commented 4 years ago

Hi, thank you for this great job. For me the local callback url is somehow working.

Its possible to call API once and the blind are working as expected.

The issue I have currently is that a second call later doesn't work anymore, like about 1 hour later. If I do the registration with new token manually again it works again for a while (1 hour).

Does somehow have any clue how to solve this issue?

Thanks in advance.

Roaders commented 4 years ago

still no reply from Somfy. Not even an automated response saying they got my support request. I phoned them and they had no idea how to contact the developer team. Really does seem like a terribly run company (The app is AWFUL as well). Considering returning my Tahoma and replacing with a Conexion instead seeing as the API doesn't work - possibly replacing the whole thing with a raspberry pi and an arduino to control the blinds directly.

How long has it taken for people to get responses from the support form? Does anyone have an e-mail address they can share we me that I can try?

Thanks

hmwelsch commented 4 years ago

still no reply from Somfy. Not even an automated response saying they got my support request. I phoned them and they had no idea how to contact the developer team. Really does seem like a terribly run company (The app is AWFUL as well). Considering returning my Tahoma and replacing with a Conexion instead seeing as the API doesn't work - possibly replacing the whole thing with a raspberry pi and an arduino to control the blinds directly.

How long has it taken for people to get responses from the support form? Does anyone have an e-mail address they can share we me that I can try?

Thanks

Sad as it is, but see nikkows comment from Aug. 25 above: "As of today, the only workaround is to contact them through this contact form, so they can manually fix each affected callback in their database."

whoami-pi commented 4 years ago

Yeah but I've RP4 and the initial set up somehow is working to get the token. I'm able to execute commands in Node red.

After a while less than 2 hours, its not working anymore. Is this same issue as you are referring to?

If I request new token manually same as before, works next 1-2 hours....😩

VoetenK commented 3 years ago

Possible solution:

pinkfloydFR commented 3 years ago

Possible solution:

  • Log in to https://www.tahomalink.com
  • Choose hamburger ico> my account
  • Click on "My Somfy account"
  • Click on "Give someone else access to my box"
  • Click in Node-RED on "link Node-RED to tahoma" I have used my local IP address.

Not working for me :(

Any news about this fu... problem ?

frankis78 commented 3 years ago

Possible solution:

  • Log in to https://www.tahomalink.com
  • Choose hamburger ico> my account
  • Click on "My Somfy account"
  • Click on "Give someone else access to my box"
  • Click in Node-RED on "link Node-RED to tahoma" I have used my local IP address.

Not working for me :(

Any news about this fu... problem ?

What is your callback url in the apps when you login to https://developer.somfy.com/user/me/apps Is it http://xxx.xxx.xx.xx:1880/ (Where xxx.xxx.xx.xx is the local ip of your node red installation) I have to run HTTP, and not HTTPS on my app And what is your app name, which you put in Node-red? Mine is example: Node-Red-MQTT-Homeseer

pinkfloydFR commented 3 years ago

Hi :)

I am using home assistant virtual machine, i am behind an apache2 virtual host proxy.

In the somfy website i use : "https://homeassistant.xxx.com/auth/somfy/callback" In node Node-Red, like in developper.somfy.com, is "home_assistant" Locally my url is : 192.168.0.9:8123

in my apache log i have this :

apache conf :

and nothing in my apache error log

Thanks for helping !

frankis78 commented 3 years ago

Try to use your local ip instead. (Just create a new app for testing) Here is my app in somfy dev account, and it works for me. Unless the token is expired, then i just need to reactivate it. (Remember that it can take up an hour before it is reactivated.) 2021-03-27_11-10-08

pinkfloydFR commented 3 years ago

Tried this :

no success so far...

EDIT : wait wait wait !!! 1880 ?? this is the node red port !

frankis78 commented 3 years ago

Yes 1880 is my node red port Try http://192.168.0.9:1880 <- if you dont have ssl sertificate, or with https if you have ssl sert

Then approve update and deploy. After maybe 10 min, go back into the node red node, to see if it finds the tahoma box and its device 2021-03-27_11-26-28

pinkfloydFR commented 3 years ago

Yes i think this is my problem, i didn't think about this is not home assistant !

Will check/correct my proxy conf, will return my result ! thanks !

frankis78 commented 3 years ago

Could be that you are into a good route now:) Im not an expert at all, but i can confirm that it works, and if it works its good;) Let us know.

Pitel commented 3 years ago

I still can't make it to work :crying_cat_face:

$ curl -v http://192.168.86.3:1880/somfy/callback
*   Trying 192.168.86.3:1880...
* TCP_NODELAY set
* Connected to 192.168.86.3 (192.168.86.3) port 1880 (#0)
> GET /somfy/callback HTTP/1.1
> Host: 192.168.86.3:1880
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Content-Type: text/html; charset=utf-8
< Date: Sat, 27 Mar 2021 13:36:18 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< Transfer-Encoding: chunked
< 
<script type="text/javascript">

    const URL_PARAMS = new URLSearchParams(window.location.search);
    const CODE = URL_PARAMS.get("code");
    const OPENER = window.opener;

    if (OPENER) {
        OPENER.handleOAuthCode(CODE);
        window.close();
    } 

</script>
* Connection #0 to host 192.168.86.3 left intact

When I try to link Somfy, I get error page from Somfy (with HTTP 404), the url is: https://accounts.somfy.com/oauth/oauth/v2/auth?response_type=code&client_id=8hRitlNvrU1v8wDZ94MYERxtUuUW7XO6YQoB4_ekj5NVqTg8R32120LESOLK6fYNJoQgMFIQXlJO4Ct1v51zQ53T&redirect_uri=http://192.168.86.3:1880/somfy/callback&state=setup&grant_type=authorization_code

frankis78 commented 3 years ago

Thats weird. Is this your node-red installation ? http://192.168.86.3:1880/ with ip and port of your node red?

Do you get the popup window for retrieving your access token in node red? And do you use your credentials for this page? https://accounts.somfy.com/login <-- try to login here to see that you use correct credentials 2021-03-27_14-58-24

Pitel commented 3 years ago

Yes, http://192.168.86.3:1880 is my running node-red installation. If I click the link, it opens up.

Snímek z 2021-03-27 20-50-37

Yes, I get the popup, I can log in, but I get that error and 404.

Snímek z 2021-03-27 20-50-20

In the devtools, I can see there is no request to 192.168.86.3, so I guess there is something wrong on Somfy's side?

There is my app: Snímek z 2021-03-27 20-54-43 Snímek z 2021-03-27 20-55-04

FYI, I can control my blinds with TaHoma Android app and Google Home Mini voice assistant.

frankis78 commented 3 years ago

Try to make a callback url by using webhook.site , and copy the url to your somfy app, to see if that works instead of your local. You still need to login to your somfy account in node red, when you authorize.

Programmierfreund commented 3 years ago

Suggestion for workarounds

I had also tried myself in 2020 with direct coupling of Somfy Tahoma API with Node-Red, but then left it. I found the following workarounds:

  1. calling Somfy scenarios via IFTTT. Pairing via IFTTT is not always stable - but works satisfactorily overall. One can use from Node-Red e.g. the following node: https://flows.nodered.org/node/node-red-contrib-ifttt. The disadvantage is that IFTTT now only allows two free applets. Setting up a Maker Channel or even webhooks is a bit tricky.
  2. pairing of older Somfy RTS devices via RFLink (https://www.nodo-shop.nl/en/42-rflink-868-kit). But this does not (!) work with the newer io devices. For controlling RTS devices you can use the following node: https://flows.nodered.org/node/node-red-contrib-rflink. I have only RTS shutters and local pairing works great - no cloud at all.
  3. pairing via Amazon Alexa https://support.somfyprotect.com/hc/en-us/articles/209026909-How-to-control-your-Somfy-Home-Alarm-System-with-Amazon-Alexa-. If you have an Echo Plus device, you might also be able to use the Smart Home Hub: https://flows.nodered.org/node/node-red-contrib-amazon-echo. I myself use Amazon Alexa to control the shutters by voice. The pairing with the Tahoma API works similarly satisfactorily as with IFTTT.

I hope that I have given you new ideas before you despair of the problem 😉

Pitel commented 3 years ago

@frankis78 Webhook.site is nice, thanks for the tip.

But, I changed it at Somfy's website and tried it right away. With same result. But then I noticed there is still my IP in callback parameter in URL. So I went to bed and let it be over the night and now, 12+ hours later, tried it again. But it is the same. The URL opened from Node RED is still https://accounts.somfy.com/oauth/oauth/v2/auth?response_type=code&client_id=8hRitlNvrU1v8wDZ94MYERxtUuUW7XO6YQoB4_ekj5NVqTg8R32120LESOLK6fYNJoQgMFIQXlJO4Ct1v51zQ53T&redirect_uri=http://192.168.86.3:1880/somfy/callback&state=setup&grant_type=authorization_code (notice the redirect_uri).

I'm wondering, if the redirect_uri is set byt Node RED/Somfy plugin, or it's directly from Somfy, telling me there might be something wrong with DB sync or something on their side.

frankis78 commented 3 years ago

Is it possible to replace the callback url with the webhook.site url, before you Approve it? Means that when you are about to approve it, you just exchange your local url parameter with the webhook.site parameter, and then click approve?

Pitel commented 3 years ago

Yes, I can, and the result is the same. Also, I don't even get to the Approve button, I get the error page immediately after login.

Roaders commented 3 years ago

Coming back to this after nearly a year and exactly the same. I had thought that maybe they might have fixed it. This really annoys me because it's a ridiculously over priced bit of kit and their support is non-existent.

Roaders commented 2 years ago

I did get a response from Somfy 10 months after my first support request. Their response:

We are really sorry if we missed your first contact. This issue has been lasting but we are still facing it. A few fixes were made but they were not satisfactory. Unfortunately, at the moment you have no other option but to wait for a new fix to be deployed.

6 months after that it's still not working.