diyhue / diyHue

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

milight bulbs show Off status on Hue app, after some seconds when set color #115

Closed huongminh closed 5 years ago

huongminh commented 5 years ago

Describe the bug I have 38 milight bulbs (RGB-CCT) set up in 7 rooms (from 2 to 7 bulbs per room). They all ran stably with the Hue Emulator and Milight hub for months. Recently I found some bulbs (usually 4 to 10 bulbs) show unreachable status. A restart of hue-emulator might fix the unreachable status. The bulbs still receive command well from the Hue app even though the status is unreachable, except that after I turn the unreachable bulbs on for a few seconds the switch will come back to Off position (but the bulbs are still glow and that make the bulb status in the app wrong). Now I came across another issue, not sure related to the one described above. All bulbs (unreachable or reachable) would glow if the command set is white (CCT) (and then some unreachable bulbs would show status OFF as described above). But when sending a color command (RGB) ALL bulb would glow but after 5-10 seconds they all show status as OFF in the app (bulbs actually are still glowing correctly in brightness and color).

Logs This log show when start up the hue-emulator but not controlling any bulb from the hue app yet. The similar would show when set color to bulbs.

pi@raspberrypi:/opt/hue-emulator $ sudo ./HueEmulator3.py --debug True
Debug Enabled
Using Host IP of 192.168.1.149
2019-04-16 17:24:40,499 - root - INFO - b827ebdcfe88
2019-04-16 17:24:40,501 - root - INFO - IP range for light discovery: 0-255
2019-04-16 17:24:40,525 - root - INFO - Config loaded
2019-04-16 17:24:40,532 - root - INFO - sync with lights
2019-04-16 17:24:40,537 - root - INFO - Starting httpd...
2019-04-16 17:24:40,546 - root - INFO - Starting ssl httpd...
Exception in thread Thread-9:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "./HueEmulator3.py", line 935, in daylightSensor
    if bridge_config["sensors"]["1"]["modelid"] != "PHDL00" or not bridge_config["sensors"]["1"]["config"]["configured"]:
KeyError: '1'

192.168.1.162 - - [16/Apr/2019 17:24:40] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
2019-04-16 17:24:40,721 - root - ERROR - light 57 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:24:40,845 - root - ERROR - light 37 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
10.8.0.2 - - [16/Apr/2019 17:24:40] "GET /api/a7161538be80d40b3de98dece6e91f90/config HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:41] "GET /api/a7161538be80d40b3de98dece6e91f90/config HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:24:42] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:42] "GET /api/a7161538be80d40b3de98dece6e91f90/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:42] "GET /api/a7161538be80d40b3de98dece6e91f90/groups HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:24:44] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:44] "GET /api/a7161538be80d40b3de98dece6e91f90/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:44] "GET /api/a7161538be80d40b3de98dece6e91f90/groups HTTP/1.1" 200 -
192.168.1.145 - - [16/Apr/2019 17:24:45] "GET /api/84312883a7fcbf9d9e6d180df58ba912 HTTP/1.1" 200 -
192.168.1.145 - - [16/Apr/2019 17:24:45] "GET /api/84312883a7fcbf9d9e6d180df58ba912/groups/0 HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:24:46] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
2019-04-16 17:24:47,072 - root - ERROR - light 62 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 192, in syncWithLights
    light_state = protocol.get_light_state(addresses[light], lights[light])
  File "/opt/hue-emulator/protocols/yeelight.py", line 125, in get_light_state
    data = tcp_socket.recv(16 * 1024)
socket.timeout: timed out
10.8.0.2 - - [16/Apr/2019 17:24:47] "GET /api/a7161538be80d40b3de98dece6e91f90/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:47] "GET /api/a7161538be80d40b3de98dece6e91f90/groups HTTP/1.1" 200 -
2019-04-16 17:24:47,200 - root - ERROR - light 58 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:24:47,268 - root - ERROR - light 59 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:24:47,303 - root - ERROR - light 40 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:24:47,340 - root - ERROR - light 48 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:24:47,516 - root - ERROR - light 38 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:24:47,772 - root - ERROR - light 39 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
192.168.1.162 - - [16/Apr/2019 17:24:48] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:49] "GET /api/a7161538be80d40b3de98dece6e91f90/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:49] "GET /api/a7161538be80d40b3de98dece6e91f90/groups HTTP/1.1" 200 -
192.168.1.149 - - [16/Apr/2019 17:24:50] "GET /api/84312883a7fcbf9d9e6d180df58ba912 HTTP/1.1" 200 -
192.168.1.149 - - [16/Apr/2019 17:24:50] "GET /api/84312883a7fcbf9d9e6d180df58ba912/groups/0 HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:24:50] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:51] "GET /api/a7161538be80d40b3de98dece6e91f90/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:51] "GET /api/a7161538be80d40b3de98dece6e91f90/groups HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:51] "GET /api/a7161538be80d40b3de98dece6e91f90/config HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:24:52] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:53] "GET /api/a7161538be80d40b3de98dece6e91f90/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:53] "GET /api/a7161538be80d40b3de98dece6e91f90/groups HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:24:54] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:55] "GET /api/a7161538be80d40b3de98dece6e91f90/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:55] "GET /api/a7161538be80d40b3de98dece6e91f90/groups HTTP/1.1" 200 -
192.168.1.145 - - [16/Apr/2019 17:24:56] "GET /api/84312883a7fcbf9d9e6d180df58ba912 HTTP/1.1" 200 -
192.168.1.145 - - [16/Apr/2019 17:24:56] "GET /api/84312883a7fcbf9d9e6d180df58ba912/groups/0 HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:24:56] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
192.168.1.149 - - [16/Apr/2019 17:24:56] "PUT /api/84312883a7fcbf9d9e6d180df58ba912/groups/7/action HTTP/1.1" 200 -
2019-04-16 17:24:56,780 - root - INFO - in PUT method
2019-04-16 17:24:56,782 - root - INFO - /api/84312883a7fcbf9d9e6d180df58ba912/groups/7/action
2019-04-16 17:24:56,783 - root - INFO - b'{"on": true }'
2019-04-16 17:24:56,785 - root - INFO - {"status": true}
2019-04-16 17:24:56,800 - root - INFO - [
    {
        "success": {
            "/groups/7/action/on": true
        }
    }
]
2019-04-16 17:24:57,063 - root - INFO - LightRequest: http://192.168.1.124/gateways/0x10C9/rgb_cct/1
2019-04-16 17:24:57,114 - root - INFO - {"status": true}
2019-04-16 17:24:57,295 - root - INFO - LightRequest: http://192.168.1.124/gateways/0x10C9/rgb_cct/2
10.8.0.2 - - [16/Apr/2019 17:24:57] "GET /api/a7161538be80d40b3de98dece6e91f90/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:24:58] "GET /api/a7161538be80d40b3de98dece6e91f90/groups HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:24:58] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
2019-04-16 17:24:59,788 - root - INFO - sync with lights
2019-04-16 17:24:59,881 - root - ERROR - light 57 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:24:59,985 - root - ERROR - light 37 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
192.168.1.149 - - [16/Apr/2019 17:25:00] "GET /api/84312883a7fcbf9d9e6d180df58ba912 HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:25:00] "GET /api/a7161538be80d40b3de98dece6e91f90/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:25:00] "GET /api/a7161538be80d40b3de98dece6e91f90/groups HTTP/1.1" 200 -
192.168.1.149 - - [16/Apr/2019 17:25:00] "GET /api/84312883a7fcbf9d9e6d180df58ba912/groups/0 HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:25:00] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
2019-04-16 17:25:01,465 - root - ERROR - light 58 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:25:01,521 - root - ERROR - light 59 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:25:01,560 - root - ERROR - light 40 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:25:01,596 - root - ERROR - light 48 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:25:01,720 - root - ERROR - light 38 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'

Log 2 (when firing a color scene of spring blossom to the bulb group). When the status start to show OFF again then the error found in the log (actual bulbs are still glowing).

10.8.0.2 - - [16/Apr/2019 17:57:37] "GET /api/a7161538be80d40b3de98dece6e91f90 HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:57:38] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:57:39] "GET /api/a7161538be80d40b3de98dece6e91f90 HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:57:40] "GET /api/a7161538be80d40b3de98dece6e91f90/config HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:57:40] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
10.8.0.2 - - [16/Apr/2019 17:57:42] "GET /api/a7161538be80d40b3de98dece6e91f90 HTTP/1.1" 200 -
192.168.1.162 - - [16/Apr/2019 17:57:42] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
2019-04-16 17:57:43,978 - root - ERROR - light 62 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 192, in syncWithLights
    light_state = protocol.get_light_state(addresses[light], lights[light])
  File "/opt/hue-emulator/protocols/yeelight.py", line 125, in get_light_state
    data = tcp_socket.recv(16 * 1024)
socket.timeout: timed out
10.8.0.2 - - [16/Apr/2019 17:57:44] "GET /api/a7161538be80d40b3de98dece6e91f90 HTTP/1.1" 200 -
2019-04-16 17:57:44,231 - root - ERROR - light 58 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:57:44,297 - root - ERROR - light 59 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:57:44,332 - root - ERROR - light 40 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:57:44,372 - root - ERROR - light 48 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:57:44,529 - root - ERROR - light 38 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
192.168.1.162 - - [16/Apr/2019 17:57:44] "GET /api/ba5ed015715da74cf1e87230ba73d485/lights HTTP/1.1" 200 -
2019-04-16 17:57:44,568 - root - ERROR - light 7 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:57:44,673 - root - ERROR - light 6 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
2019-04-16 17:57:44,812 - root - ERROR - light 39 is unreachable
Traceback (most recent call last):
  File "/opt/hue-emulator/functions/lightRequest.py", line 226, in syncWithLights
    lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'
huongminh commented 5 years ago

I am using milight hub version 1.8.5 and the latest hue emulator version. when I tried to make a clean installation of hue emulator on my second Pi hardware and added milight bulbs. Now, when setting color, now bulb would glow. While on the current production version, bulbs are glowing as described above. I have 20 real philip hue bulbs connected via the hue emulator as they all work normally. So it seems the issues are with milight bulbs only.

mariusmotea commented 5 years ago

Hi,

One year ago i was forced to create a change with no automatic config fix. Hue introduces a logical sensor (sensor ID 1 for daylight). It seams your config is very old and don't have this.

For next error:

lights[light]["state"]["hue"] = light_data["hue"] * 180
KeyError: 'hue'

hue key seams to miss from the light. I believe i need to change this to get the rgb data and convert it to xy or hue/sat.

huongminh commented 5 years ago

Thank you for quick response! Can you tell me how to update my config? I keep rerun the automatic installation script but as you said it would not update the config

Sent from Yahoo Mail for iPhone

On Tuesday, April 16, 2019, 6:13 PM, Motea Marius notifications@github.com wrote:

Hi,

One year ago i was forced to create a change with no automatic config fix. Hue introduces a logical sensor (sensor ID 1 for daylight). It seams your config is very old and don't have this.

For next error: lights[light]["state"]["hue"] = light_data["hue"] * 180 KeyError: 'hue'



—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
mariusmotea commented 5 years ago

do you have something under "sensors" in config.json file?

huongminh commented 5 years ago

This is part of my config.json (I had to cut some part since too long to post)

huongminh commented 5 years ago

this is the sensor part I find: "sensors": { "available": 63, "clip": { "available": 63 }, "zgp": { "available": 63 }, "zll": { "available": 63 }

mariusmotea commented 5 years ago

Not in capabilities, check and the end of the file.

huongminh commented 5 years ago

At the end of the file there is a “sensor” as well as seen in the file I sent. There is no value next to it. 

Sent from Yahoo Mail for iPhone

On Tuesday, April 16, 2019, 8:29 PM, Motea Marius notifications@github.com wrote:

Not in capabilities, check and the end of the file.

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

mariusmotea commented 5 years ago

add this sensor "1" in sensors:

"sensors":{
      "1":{
         "state":{
            "daylight":null,
            "lastupdated":"none"
         },
         "config":{
            "on":true,
            "configured":false,
            "sunriseoffset":30,
            "sunsetoffset":-30
         },
         "name":"Daylight",
         "type":"Daylight",
         "modelid":"PHDL00",
         "manufacturername":"Philips",
         "swversion":"1.0"
      }
   }
huongminh commented 5 years ago

Thank you! It is supposed to fix the unreachable bulbs, am i correct?

Sent from Yahoo Mail for iPhone

On Tuesday, April 16, 2019, 9:40 PM, Motea Marius notifications@github.com wrote:

add this sensor "1" in sensors: "sensors":{ "1":{ "state":{ "daylight":null, "lastupdated":"none" }, "config":{ "on":true, "configured":false, "sunriseoffset":30, "sunsetoffset":-30 }, "name":"Daylight", "type":"Daylight", "modelid":"PHDL00", "manufacturername":"Philips", "swversion":"1.0" } }

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

mariusmotea commented 5 years ago

I will propose another fix for that...when inwill reach to hotel.

huongminh commented 5 years ago

I reviewed the log file and now realized that there are 3 error in the logs:

  1. Error with the daylight sensor (which you suggested a fix).
  2. Error with the unreachable milight bulbs: key error = hue (this could also be the cause hue emulator could not keep color status of the bulbs in my setup / or in a fresh clean setup, could not fire a color setting command to bulbs).
  3. Error with the yeelight: File "/opt/hue-emulator/protocols/yeelight.py", line 125, in get_light_state data = tcp_socket.recv(16 * 1024) socket.timeout: timed out I actually have 2 yeelight bulbs in my setup (1 Xiaomi Desk Lamp (CCT) and 1 Mijia bedside lamp (RGB). Of which, 1 is unreachable that shows the log above. I notice in my setup yeelight bulbs are not very responsive with the Hue App since they are supported by the Hue emulator.
mariusmotea commented 5 years ago

timeout means the hue emulator was unable to communicate with the yeelight bulb, ensure better wifi coverage in your home.

For Milight error remove or comment the following code in /opt/hue-emulator/functions/lightRequest.py:

elif "bulb_mode" in light_data and light_data["bulb_mode"] == "color":
                        lights[light]["state"]["colormode"] = "hs"
                        lights[light]["state"]["hue"] = light_data["hue"] * 180
                        if (not "saturation" in light_data) and addresses[light]["mode"] == "rgbw":
                            lights[light]["state"]["sat"] = 255
                        else:
                            lights[light]["state"]["sat"] = int(light_data["saturation"] * 2.54)

Restart hue emulator for the changes to be applied.

huongminh commented 5 years ago

I updated the config.json with sensors 1 as per your instruction. However, when I restart hue-emulator service. I still got the same error. I checked the config.json and found the code lines added now disappear as if I never added it before. So somehow the config.json gets updated every time hue-emulator starts? What should I do now?  On Tuesday, April 16, 2019, 9:40:58 PM GMT+7, Motea Marius notifications@github.com wrote:

add this sensor "1" in sensors: "sensors":{ "1":{ "state":{ "daylight":null, "lastupdated":"none" }, "config":{ "on":true, "configured":false, "sunriseoffset":30, "sunsetoffset":-30 }, "name":"Daylight", "type":"Daylight", "modelid":"PHDL00", "manufacturername":"Philips", "swversion":"1.0" } }

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

huongminh commented 5 years ago

I followed your instruction and the hue key error does not occur any more. all hue light bulbs are now reachable and color state is reflected correctly. Many thanks for your fix. On Wednesday, April 17, 2019, 2:20:44 AM GMT+7, Motea Marius notifications@github.com wrote:

timeout means the hue emulator was unable to communicate with the yeelight bulb, ensure better wifi coverage in your home.

For Milight error remove or comment the following code in /opt/hue-emulator/functions/lightRequest.py: elif "bulb_mode" in light_data and light_data["bulb_mode"] == "color": lights[light]["state"]["colormode"] = "hs" lights[light]["state"]["hue"] = light_data["hue"] 180 if (not "saturation" in light_data) and addresses[light]["mode"] == "rgbw": lights[light]["state"]["sat"] = 255 else: lights[light]["state"]["sat"] = int(light_data["saturation"] 2.54)

Restart hue emulator for the changes to be applied.

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

huongminh commented 5 years ago

For the time out issue with Yeelight Error with the yeelight: File "/opt/hue-emulator/protocols/yeelight.py", line 125, in get_light_state data = tcp_socket.recv(16 * 1024) socket.timeout: timed out I am pretty sure the lamp is within very good wifi coverage. I am controlling it very well with alternative connections, both officially released by Xiaomi like Alexa and Google Home (via Yeelight skills) and via homebridge yeelight plug in. The lamp is only unreachable in Hue app connected to Hue-emulator. I notice when I control it via alternative method, like Homebridge Home App and watch its status in Hue app. I can see the lamp shortly gets reachable (the unreachable word disappears), then becomes unreachable again. This lamp is xiaomi desk lamp. The other lamp (xiaomi bedside lamp) is always reachable.

mariusmotea commented 5 years ago

Important is to have good connectivity from hue emulator host, not from other devices from your home. Is the ping stable to the yeelight bulbs from hue emulator host?

huongminh commented 5 years ago

I set static IP for both hue-emulator and the yeeight bulb. 

Sent from Yahoo Mail for iPhone

On Friday, April 19, 2019, 4:39 AM, Motea Marius notifications@github.com wrote:

Important is to have good connectivity from hue emulator host, not from other devices from your home. Is the ip stable to the yeelight bulbs from hue emulator host?

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

huongminh commented 5 years ago

I added the sensor "1" in the config.json as per your instruction but still got this error after restart the hue-emulator service: it is found that the lines sdded are wiped out from config.json when restarting hue emulator. 

Exception in thread Thread-9:

Apr 18 23:08:55 raspberrypi HueEmulator3.py[29358]: Traceback (most recent call last):

Apr 18 23:08:55 raspberrypi HueEmulator3.py[29358]:   File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner

Apr 18 23:08:55 raspberrypi HueEmulator3.py[29358]:     self.run()

Apr 18 23:08:55 raspberrypi HueEmulator3.py[29358]:   File "/usr/lib/python3.5/threading.py", line 862, in run

Apr 18 23:08:55 raspberrypi HueEmulator3.py[29358]:     self._target(*self._args, **self._kwargs)

Apr 18 23:08:55 raspberrypi HueEmulator3.py[29358]:   File "/opt/hue-emulator/HueEmulator3.py", line 935, in daylightSensor

Apr 18 23:08:55 raspberrypi HueEmulator3.py[29358]:     if bridge_config["sensors"]["1"]["modelid"] != "PHDL00" or not bridge_config["sensors"]["1"]["config"]["configured"]:

Apr 18 23:08:55 raspberrypi HueEmulator3.py[29358]: KeyError: '1'

On Tuesday, April 16, 2019, 9:40:58 PM GMT+7, Motea Marius <notifications@github.com> wrote:  

add this sensor "1" in sensors: "sensors":{ "1":{ "state":{ "daylight":null, "lastupdated":"none" }, "config":{ "on":true, "configured":false, "sunriseoffset":30, "sunsetoffset":-30 }, "name":"Daylight", "type":"Daylight", "modelid":"PHDL00", "manufacturername":"Philips", "swversion":"1.0" } }

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

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 2 days if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue has been automatically closed as it has not had any recent activity. Thank you for your contributions.