mariusmotea / diyHue

Philips Hue emulator that is able to control multiple types of lights
Other
627 stars 107 forks source link

Lights disappear after pi restarts #131

Closed mcer12 closed 6 years ago

mcer12 commented 6 years ago

Hi @mariusmotea Today I've updated the hue emulator to latest commit (my old version was before the fw version update) and since then I cant make my lights save properly. I set my rooms and lights but after I restart the Pi, all lights disappear and I have to search them again. Rooms disappear also, but interestingly first room is still available in the hue app. Spend few hours on it already and cant figure it out. I even tried to roll back before the update but Philips disabled older fw version already. I would very much appreciate any help.

I should add, that everything seems OK until I restart the bridge.

mariusmotea commented 6 years ago

Can you explain your setup? If you used an old version, then you need to upgrade also lights firmware and everything must work fine. config.json file is saved automatically every hour, if you configure the rooms, the lights and reboot right away is possible to lose some configuration. I suggest to start HueEmulator.py script manually because when you press CTRL+C it will save the config on exit and then you can reboot.

mcer12 commented 6 years ago

OK so I replaced firmware in all my lights, replaced the bridge firmware again completely with default config. Start the emulator (shut down service and run manually HueEmulator.py), everything runs OK, save lights and rooms. Now when I restart the bridge, the service won't start. When I run the HueEmulator manually it just prints this: Config loaded server stopped 'bri' Config saved

Maybe be the config gets corrupted somehow?

mariusmotea commented 6 years ago

Yes, for sure there is a problem with the config. I introduce automatic backup in recent versions, if you don't have any bakup i believe you need to start with new config.

mcer12 commented 6 years ago

As I said I used the default config from the repository.

I tried one more thing.

  1. Run the HueEmulator manually,
  2. Save all my rooms and lights in the app
  3. Exit HueEmulator with ctrl+c (saving the config)
  4. Start HueEmulator manually again but it now returns server stopped 'bri'

I briefly catched some encoding exceptions in console while saving the lights. Could it be caused by special characters in the names of scenes etc. In older version these were just replaced with "?" character but now it breaks the config? Below is the config (corrupted) after save.

mcer12 commented 6 years ago

{ "alarm_config": { "mail_from": "your_email@gmail.com", "mail_password": "", "mail_recipients": [ "first_recipient@mail.com", "second_recipient@mail.com" ], "mail_subject": "HUE ALARM TRIGGERED!", "mail_username": "", "smtp_port": 465, "smtp_server": "smtp.gmail.com" }, "capabilities": { "groups": { "available": 64 }, "lights": { "available": 63 }, "resourcelinks": { "available": 64 }, "rules": { "actions": { "available": 400 }, "available": 200, "conditions": { "available": 400 } }, "scenes": { "available": 200, "lightstates": { "available": 2048 } }, "schedules": { "available": 100 }, "sensors": { "available": 63, "clip": { "available": 63 }, "zgp": { "available": 63 }, "zll": { "available": 63 } } }, "config": { "UTC": "2017-12-30T17:48:24", "apiversion": "1.19.0", "bridgeid": "BE989FFFFE067C1D", "datastoreversion": 59, "dhcp": true, "factorynew": false, "gateway": "192.168.0.100", "ipaddress": "192.168.0.100", "linkbutton": true, "localtime": "2017-12-30T17:48:24", "mac": "be:98:9f:06:7c:1d", "modelid": "BSB002", "name": "Philips hue", "netmask": "255.255.255.0", "portalservices": false, "proxyaddress": "none", "proxyport": 0, "swversion": "1711151408", "timezone": "Europe/Bucharest", "whitelist": { "a7161538be80d40b3de98dece6e91f904dc96170": { "create date": "2017-12-30T17:47:49", "last use date": "2017-12-30T17:48:24", "name": "Hue 2#Samsung SM-G920F" } }, "zigbeechannel": 15 }, "deconz": { "enabled": false, "lights": {}, "port": 8080, "sensors": {} }, "groups": { "1": { "action": { "on": false }, "class": "Living room", "lights": [ "3", "1" ], "name": "test room", "state": { "all_on": false, "any_on": false }, "type": "Room" } }, "lights": { "1": { "modelid": "LST001", "name": "Hue strip LST001 1", "state": { "alert": "none", "bri": 144, "colormode": "ct", "ct": 447, "effect": "none", "hue": 0, "on": false, "reachable": true, "sat": 0, "xy": [ 0.0, 0.0 ] }, "swversion": "66010400", "type": "Color light", "uniqueid": "2f:bc:e:e8:3a:2c-1" }, "2": { "modelid": "LST001", "name": "Hue strip LST001 2", "state": { "alert": "none", "bri": 144, "colormode": "ct", "ct": 447, "effect": "none", "hue": 0, "on": false, "reachable": true, "sat": 0, "xy": [ 0.0, 0.0 ] }, "swversion": "66010400", "type": "Color light", "uniqueid": "2f:bc:e:e8:3a:2c-2" }, "3": { "modelid": "Plug 01", "name": "Hue bulb Plug 01 1", "state": { "alert": "none", "on": false, "reachable": true }, "swversion": "V1.04.12", "type": "On/Off plug-in unit", "uniqueid": "cc:c6:66:7f:cf:5c-1" } }, "lights_address": { "1": { "ip": "192.168.0.42", "light_nr": 1, "protocol": "native" }, "2": { "ip": "192.168.0.42", "light_nr": 2, "protocol": "native" }, "3": { "ip": "192.168.0.18", "light_nr": 1, "protocol": "native" } }, "resourcelinks": {}, "rules": {}, "scenes": { "1": { "appdata": { "data": "NLalD_r01_d15", "version": 1 }, "lastupdated": "2017-12-30T17:48:26", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "Z\u00e1pad slunce na savan\u011b", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 }, "10": { "appdata": { "data": "VjRIj_r01_d04", "version": 1 }, "lastupdated": "2017-12-30T17:48:26", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "Povzbuzuj\u00edc\u00ed", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 }, "11": { "appdata": { "data": "U6y7Z_r01_d06", "version": 1 }, "lastupdated": "2017-12-30T17:48:27", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "Ztlumen\u00e9", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 }, "2": { "appdata": { "data": "Tfval_r01_d16", "version": 1 }, "lastupdated": "2017-12-30T17:48:26", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "Tropick\u00fd soumrak", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 }, "3": { "appdata": { "data": "FhaFh_r01_d17", "version": 1 }, "lastupdated": "2017-12-30T17:48:26", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "Pol\u00e1rn\u00ed z\u00e1\u0159e", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 }, "4": { "appdata": { "data": "bvAbk_r01_d18", "version": 1 }, "lastupdated": "2017-12-30T17:48:26", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "Jarn\u00ed kv\u011bt", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 }, "5": { "appdata": { "data": "NQ7ra_r01_d01", "version": 1 }, "lastupdated": "2017-12-30T17:48:26", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "Relaxa\u010dn\u00ed", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 }, "6": { "appdata": { "data": "KDaDA_r01_d03", "version": 1 }, "lastupdated": "2017-12-30T17:48:26", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "Soust\u0159ed\u011bn\u00ed", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 }, "7": { "appdata": { "data": "CJLMW_r01_d02", "version": 1 }, "lastupdated": "2017-12-30T17:48:26", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "\u010cten\u00ed", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 }, "8": { "appdata": { "data": "RSzpA_r01_d05", "version": 1 }, "lastupdated": "2017-12-30T17:48:26", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "Sv\u011btl\u00e9", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 }, "9": { "appdata": { "data": "TaXep_r01_d07", "version": 1 }, "lastupdated": "2017-12-30T17:48:26", "lights": [ "3", "1" ], "lightstates": {}, "locked": false, "name": "No\u010dn\u00ed sv\u011btlo", "owner": "a7161538be80d40b3de98dece6e91f904dc96170", "picture": "", "recycle": false, "version": 2 } }, "schedules": {}, "sensors": {} }

mariusmotea commented 6 years ago

I will debug in 10 minutes

mariusmotea commented 6 years ago

please replace update_lights_on_startup = True with update_lights_on_startup = False and test. I believe the error is in code.

mcer12 commented 6 years ago

No change, the config still gets corrupted

EDIT>> It works after restart!

mariusmotea commented 6 years ago

is working no mater update_lights_on_startup is set to True or False?

mcer12 commented 6 years ago

Its working when set False

mariusmotea commented 6 years ago

ok, it means there is a bug in that function when there are on/off devices with no bri attribute. I will fix this today.

mcer12 commented 6 years ago

You should reconsider accepting donations for this kind of support. Just saying.

mariusmotea commented 6 years ago

i believe there will be a moment when i will add a paypal button, currently i put lot effort to have this software running very stable because all the lights in my home are managed by it and there is no turn back option, i remove all classic light switches, cover the holes, etc. People like you help me to find bugs and provide me relevant feedback.