diyhue / diyHue

Main diyHue software repo
https://diyhue.org/
Other
1.52k stars 274 forks source link

Sleep as android can no longer connect with diyHue #19

Closed Nostras closed 4 years ago

Nostras commented 5 years ago

Describe the bug DiyHue used to work fine with Sleep as android.

To Reproduce Steps to reproduce the behavior: Simply install sleep as android and attempt to connect it with diyHue, it will hang on attempting to add it. I tried installing an older version, but with these it still fails. As diyHue has been updated I assume the problem must lie here.

Expected behavior Well, it should be working.

mariusmotea commented 5 years ago

What is this Sleep? An app, a function of Android?

Nostras commented 5 years ago

It's an app. https://play.google.com/store/apps/details?id=com.urbandroid.sleep&hl=en

mariusmotea commented 5 years ago

I see. This app use hueManic as hue plugin and this one don't pair anymore with diyhue. From logs a see a successful pair, this app don't like something from the config. I will try to find out what.

Nostras commented 5 years ago

At least it's not just for me 👍 It did work today though, it broke after I fiddled with some settings and had to reconfigure.

mariusmotea commented 5 years ago

i made some progress. I found following changes:

"creationtime" key is in the new api "created"

missing state => lastupdated and config values

            "state": {
                "flag": true,
                        "lastupdated": "2019-01-08T20:01:00"
            },
            "config": {
                    "on": true,
                    "reachable": true
                },

this will be fixed soon

Nostras commented 5 years ago

Good to hear. Let me know when it is available and I'll make sure to share my experiences.

Nostras commented 5 years ago

I tried it again as someone mentioned it worked here. https://github.com/diyhue/diyHue/issues/51

The current version is not detected by Sleep ( at all ) and Hue won't connect. I don't really care about the latter tbh.

image

Joshuant commented 5 years ago

It is OK after Sleep As Android update!

Nostras commented 5 years ago

I am running 20181212 and as far as I know that is the latest version. That one doesn't work for me.

Joshuant commented 5 years ago

Yesterday I obtained a new version 20190109.

Nostras commented 5 years ago

Even apkpure says that the latest version is 20181212. How the hell did you get your hands on that one? https://apkpure.com/sleep-as-android-sleep-cycle-tracker-smart-alarm/com.urbandroid.sleep

Sorry @diyHue for going a bit off topic, but this is bugging me.

APKPure.com
Sleep for Android - APK Download
Download Sleep apk 20181212 for Android. Track your sleep and wake up gently with nature sounds in optimal sleep phase
Joshuant commented 5 years ago

It is weird. Maybe it is because I am form Czech Rep. like author of this app.

screenshot_20190122-232301

Nostras commented 5 years ago

Yeah, Sleep as Android only shows a bridge on address 192.168.1.124 as a valid huebridge, that subnet is not even used where I am, everything is 192.168.123.XXX. That also makes it kind of obvious that this is not the fault of DiyHue as far as I can tell. I can't even bloody enter a static address, dumbing down interfaces ffs.

Nostras commented 5 years ago

I dusted off my old phone with a clean sleep as android from the 22nd of January and the one joshuant has. It keeps saying the ip in the previous comment. The DiyHue just doesn't appear at all. I'm once again not sure who to blame, sleep being buggy or diyhue not properly announcing/responding.

ghost commented 5 years ago

Enable debug and post the output when your try pair sleep as android. We will try workout who is to blame 😜

Nostras commented 5 years ago

Might wanna update here that it is now passed as an argument ( -> --debug True ) https://github.com/mariusmotea/diyHue/wiki/Debug Instead of being a variable in the header.

First things first, Sleep as android cannot find the server by default, but it can when it is running with debug. So I think that's a DiyHue thing. It also doesn't seem to work very well if I enble debug but pipe stdout to a file. Strange. Anyways, here's the log. https://pastebin.com/hyyvzH86 It's stuck at line 55 as you can evidently see by the caret C.

GitHub
mariusmotea/diyHue
Philips Hue emulator that is able to control multiple types of lights - mariusmotea/diyHue
Pastebin
[Python] root@DebNas:/opt/hue-emulator# root@DebNas:/opt/hue-emulator# ./HueEmulator3.py - Pastebin.com

For some reason that run the first couple prints are omitted, you know, these "sync with lights", "IP range for light discovery" kind of things.

ghost commented 5 years ago

Thanks for spotting the error in the wiki! I have updated the instructions at ReadTheDocs as all our documentation is there now.

Thanks for the debug, the current behaviour is very odd. @mariusmotea can you have a look at this?

PhoenixTwoFive commented 5 years ago

Hello, I just want to chime in with a piece of information that I thought might be useful: I have the aforementioned issues only when trying to link Sleep as Android/ other apps using hueManic to an instance of diyhue running on an Raspberry Pi (Model B). The "countdown bar" on the app's link screen just freezes. When firing up an instance on my PC in Docker it works flawlessly.

I hope this is in some way useful, feel free to tell me if you could use my help in any way with this.

Nostras commented 5 years ago

Won't even show up in the bridge list.

If it matters I'm running it on an x64 debian stretch platform.

Nostras commented 5 years ago

Err, correction, I cleaned up all my docker images and containers and ran a clean one (as described by rtfm) and, well, I get the freeze again. Might it be a platform thing? I'll attempt running it on my windows pc.

Edit, never mind, seems like a bit too much of a chore to figure it out how to run it on windows 😨

Edit again: Aaand it won't show up again.

PapACutA commented 5 years ago

If i do a new install of diyHue and don't add any lights or rooms my sleep as android app links succesfull. After i added a light and one room with the original Hue app my sleep as android freezes at requesting / getting the config. So it looks like sleep as android really don't like the configuration. Does someone have an Original Hue Bridge that links succesfully with sleep as android so we can look at its configuration and spot the differences.

PapACutA commented 5 years ago

I don't no if it helps but i played a bit with the config.json and after i deleted all scenes my sleep as android linked succesfully. It don't work very well. Without the scenes only one simple dimmable light worked right, my rgb led strips didn't do anything. Edit: If i add a scene manually or with the hue app then sleep as android freezes again.

ghost commented 5 years ago

@PapACutA Did you get anywhere trying to find the source of the issue here?

PapACutA commented 5 years ago

Unfortunately not. I have not really had time to spend more time in the last 2 months either. But my workaround #86 still works for me.

Real-Konai commented 5 years ago

Is there any progress to find this issue? Have anyone tried this apps with an original Hue Bridge? I use Sleep as Android and Twilight as well, wich are from the same developer. Maybe it's an issue in that apps itself, if it is, we can do nothing here. @PapACutA An interesting thing is, your quick and dirty fix works with both apps.

juanesf commented 4 years ago

Today I tried to link sleep as Android with diyHue and connected, someone else can try if it works

alexyao2015 commented 4 years ago

Huematic from the same dev will not pair even with the scene removal patch. We need to look into the scenes returned by diyhue and an actual bridge.

juanesf commented 4 years ago

HueManiac and Sleep as Android works for me. after reinstalling the emulator from scratch

alexyao2015 commented 4 years ago

Really? That must mean that either a recent patch fixed it or changing a setting causes the issue.

alexyao2015 commented 4 years ago

I just tested it again. With a fresh install without any of the default scenes (ie. no scenes at all in the config), both apps pair. The second you add a scene in, it refuses to pair. Clearly, it doesn't like something about the way the scenes are returned. Something that I believe @PapACutA discovered earlier.

We need to figure out what it doesn't like and fix it. Though its hard for me since I don't have an actual bridge.

juanesf commented 4 years ago

I don't know if it affects anything but when I tested the installation and application link it was before the last pull https://github.com/diyhue/diyHue/commit/3470c83b98c10897562652bc2290c13642c9f202

alexyao2015 commented 4 years ago

Did you have scenes before you paired the app?

alexyao2015 commented 4 years ago

Alright I think I found a difference between whats returned with diyhue and the actual api in scenes.

alexyao2015 commented 4 years ago

I believe that I have solved the issue and we can finally put this issue to rest 🎉

Nostras commented 4 years ago

I'm kicking this again as the problem has reappeared after upgrading to Android 10 and having to reconnect everything. I also can't connect through the hue apps, at times it will flash as present very shortly but disappear before I have the chance to connect.

Could you reopen this issue or would you rather I create a new issue?

alexyao2015 commented 4 years ago

Go use the beta version. Believe some new commit caused it. If that doesn't work wipe the config and cert and try again

Nostras commented 4 years ago

The latter I already tried, I'll try the beta tomorrow.

alexyao2015 commented 4 years ago

I've been pretty away from dev for a bit so I haven't validated any of the recent commits to not cause issues but I do have an idea of a commit that's causing issues.

I do remember seeing one that essentially undid my patch which fixed this in the first place.

Nostras commented 4 years ago

I did the manual install (git clone https://github.com/diyhue/diyHue.git), same issue though.

GitHub
diyhue/diyHue
Main diyHue software repo. Contribute to diyhue/diyHue development by creating an account on GitHub.
alexyao2015 commented 4 years ago

Wrong branch. Make sure you use the beta branch. That's the master branch.

https://github.com/diyhue/diyHue/tree/beta?files=1

GitHub
diyhue/diyHue
Main diyHue software repo. Contribute to diyhue/diyHue development by creating an account on GitHub.
Nostras commented 4 years ago

Hmm, I did a clone and checkout to beta, but I can't seem to run it.

image

alexyao2015 commented 4 years ago

Looks like you didn't clear the config.

If that still doesn't work try docker. Dependency versions have been updated in newer versions

Nostras commented 4 years ago

Hmm, still doesn't seem to work. This is what I see when I try to find devices with the hue app. I don't see anything happen when I refresh in sleep as android. image 181 is me, 102 is server, 17 is phone.

I think I installed your version properly, but I can't 100% verify.

It also complains about cert.pem as it is hard linked to /opt, not where it is installed now.

alexyao2015 commented 4 years ago

I'll let it at this, if it's still not working, you did not install it properly. Try things like clearing the config, wiping the os and starting over, or using docker instead. That particular build is known to work properly.

Nostras commented 4 years ago

I already tried the docker one, but I'll kick it again.

Aside from that, I tried following the manual instructions from here. https://diyhue.readthedocs.io/en/latest/getting_started.html Apparently it isn't conclusive then.

Thanks for helping. If it still won't work I'll create a new issue this weekend or so.

Getting Started — diyHue 1.0 documentation
alexyao2015 commented 4 years ago

No need for a new issue. I'm almost positive its not working because of this commit https://github.com/diyhue/diyHue/commit/444fb781712cc770b68c6cd7401b9dc0f27663ad

You are correct, the manual install instructions are incomplete. I would highly suggest using this build here on docker hub docker pull diyhue/core:beta-latest or this one docker pull yaoa/diyhue:DEBUG-latest These two builds are known to be stable (moreso the beta-latest over the debug build) and should not have issues.

Since HueManic and sleep both use the same pairing protocols and since huemanic was last updated prior to the last commit in those branches, its safe to say that those builds definitely work because I have personally tested it.

Nostras commented 4 years ago

I tried to use either, but both exhibit similar behavior. For the record, I tried this. image Verified it was running by going to the IP of the NAS, finally tried to connect through either the Hue app and Sleep as Android. Both no luck.

If what I'm doing is correct and you're confident its working on your end, something is going wrong in the network here.

alexyao2015 commented 4 years ago

So diyhue must have access to port 80 and 443. If your Nas is using either of those ports, it won't work. If the hue app will not connect at all, there is something wrong with your configuration.

Nostras commented 4 years ago

Alright Alex,

I dusted off an old raspberry Pi and tried the three docker images. The debug build and beta-latest both crashloop and can't be ran, sadly.

The official build actually does work, in the Hue app that is (it's progress!)... Sleep as Android however, still won't bloody run. Egh.

Same issue

Hmm, I did a clone and checkout to beta, but I can't seem to run it.

image

alexyao2015 commented 4 years ago

First, have you tried docker? Second, did you clear the config and cert like I asked?

Those two builds have been checked and maintained by me so I know every build there works. If you are still having trouble, ill try to start from scratch using those builds and see if I can reproduce these issues. However, it sounds like a config or dependency issue.