ebaauw / homebridge-hue

Homebridge plugin for Philips Hue
Apache License 2.0
898 stars 91 forks source link

Dimmer switch not responding/updating with node v8.x #125

Closed DJay-X closed 7 years ago

DJay-X commented 7 years ago

Hi there and first of all thanks for the great work @ebaauw and the ongoing development and improvements. Unfortunately I'm getting a little bit desperate with my hue dimmer switch and I couldn't find a solution. So I hope somebody can help here. In the past I already had set up the plugin and also the switch to work great. Due to some other plugins I had to reset homebridge a several times, did a new config.json back and forth. Everything works good now, but unfortunately I can't bring the dimmer switch back to work. On iOS 10.3.2 the switch is in the hue App. Also I linked the plugin to the hue bridge (square) again and put the new user in the config.json. The dimmer switch is showing up as a device in the Home App and Eve App and also the homebridge log is showing the response.

[2017-6-18 18:54:11] [Hue] Hue dimmer switch Off: homekit button single press [2017-6-18 18:54:31] [Hue] Hue dimmer switch Off: homekit button single press [2017-6-18 18:54:47] [Hue] Hue dimmer switch Off: homekit button long press [2017-6-18 18:54:52] [Hue] Hue dimmer switch Off: homekit button single press [2017-6-18 18:54:57] [Hue] Hue dimmer switch Off: homekit button long press [2017-6-18 18:55:02] [Hue] Hue dimmer switch Off: homekit button single press [2017-6-18 18:55:08] [Hue] Hue dimmer switch Off: homekit button long press [2017-6-18 18:55:13] [Hue] Hue dimmer switch Off: homekit button long press [2017-6-18 18:55:18] [Hue] Hue dimmer switch Off: homekit button single press

But in the Apple Home App the selected button is not responding or not updating. e.g. I long press the off button, the homebridge log is showing it but the assigned scene is not starting. And when I check in the Home App the button (4) is not flashing grey. I can when everything was working a couple of months ago it did flash.

Thanks in advance for you friendly help and reply.

{
                  "platform": "Hue",
                  "name": "Hue",
                  "host": "xxx.xxx.xxx.xx",
                  "users": {
                  "xxxx": "xxxxx"
                  },
                  "sensors": true,
                  "excludeSensorTypes": [],
                  "lowBattery": 25,
                  "lights": false,
                  "philipsLights": false,
                  "wallSwitch": false,
                  "groups": false,
                  "group0": false,
                  "rooms": false,
                  "schedules": false,
                  "rules": false,
                  "heartrate": 5,
                  "timeout": 5,
                  "parallelRequests": 10,
                  "waitTimeResend": 300,
                  "waitTimeUpdate": 20
                  }

napkin 8 18 06 17 7 40 32 pm

ebaauw commented 7 years ago

The wonders of HomeKit...

I haven't seen this before. The log and screenshots would suggest everything is OK. I'm running iOS 10.3.2 and the switches flash as expected. Some long shots:

  1. The screenshots show `Hue dimmer switch 1", but the log says "Hue dimmer switch". Sorry to ask, but are you sure you're looking at the right switch? Does the tile in the Home or Rooms view flash when you press a button?

  2. How many accessories do you expose from homebridge? And how many do you have in your home? HomeKit only supports 99 accessories per bridge and above some 150 accessories, iCloud sync of the HomeKit database stalls.

  3. Sometimes HomeKit gets confused when you restart homebridge a number of times in a row, with a slightly changed config. You might try removing the dimmer switch from HomeKit, by specifying "excludeSensorTypes: ["ZLLSwitch"], in config.json and restarting homebridge. Then wait for the switch to disappear on all you iOS devices, before reverting config.json and restarting homebridge again. If that doesn't help, you might try to remove your HomeKit home, re-pair all your accessories and redo the entire HomeKit configuration.

  4. In theory, there could be some interference from another plugin. What happens when you run homebridge with only homebridge-hue?

DJay-X commented 7 years ago

Thanks for your fast reply. I really can't tell, what it is with the name "Hue dimmer switch 1" and just "Hue dimmer switch". I only have one dimmer switch in my home. And not to depreciate your work and the huge possibilities of your plugin, I only use homebridge-hue just for this switch. :) I followed your given advise on point 3). The whole nuke procedure removing the complete home out of HomeKit. Also I removed the plugin, persist and accessories folder, restart and set up the config.json and installed the plugin again. After the procedure and restart I now have a this.

[2017-6-19 18:07:41] [Hue] Philips hue: 10 accessories [2017-6-19 18:07:41] [Hue] Initializing platform accessory 'Philips hue'... [2017-6-19 18:07:41] [Hue] Philips hue: 3 services [2017-6-19 18:07:41] [Hue] Initializing platform accessory 'Daylight'... [2017-6-19 18:07:41] [Hue] Initializing platform accessory 'roomSwitch'... [2017-6-19 18:07:41] [Hue] Initializing platform accessory 'On/Off'... [2017-6-19 18:07:41] [Hue] Initializing platform accessory 'iPhone 7'... [2017-6-19 18:07:41] [Hue] Initializing platform accessory 'HomeAway'... [2017-6-19 18:07:41] [Hue] Initializing platform accessory 'myState'... [2017-6-19 18:07:41] [Hue] Initializing platform accessory 'onOff'... [2017-6-19 18:07:41] [Hue] Initializing platform accessory 'Hue dimmer switch 1'... [2017-6-19 18:07:41] [Hue] Initializing platform accessory 'Dimmer Switch 35 SceneCycle'...

In Home App

"Hue dimmer switch 1" "Dimmer Switch 35 SceneCyle" with marked not supported <- what is this 10 SceneCyle? "Philips hue" Bridge with configurable one Button action, "HomeAway" always activated, though I'm at home "On/Off" not supported "onOff" not supported "roomSwitch" not supported

I noticed when I press the Buttons on the dimmer switch, that again homebridge log is all showing right, but automatically in addition an entry with the "Dimmer Switch 10 SceneCycle". And in the Home App the buttons are still not flashing grey and no scene is started. The "Dimmer Switch 35 SceneCycle" is kind of new to me and it's strange what it is doing and why when I press the dimmer switch. Any Idea and how to get rid of it? :) Also in the xxx folder where the config.json is placed there is now a Philips hue.json that was never there before with a lot in there.

Thanks again for your patience and friendly help.

{
                  "platform": "Hue",
                  "name": "Hue",
                  "host": "xxx.xxx.xxx.xx",
                  "users": {
                  "xxxxx": "xxxxx"
                  },
                  "heartrate": 2,
                  "timeout": 5,
                  "lights": false,
                  "philipslights": false,
                  "groups": false,
                  "group0": false,
                  "rooms": false,
                  "sensors": true,
                  "lowBattery": 25,
                  "excludeSensorTypes": [],
                  "schedules": false,
                  "rules": false
                  }

[2017-6-19 18:08:45] [Hue] Hue dimmer switch 1 On: homekit button single press [2017-6-19 18:08:45] [Hue] Dimmer Switch 35 SceneCycle: set homekit status from 0 to 1 on Mon Jun 19 2017 16:08:43 [2017-6-19 18:08:50] [Hue] Dimmer Switch 35 SceneCycle: set homekit status from 1 to 2 on Mon Jun 19 2017 16:08:47 [2017-6-19 18:08:54] [Hue] Dimmer Switch 35 SceneCycle: set homekit status from 2 to 3 on Mon Jun 19 2017 16:08:53 [2017-6-19 18:08:56] [Hue] Hue dimmer switch 1 On: homekit button long press [2017-6-19 18:09:02] [Hue] Hue dimmer switch 1 On: homekit button long press [2017-6-19 18:09:02] [Hue] Dimmer Switch 35 SceneCycle: set homekit status from 3 to 4 on Mon Jun 19 2017 16:09:00 [2017-6-19 18:09:10] [Hue] Hue dimmer switch 1 Off: homekit button single press [2017-6-19 18:09:10] [Hue] Dimmer Switch 35 SceneCycle: set homekit status from 4 to 0 on Mon Jun 19 2017 16:09:08 [2017-6-19 18:09:15] [Hue] Hue dimmer switch 1 Off: homekit button long press [2017-6-19 18:09:23] [Hue] Hue dimmer switch 1 On: homekit button single press [2017-6-19 18:09:23] [Hue] Dimmer Switch 35 SceneCycle: set homekit status from 0 to 1 on Mon Jun 19 2017 16:09:21 [2017-6-19 18:09:27] [Hue] Hue dimmer switch 1 On: homekit button single press [2017-6-19 18:09:27] [Hue] Dimmer Switch 35 SceneCycle: set homekit status from 1 to 2 on Mon Jun 19 2017 16:09:26 [2017-6-19 18:09:38] [Hue] Dimmer Switch 35 SceneCycle: set homekit status from 2 to 0 on Mon Jun 19 2017 16:09:36

ebaauw commented 7 years ago

And not to depreciate your work and the huge possibilities of your plugin, I only use homebridge-hue just for this switch. :)

That's cool.

And in the Home App the buttons are still not flashing grey and no scene is started.

I'm at a loss. Could you run homebridge -D > output.log 2>&1 and post output.log it here?

The "Dimmer Switch 35 SceneCycle" is kind of new to me and it's strange what it is doing and why when I press the dimmer switch. Any Idea and how to get rid of it? :)

This is a CLIPGenericStatus sensor created by a Hue app to cycle through scenes on pressing the On button of the dimmer switch. It also created Hue bridge rules, to react to a button press, that's how it gets updated. To get rid of it (in HomeKit), specify "excludeSensorTypes": ["CLIPGenericStatus"] or "excludeSensorTypes": ["CLIP"] in config.json.

Also in the xxx folder where the config.json is placed there is now a Philips hue.json that was never there before with a lot in there.

This file has been created by homebridge-hue and contains the (masked) Hue bridge config. If you check the log, you should see a message that it was created on Identify on the bridge accessory, which the iOS Home app issued while cycling through the accessories when you paired homebridge. You can delete this file, or better post it here for troubleshooting the Hue bridge configuration (e.g. checking which user/app created the rules corresponding to the SceneCycle CLIP sensor).

"Philips hue" Bridge with configurable one Button action,

This is for the physical button on the bridge, see https://github.com/ebaauw/homebridge-hue/releases/tag/v0.4.0. To disable it, set "linkbutton": false in config.json. The bridge will then show as an unsupported accessory, as before v0.4.0. Before doing that, you might check whether pressing this button causes the corresponding Home app button to flash.

"HomeAway" always activated, though I'm at home

Probably a CLIPPresence sensor created by a Hue app. To get rid of it (in HomeKit), specify "excludeSensorTypes": ["CLIPPresence"] or "excludeSensorTypes": ["CLIP"] in config.json.

"On/Off" not supported "onOff" not supported "roomSwitch" not supported

Some more CLIPGenericStatus sensors created by a Hue app.

[2017-6-19 18:07:41] [Hue] Initializing platform accessory 'Daylight'...

The Daylight sensor built-in to the Hue bridge. Adding "Daylight" to the excludeSensorTypes array in config.json will get rid of this one.

[2017-6-19 18:07:41] [Hue] Initializing platform accessory 'iPhone 7'...

That's probably a Geofence sensor created by the Hue app for a Home/Away routine.

DJay-X commented 7 years ago

First of all ... you are great! I feel uncomfortable to take so much time of you that you are investing. Thank you very much.

Also thanks for the given information on the "excludeSensorTypes": This was all-in-all helpful to me with the given background. Although of course I read the Wiki, but with the direct connection to the names of my sensors. Now I understand and I exclude this sensors later.

With homebridge -D > output.log 2>&1 I was unfortunately not able to generate a log File. After I run the command nothing happened on the screen and also I can't see a log file. Or where should I find it?

I tried the physical button on the bridge and checked it in Home App. Pressing this button also did not causes the corresponding Home app button to flash. Again in the journal sudo journalctl -f -u homebridge the pressing was documented.

napkin 8 19 06 17 10 49 53 pm

bildschirmfoto 2017-06-19 um 22 55 54

Philips hue.json.txt

ebaauw commented 7 years ago

With homebridge -D > output.log 2>&1 I was unfortunately not able to generate a log File. After I run the command nothing happened on the screen and also I can't see a log file. Or where should I find it?

You won't see anything on the screen, as the output is redirected to the output.log file. It should be created a in the current directory. You can stop homebridge after pressing some buttons on the dimmer switch by issuing ctrl-C on the terminal.

You need to stop / disable the automatic startup of homebridge first, or you'll get an error that the port is already in use. Alternatively, you could add the -D to the automatic startup script and use the regular log file, but I don't know how that's setup on your Raspberry Pi. I really need all messages from homebridge startup up to some button presses.

The bridge config is insightful: the SceneCycle, iPhone7 and HomeAway sensors were indeed created by the Hue app on your iPhone 7; the other sensors by Hue Labs.

DJay-X commented 7 years ago

Found it. ;) There you go. Hope it helps. Thanks in advance.

output.log.txt

ebaauw commented 7 years ago

Thanks. Unfortunately (?) I can't find anything wrong from it. You're running quire a few plugins, but I count 53 accessories overall, so that shouldn't hit any limit. I assume you're exposing the 15 Hue lights through the Hue bridge directly. Do you have any other accessories?

As you're only exposing the dimmer switch I'd like to test whether the issue is specifically with the programmable switches or with all homebridge-hue accessories. Does the Daylight sensor update in HomeKit? Do you have another HomeKit app (like Eve), and if so, could you try and update the heartrate of the Hue bridge accessory? Is the Last Updated characteristic updated on each heartbeat?

Due to some other plugins I had to reset homebridge a several times, did a new config.json back and forth.

Sometimes HomeKit chokes on that, especially in larger configurations with multiple iOS devices linked to the same iCloud account, see #109 (button half). Does your HomeKit config look the same on all devices? Did you check whether the switch blinks on any of the other devices?

DJay-X commented 7 years ago

Hmm... I wished you did have found something wrong in the output. ;) Thanks for looking into it.

It's right, that I have running a few plugins. :) I'm a little bit addicted to homebridge and when I first discovered it and figured out step-by-step how things work. I think it's so great to get non-native HomeKit Devices work with with. And I have to - unfortunately? ;) - all other accessories and sensors work great and as expected. So strange the thing with the not working hue dimmer switch did start. :( It was so helpful to use it in the bedroom to start the good night scene and all other things switched off. Anyway.. I use an iPhone 7, an iPad Pro 9.7", and iPad mini 4, and sometimes an iPod touch 6 Gen. and an Apple TV 4. All with iCloud and HomeKit. On all iDevices in the Home App the accessories and sensors are available and ready. Also the hue dimmer switch. But e.g. on the iPad there is also no grey blink when switching the dimmer. I have no other Hue devices than the dimmer switch. And the lights are connected directly to HomeKit.

I will check on the Daylight value if this changes to 0 later. But I think it does. At the moment it's correct on 100.000 Lux. I already changed the heartrate to 2 yesterday in the config.json, without any noticeable reaction. When I check the Hue dimmer switch 1 "Resource" /SENSOR/35 the "Last Updated" in the Eve App is at the moment "TUE JUN 20 2017 17:05:41". Pressing the dimmer switch doesn't change the "Last Updated". But something is wrong with the time. Here in Frankfurt it's 19:05. I checked the hue App settings for the Hue bridge and the Timezone is correct "Berlin". RasPI also has the correct time.

I unplugged and replugged the hue bridge and checked on the Home App. When I press a button on the dimmer switch the button flashed grey once in the App but then no longer. Repeating a short or long on the button or any other button didn't bring a reaction anymore. Strange!

With the risk of repeating, thanks for your time and support. And sorry for my bad English in probably some sentences. My German is better. ;)

{
                  "platform": "Hue",
                  "name": "Hue",
                  "host": "xxx.xxx.xxx.xx",
                  "users": {
                  "xxx": "xxx"
                  },
                  "heartrate": 2,
                  "timeout": 5,
                  "lights": false,
                  "philipslights": false,
                  "groups": false,
                  "group0": false,
                  "rooms": false,
                  "sensors": true,
                  "lowBattery": 25,
                  "excludeSensorTypes": ["CLIP", "Geofence"],
                  "schedules": false,
                  "rules": false
                  }
ebaauw commented 7 years ago

I suppose your English is still better than my German. And my Dutch is probably better than my English.

I already changed the heartrate to 2 yesterday in the config.json, without any noticeable reaction

Could you change the heartrate from Eve instead? I want to check if HomeKit talks to homebridge-hue at all.

Pressing the dimmer switch doesn't change the "Last Updated".

That could mean the accessory isn't connected (correctly) to HomeKit. When you refresh Eve (pull down the screen), does it reflect the new value?

But something is wrong with the time. Here in Frankfurt it's 19:05. I checked the hue App settings for the Hue bridge and the Timezone is correct "Berlin". RasPI also has the correct time.

Did you set the timezone on the RasPi as well? Under the Localisation tab in the Raspberry Pi Configuration application.

Looking at the log:

[2017-6-20 09:12:47] [Hue] Hue dimmer switch 1: sensor buttonevent 1002 on 2017-06-20T07:12:46
[2017-6-20 09:12:47] [Hue] Hue dimmer switch 1 On: homekit button single press

The Hue bridge reports the UTC time and homebridge logs local time. Seems OK, unless the Pi is running in the wrong timezone (with the system time not in UTC). Otherwise, I think you might have restarted homebridge around 17.05 local time. What's the Last Updated for the Daylight sensor? For the Philips hue bridge?

DJay-X commented 7 years ago

When you refresh Eve (pull down the screen), does it reflect the new value?

Yes. Then "Last Updated" shows the time I last pushed the button on the dimmer switch, when I pull down the screen.

Did you set the timezone on the RasPi as well?

Yes. On the RPi its Europe / Berlin. When I select UTC the time is 2h back. Wintertime. There is no UTC+2 in the Dropdown.

What's the Last Updated for the Daylight sensor? For the Philips hue bridge?

Daylight is updated now to 0.0 Lux at

napkin 8 21 06 17 12 00 04 am

DJay-X commented 7 years ago

You might want to have a look on this. https://youtu.be/kwcrQZtIaro

The Hue bridge shows the heartbeat every 2 sec. about 3 times. Then it stops. When I pull the screen it comes up again 2 sec. 3 times and again stops. hmm...?? 🤔 And don't be irritated by the clock time in the statusbar. With the screen recording program it shows on the recording a different time. With all that time thing I'm close to get a jet lag soon. ;) Thanks again.

ebaauw commented 7 years ago

That's interesting. A HomeKit characteristic might offer permissions for read, write, and events. When you refresh Eve, it reads the Last Updated characteristic and "subscribes" to events, so the value is updated automatically. It would seem this "subscription" somehow gets lost after a short while. The Programmable Switch Event characteristic for the Hue dimmer switch is event-only (HomeKit cannot read this characteristic). HomeKit doesn't seem to receive these events, rendering the switch useless. You might try refreshing the Hue dimmer switch (so the event "subscription" is restored) and pressing a button immediately after, to see if Last Updated is updated.

So there's definitely something wrong between homebridge and HomeKit, causing the event notifications to "get lost". You might try to disable homebridge-hue (make a backup copy of config.json, remove the Hue platform, and restart homebridge). Wait for the accessories for the dimmer switch, Daylight, and bridge to no longer show on all your devices. Then restore config.json and restart homebridge again. If that doesn't help, my suggestion would be to "nuke" your HomeKit configuration, see https://github.com/ebaauw/homebridge-hue/issues/109#issuecomment-309577334.

As I said before, in theory, there might be some interference by another plugin. You could try and disable all other plugins and see if the events stick when homebridge-hue is the only active plugin. That would cause the accessories by the other plugins to be removed from HomeKit, causing almost as much work as resetting the HomeKit configuration.

DJay-X commented 7 years ago

Thanks @ebaauw I'll give this another try later. I think for the moment I took enough of your time. I really appreciate your friendly help. Thanks a lot for your work here and sharing. 👍🏻

DJay-X commented 7 years ago

Just to keep you informed, I did the "nuke" thing. But unfortunately without any success to the Dimmer switch.

All accessories are there and working. homebridge-hue accessories are also there but with the same problem then before. Dimmer switch is not flashing grey when pressing the button on the physical dimmer remote. I does it ons than stopped. I give up for now. I did the nuke procedure 4-5 times in the laste couple of days and as you are mentioned earlier I have a few accessories to set up new to the rooms, scenes, timers and so on. :/

It's strange.. But again, thanks for you work and the ongoing development. I'm pretty confident that I will need the plugin again sooner or later. ;)

DJay-X commented 7 years ago

Meanwhile I was so desperate and factory reset the hardware hue bridge and connected all from scratch. But also without any success, Hue dimmer switch 1 is again shown correct in the Home App and in terminal the homebridge status shows the pressing of the buttons but in the App there is no response (grey flash). 🤔😴

ebaauw commented 7 years ago

As I said ealier, the issue lies in the communication between homebridge and HomeKit on the iOS devices, causing HomeKit to no longer receive the events sent by homebridge-hue. I'm totally in the dark what's causing this, but resetting the Hue bridge won't change anything in that area.

While we're being desperate: What happens if you run homebridge with only the homebridge-hue plugin enabled? Installed?

NorthernMan54 commented 7 years ago

Erik,

I was having a similar issue with motion sensors, and not receiving events. And I found that HomeKit was unregistering that device from events. This was seen in the debug log during the hand shake event just after startup of homebridge, and only occurred when connected remotely via Apple TV. We worked around it by ignoring the unregister for events message. Details and hack are in this thread.

https://github.com/KhaosT/HAP-NodeJS/issues/418

Sent from my iPad

On Jun 25, 2017, at 4:44 AM, Erik Baauw notifications@github.com wrote:

As I said ealier, the issue lies in the communication between homebride(-hue) and HomeKit on the iOS devices, causing HomeKit to no longer receive the events sent by homebridge. I'm totally in the dark what's causing this, but resetting the Hue bridge won't change anything in that area.

While we're being desperate: What happens if you run homebridge with only the homebridge-hue plugin enabled? Installed?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

DJay-X commented 7 years ago

The latest hint I got from a friend is that the problem could be the latest node version. I'm on homebridge@0.4.20 | n@2.1.7 | node@8.1.2 | npm@5.0.3 Should I try do a node fallback or do you see a possibility to work around with your plugin? You are the pro. ;)

ebaauw commented 7 years ago

I was having a similar issue with motion sensors, and not receiving events. And I found that HomeKit was unregistering that device from events. This was seen in the debug log during the hand shake event just after startup of homebridge, and only occurred when connected remotely via Apple TV.

Which debug log would that be, and how can I enable it? "That device" being the AppleTV? Or the remote iOS device? I thought this was specific for Motion Sensor service, maybe related to Apple's policy to disallow bridged security accessories. I've been playing with the idea to try and expose the Hue motion sensor as Presence Sensor service instead of Motion Sensor to see if that would solve it.

ebaauw commented 7 years ago

The latest hint I got from a friend is that the problem could be the latest node version. I'm on homebridge@0.4.20 | n@2.1.7 | node@8.1.2 | npm@5.0.3 Should I try do a node fallback or do you see a possibility to work around with your plugin? You are the pro. ;)

I'm using NodeJS v6.11.0 (latest LTS), and the same version of homebridge and npm. What is n? I noticed (from the log) you're using a later version of NodeJS, but so are others. I don't know if nor how this issue could be related to the version of NodeJS, so I don't know what I would need to create a workaround for.

Having said that, I suppose it wouldn't hurt to downgrade NodeJS and try that, if you're up to reconfiguring HomeKit once again. I would really try and run homebridge-hue as only plugin before installing/enabling other plugins.

DJay-X commented 7 years ago

I have to inform you that the fallback to Node 7.10.0 was the solution! Unbelievable that Node 8.1.2 did cause this problem? Now on node@7.10.0, npm 4.6.1. Now all buttons of the Hue dimmer switch are working as they should and in the Home App the related buttons always give response.

I followed this step-by-step to do the fallback. Maybe at some day it will help another poor fellows. ;)

  1. sudo systemctl stop homebridge

  2. Optional: sudo npm i npm@latest -g (recommended on older npm Versions)

  3. wget https://nodejs.org/dist/v7.10.0/node-v7.10.0-linux-armv7l.tar.gz (customize to preferred Version Number)

  4. tar -xvf node-v7.10.0-linux-armv7l.tar.gz (customize to preferred Version Number)

  5. cd node-v7.10.0-linux-armv7l (customize to preferred Version Number)

  6. sudo cp -R * /usr/local/

  7. cd

  8. sudo npm uninstall -g homebridge

  9. sudo npm install -g --unsafe-perm homebridge@latest

  10. sudo reboot

  11. node -v (Check Version Number)

ebaauw commented 7 years ago

@DJay79 That's good news, indeed!

I have no idea what could have changed in Node v8 to cause this issue. Best I can do for now is issue a warning in homebridge-hue when Node version is 8.x.

ebaauw commented 7 years ago

v0.5.3 issues a warning for node v8.x.

Best keep this issue open, until we've identified the cause.

deanlyoung commented 7 years ago

Ahh, good to know! I was considering updating to node-v8+, so now I think I'll hold off.

deanlyoung commented 7 years ago

I wanted to update to a more recent version of node (I'm currently on v5.6.0 -- some plugins require v7+ or v8+), and I tried your steps @DJay79 to load v7.1.0 (except uninstalling homebridge and reinstalling), but that caused Homebridge to fail to start. So I'm not sure if that means v7.1.0 isn't actually okay, or if when updating node I'd need to include the homebridge uninstall/re-install steps to get it to work. I'm not really sure what that would do in terms of wiping out any settings on my Homebridge setup.

homebridge.service - Node.js HomeKit Server
  Loaded: loaded (/etc/systemd/system/homebridge.service; enabled)
    Active: activating (auto-restart) (Result: exit-code) since Tue 2017-06-27 13:55:41 PDT; 3s ago
    Process: 2091 ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS (code=exited, status=1/FAILURE)
  Main PID: 2091 (code=exited, status=1/FAILURE)
Jun 27 13:55:41 raspberrypi homebridge[2091]: at Function.Module._load (module.js:439:3)
Jun 27 13:55:41 raspberrypi homebridge[2091]: at Module.require (module.js:498:17)
Jun 27 13:55:41 raspberrypi homebridge[2091]: at require (internal/module.js:20:19)
Jun 27 13:55:41 raspberrypi homebridge[2091]: at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/mdns/lib/dns_sd.js:24:20)
Jun 27 13:55:41 raspberrypi homebridge[2091]: at Module._compile (module.js:571:32)
Jun 27 13:55:41 raspberrypi homebridge[2091]: at Object.Module._extensions..js (module.js:580:10)
Jun 27 13:55:41 raspberrypi homebridge[2091]: at Module.load (module.js:488:32)
Jun 27 13:55:41 raspberrypi systemd[1]: homebridge.service: main process exited, code=exited, status=1/FAILURE
Jun 27 13:55:41 raspberrypi systemd[1]: Unit homebridge.service entered failed state.
ebaauw commented 7 years ago

Looks like it fails to load the Avahi library. Best try re-installing Avahi, see https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi#install-avahi-and-other-dependencies.

BTW I installed node on my Raspberry using apt-get, see https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi#nodejs-package-manager-install-easiest-preferred. This installs node to /usr/bin instead of /usr/local/bin and node_modules to /usr/lib.

DJay-X commented 7 years ago

@deanlyoung I was reading about that the uninstall and new install of homebridge after the node procedure is necessary. So I did this without running into any issue.

ebaauw commented 7 years ago

I did some testing with node v8.1.3 and v8.1.2 on macOS 10.12.5. Indeed, the Programmable Switch Input Event doesn't seem to be received by HomeKit. After re-installing node v6.11.0 (and npm and homebridge) they work again.

ebaauw commented 7 years ago

It's a generic issue (not specifically related to the Stateful Programmable Switch's Input Event characteristic) with node v8.x, that causes HomeKit to lose the connection to homebridge, no longer receiving events, see nfarina/homebridge#1353.

@NorthernMan54 I think it's a different issue from the Motion Detected on the AppleTV. There, the AppleTV unregisters events from that characteristic, here, the connection between HomeKit and homebridge is lost altogether. The hack won't work in this case, as there's no unregister event message to ignore.

ebaauw commented 7 years ago

@deanlyoung @DJay79 @NorthernMan54 They traced the issue to a change in the http module of node v8.x, that now, by default, closes an http server connection after 5 seconds. homebridge uses an http server to communicate with HomeKit.

homebridge v0.4.22 deals with this, overriding the new default. homebridge-hue v0.5.7 requires this homebridge version and no longer warns about node v8.x.

Nastras commented 7 years ago

Hello ebaauw,

thanks for the great work!

I have installed your update 0.5.7 as well as homebridge 0.4.22 and node 8.1.3 unfortunately, the hue switches still do not work.

I have tried to put a device as well as a scenes on different buttons. After the activation of the buttons unfortunately nothing happens

In the home app and in the log of the homebridge, I am informed that the switch has been pressed but there is no action to be executed?

Was not this issue fixed with the update from homebridge and hue? Do you have an idea why it does not work?

ebaauw commented 7 years ago

This issue was about the Stateless Programmable Switch's Input Events not reaching HomeKit - if Home reacts to pressing the switch (by blinking the tile) it is solved. I'm afried you're hitting one of the other issues, see https://github.com/ebaauw/homebridge-hue/issues/118#issuecomment-311798530.

Nastras commented 7 years ago

Good morning,

Many thanks for this reference! I have my Apple TV from the iCloud logged off and logged back now the switches worke again.

Thanks again for the good work you do here!