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

Unable to connect diyHue with SleepCycle app #981

Open
a-i-ks opened this issue Jan 5, 2024 · 21 comments
Open

Unable to connect diyHue with SleepCycle app #981

a-i-ks opened this issue Jan 5, 2024 · 21 comments

Comments

@a-i-ks
Copy link

a-i-ks commented Jan 5, 2024

Issue does not already exist?

I have searched and found no existing issue

Select Environment

Docker

Home Assistant related?

No

Description

I would like to connect my diyHue bridge to the SleepCycle app. The app usually only supports Philips Hue. But since I want to use a non-Hue compatible device to wake me up, I want to use the diyHue bridge for this. Unfortunately, the diyHue bridge is not found in SleepCycle. I have no option there to configure a manual connection via an IP address. An original Philips Hue bridge is found and can be connected.
I assume that the diyHue bridge cannot be found correctly via ssdp. In the Hue Essentials app, only the original Philips Hue Bridge appears via Auto Discovery the first time it is started. However, the diyHue can be connected manually in Hue Essentials.

Errorlog:

2024-01-05 21:30:02,699 - werkzeug - INFO - 192.168.178.101 - - [05/Jan/2024 21:30:02] "GET /api/672feeacac0911ee811e0242ac130002/groups/0 HTTP/1.1" 200 -
2024-01-05 21:30:17,605 - configManager.argumentHandler - INFO - Using Host 192.168.178.129:80
2024-01-05 21:30:17,606 - configManager.argumentHandler - INFO - Host MAC given as a7de8995a2ed
2024-01-05 21:30:17,606 - configManager.argumentHandler - INFO - IP range for light discovery: 0-255
2024-01-05 21:30:17,606 - configManager.argumentHandler - INFO - Deconz IP given as 127.0.0.1
2024-01-05 21:30:17,606 - configManager.argumentHandler - INFO - Online Discovery/Remote API Enabled!
2024-01-05 21:30:17,610 - configManager.argumentHandler - INFO - Using Host 192.168.178.129:80
2024-01-05 21:30:17,610 - configManager.argumentHandler - INFO - Host MAC given as a7de8995a2ed
2024-01-05 21:30:17,610 - configManager.argumentHandler - INFO - IP range for light discovery: 0-255
2024-01-05 21:30:17,611 - configManager.argumentHandler - INFO - Deconz IP given as 127.0.0.1
2024-01-05 21:30:17,611 - configManager.argumentHandler - INFO - Online Discovery/Remote API Enabled!
2024-01-05 21:30:17,613 - configManager.argumentHandler - INFO - Debug logging disabled!
2024-01-05 21:30:17,643 - configManager.configHandler - INFO - Config loaded
2024-01-05 21:30:17,777 - services.remoteDiscover - INFO - Starting discovery service
2024-01-05 21:30:17,784 - services.stateFetch - INFO - start lights sync
2024-01-05 21:30:17,787 - services.ssdp - INFO - starting ssdp...
2024-01-05 21:30:17,788 - services.ssdp - INFO - start ssdp broadcast
2024-01-05 21:30:17,789 - services.mdns - INFO - <MDNS> listener started
 * Serving Flask app 'HueEmulator3' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
2024-01-05 21:30:17,796 - werkzeug - WARNING -  * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
2024-01-05 21:30:17,796 - werkzeug - INFO -  * Running on http://172.19.0.2:80/ (Press CTRL+C to quit)
 * Serving Flask app 'HueEmulator3' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
2024-01-05 21:30:17,804 - werkzeug - WARNING -  * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
2024-01-05 21:30:17,805 - werkzeug - INFO -  * Running on https://172.19.0.2:443/ (Press CTRL+C to quit)
2024-01-05 21:30:39,707 - werkzeug - INFO - 192.168.178.101 - - [05/Jan/2024 21:30:39] "GET /api/672feeacac0911ee811e0242ac130002/groups/0 HTTP/1.1" 200 -
2024-01-05 21:30:40,794 - services.stateFetch - INFO - start lights sync

Steps to reproduce

Install diyHue, try to connect to SleepCycle App

Please enter your operating system details here

I have started diyHue with the following Docker compose:

version: '3'
services:
  diyHue:
    image: 'diyhue/core:latest'
    container_name: diyHue
    restart: unless-stopped
    environment:
      - DEBUG=false
      - MAC=a7:de:89:95:a2:ed
      - IP=192.168.178.129
    volumes:
      - '/opt/stacks/diyhue/config:/opt/hue-emulator/config'
    ports:
      - '80:80'
      - '443:443'
      - '1900:1900/udp'
      - '2100:2100/udp'
      - '1982:1982/udp'

What DiyHue version(branch) are you using?

master (latest)

@mariusmotea
Copy link
Member

Hi,

From what i know SSDP traffic cannot be forwarded to docker network, so to have it working you need to use host network mode instead to manually specify the binding ports.

@a-i-ks
Copy link
Author

a-i-ks commented Jan 6, 2024

Ah, thanks for the information. I will try to install diyHue in host mode and and I'll let you know if it works.

I have made some progress, but unfortunately I have not been able to solve my problem conclusively.
In host mode, diyHue is displayed by the Hue Essentials app. This means that the ssdp is now working. Unfortunately, SleepCycle only recognizes my Philips hue bridge. diyHue seems to behave differently than the Philips hue bridge in some point during discovery. But from here on you can only make assumptions because there is no log or similar in the SleepCycle app. What a pity, my use case is probably not feasible.

@a-i-ks a-i-ks changed the title diyHue Bridge is not found via ssdp Unable to connect diyHue with SleepCycle app Jan 9, 2024
@alexejFroebel
Copy link

Any updates on this? I have the same problem.

@a-i-ks
Copy link
Author

a-i-ks commented Jul 22, 2024

Unfortunately not. I don't know what's the problem, that diyHue is not found by Sleep Cycle but the Philips hue bridge is. I would love to solve the issue. I have such cool automations in mind. Currently SleepCycle only supporting Apple Home scenes when you turn off the alarm, not at the first time, when the wake up window starts. I was trying to solve this by using DiyHue as a light but trigger some other things in my smart home.

@hendriksen-mark
Copy link
Member

Hi, if you want to connect to diyue does the sleep app ask for philips cloud login?
If so that does not work because diyhue can not acces philips cloud.
If not and it does a local network search then it should work.

@alexejFroebel
Copy link

No, it just scans for devices in the local network. Hue essentials and alexa are finding those devices, but if i search in the sleep cycle app, it just wont try to get infos from diyHue ( I can see that there is no api request to the config endpoint). If i try it with my real hue bridge, it works instantly. So how could this app spot a difference from the normal hue bridge. Any Ideas?

@a-i-ks Exactly the same for me, I also submitted a feature request to sleep cycle that they also add homekit support for when the alarm triggers, but i dont think I am the first one asking, so I dont think they will do this..

@mariusmotea
Copy link
Member

Probably they use cloud based detection, and diyHue is not registred with Hue cloud servers to work. Maybe if you block the internet temporary you can see some pairing requests?

@a-i-ks
Copy link
Author

a-i-ks commented Jul 23, 2024

@a-i-ks Exactly the same for me, I also submitted a feature request to sleep cycle that they also add homekit support for when the alarm triggers, but i dont think I am the first one asking, so I dont think they will do this..

How funny to see that there are people who had the same idea to improvise the missing function of SleepCycle. I wouldn't write off completely yet that the developers of Sleep Cycle will add the feature at some point. We just have to nag them long enough. I did that for years with the HomeKit scenes and eventually they got my wish. I think the functionality is partly thanks to my months of begging. Unfortunately, it's not quite as comprehensive as I had hoped.

Probably they use cloud based detection, and diyHue is not registred with Hue cloud servers to work. Maybe if you block the internet temporary you can see some pairing requests?

I will try this in the next days. Thanks for your support @mariusmotea

@hendriksen-mark
Copy link
Member

hendriksen-mark commented Jul 23, 2024

I just downloaded the app and tried it.
Sleepcycle is using cloud based services.
Scherm­afbeelding 2024-07-23 om 21 30 20
If the internet is blocked on the router using parent control the app still cant find it.
Sleep cycle can not be used with diyhue.

I made a feature request to Sleepcycle if they can add a local bridge search.

@alexejFroebel
Copy link

First of all thank you. So it should theoratically be possible to override the dns routing locally for discovery.meethue.com to discovery.diyhue.com? Like mentioned in here: #217 ? I dont know really much about network routing, but I assume overriding a dns to another ip should be possible in a router, or?

@hendriksen-mark
Copy link
Member

Yes im testing this now.

@hendriksen-mark
Copy link
Member

hendriksen-mark commented Jul 23, 2024

It is possible with a proxy, it is not easy but the sleepcycle app connects to diyhue.
I did it with mitmproxy and this example and change it to this:

from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    # pretty_host takes the "Host" header of the request into account,
    # which is useful in transparent mode where we usually only have the IP
    # otherwise.
    if flow.request.pretty_host == "discovery.meethue.com":
        flow.request.host = "discovery.diyhue.org"

here some links that i used:
https://medium.com/testvagrant/intercept-ios-android-network-calls-using-mitmproxy-4d3c94831f62
https://superuser.com/questions/902705/mitmproxy-how-to-configure-a-redirect-for-requests

@alexejFroebel
Copy link

Thank you very much, I will try this as soon as I am home

@alexejFroebel
Copy link

I was able to get it working with your example, but unfortunately it seems that this only works one time, since the app always calls the auto discover endpoint. But I will do more testing on this. But now I know what the problem ist and can think of a solution. Thank you very much

@hendriksen-mark
Copy link
Member

You can also look if your router can redirect https, NAT port forwarding does not work.

@a-i-ks
Copy link
Author

a-i-ks commented Jul 24, 2024

Could my local Pi-hole DNS server, which I use in my home network for all devices (including my iPhone), be used to redirect the discovery URL?

@hendriksen-mark
Copy link
Member

dns works with ip addresses and the diyhue discovery serves can not work with ip addresses because it needs to see discovery.diyhue.org, also cname is not designed for this and also does not work.

@hendriksen-mark
Copy link
Member

This is the reaction of sleep cycle.

Antonia (Sleep Cycle AB)
Jul 25, 2024, 15:19 GMT+2

Hi Hendriksen-mark, 
 
Thank you for contacting us.
 
We are always on the hunt for new features that bring added value to our users, and the suggestions we receive from our users really help.
 
Thank you for your suggestion, we will add it to our list.
 
All the best,
Antonia

@alexejFroebel
Copy link

Exaclty the same response for me

@hendriksen-mark
Copy link
Member

I have an other idea to trik the system but dont know if this will last, i will update when i know something

@hendriksen-mark
Copy link
Member

Sorry what i wanted to do is not possible since version 1.37.
The only way to get this to work is if sleepcycle changes the way the app work or setup a permanent proxy to redirect the request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants