python-miio icon indicating copy to clipboard operation
python-miio copied to clipboard

Philips Eyecare - physical buttons stops working after few days

Open pniewiadowski opened this issue 4 years ago • 69 comments

Hi There,

don't know really where to put this issue, here or in Home Assistant, but let me try to explain and the you can redirect me to appropriate project.

Once the light is hooked up to Home Assistant via the miio integration, after few days, the physical buttons stops working on the device.

So we have two scenarios:

  1. Philips eyecare synced with Mi Home app, works without problem. Both, physical buttons and app control works without problem,
  2. Philips eyecare integrated into Home Assistant, works for 4, 5 days (physcial buttons, Mi Home app control, and via Home Assistant). After 4, 5 days, buttons doesn't react on touch, app control and HA integration works though.

Once I pull out the plug and plugin back again, the device reconnect to network, and buttons work again for few days.

I have run some debug commands and I am not able to spot anything interesting here, but maybe you are. This is what I can see just after reset: PS C:\WINDOWS\system32> mieye --ip=192.168.0.113 --token=xxxxxxxxxx-d INFO:miio.philips_eyecare_cli:Debug mode active DEBUG:miio.philips_eyecare_cli:Connecting to 192.168.0.113 with token xxxxxxxxxx DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b'' DEBUG:miio.device:Got a response: Container: data = Container: data = b'' (total 0) value = b'' (total 0) offset1 = 32 offset2 = 32 length = 0 header = Container: data = b'!1\x00 \x00\x00\x00\x00\x03.\xa0"\x00\x00\x02\xd2' (total 16) value = Container: length = 32 unknown = 0 device_id = unhexlify('032ea022') ts = 1970-01-01 00:12:02 offset1 = 0 offset2 = 16 length = 16 checksum = b'\x8f\x00\xcb\x89]\xe5j\x00\x0e\x8e\xc3\xca\x85\xec\x03\xe2' (total 16) DEBUG:miio.device:Discovered 032ea022 with ts: 1970-01-01 00:12:02, token: b'xxxxxxxxxx' DEBUG:miio.device:192.168.0.113:54321 >>: {'id': 2, 'method': 'get_prop', 'params': ['power', 'bright', 'notifystatus', 'ambstatus', 'ambvalue', 'eyecare', 'scene_num', 'bls', 'dvalue']} DEBUG:miio.device:192.168.0.113:54321 (ts: 1970-01-01 00:12:02, id: 2) << {'result': ['on', 47, 'off', 'on', 1, 'on', 1, 'on', 0], 'id': 2} Power: on Brightness: 47 Eye Fatigue Reminder: False Ambient Light: True Ambient Light Brightness: 1 Eyecare Mode: True Eyecare Scene: 1 Night Light: True Countdown of the delayed turn off: 0 minutes

This is once the button stooped reacting: PS C:\Users\Przemek> mieye --ip=192.168.0.113 --token=xxxxxxxxx -d INFO:miio.philips_eyecare_cli:Debug mode active DEBUG:miio.philips_eyecare_cli:Connecting to 192.168.0.113 with token xxxxxxxxx DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b'' DEBUG:miio.device:Got a response: Container: data = Container: data = b'' (total 0) value = b'' (total 0) offset1 = 32 offset2 = 32 length = 0 header = Container: data = b'!1\x00 \x00\x00\x00\x00\x03.\xa0"\x00\x04\x8e\xaa' (total 16) value = Container: length = 32 unknown = 0 device_id = unhexlify('032ea022') ts = 1970-01-04 10:57:46 offset1 = 0 offset2 = 16 length = 16 checksum = b'\x8f\x00\xcb\x89]\xe5j\x00\x0e\x8e\xc3\xca\x85\xec\x03\xe2' (total 16) DEBUG:miio.device:Discovered 032ea022 with ts: 1970-01-04 10:57:46, token: b'xxxxxxxxx' DEBUG:miio.device:192.168.0.113:54321 >>: {'id': 2, 'method': 'get_prop', 'params': ['power', 'bright', 'notifystatus', 'ambstatus', 'ambvalue', 'eyecare', 'scene_num', 'bls', 'dvalue']} DEBUG:miio.device:192.168.0.113:54321 (ts: 1970-01-04 10:57:47, id: 2) << {'result': ['off', 50, 'off', 'off', 1, 'on', 1, 'on', 0], 'id': 2} Power: off Brightness: 50 Eye Fatigue Reminder: False Ambient Light: False Ambient Light Brightness: 1 Eyecare Mode: True Eyecare Scene: 1 Night Light: True Countdown of the delayed turn off: 0 minutes

I can try to help with debuging this, but please tell me what else I can do here. I own two of these lights, and both react the same way. I found a guy on the internet, which has same problem as mine.

pniewiadowski avatar Jan 26 '20 16:01 pniewiadowski

Do you mean the button of the device itself? What happens after 4-5 days if you remove the integration from HA?

syssi avatar Jan 26 '20 17:01 syssi

Yes, I mean the button of the device itself. Any of the buton doesn't react. Well, I didn't think of removing this integration, but le me check and come once the issue occur again. It can take few days :)

pniewiadowski avatar Jan 26 '20 18:01 pniewiadowski

This time issue appeared a bit faster. After few hours. I have removed the integration from HA, but this did not resolve the problem. The other light which is not integrated with HA works as it should.

pniewiadowski avatar Jan 27 '20 08:01 pniewiadowski

You should contact the manufacturer of your device because it looks like an firmware issue which cannot be solved here.

syssi avatar Jan 27 '20 08:01 syssi

Hmm, so why is that the manufacturer integration (Mi Home app) works, while once I start using python-miio it stops?

pniewiadowski avatar Jan 27 '20 08:01 pniewiadowski

What did you mean by:

I have removed the integration from HA, but this did not resolve the problem.

If the issue appears without interaction with 3rd party apps/libraries it should be a hardware/firmware issue of the device itself. Correct me if I'm wrong. :-)

syssi avatar Jan 27 '20 08:01 syssi

I thought you want me to remove the integration from HA, once the issue occur again. So I did, and the issue persists.

The other Philips light is sync with Hi Home app, but not with HA and the issue doesn't appear so I think there is something with python-miio.

Hope I am clear now :)

pniewiadowski avatar Jan 27 '20 09:01 pniewiadowski

Hey, I found out this is the same here: https://github.com/syssi/philipslight/issues/25

I can try and help, but need some guidance, what I can check.

pniewiadowski avatar Jan 27 '20 19:01 pniewiadowski

The same issue here with two different versions of the lamp. Please let me know if I can help debugging it

maximalexanian avatar Feb 10 '20 20:02 maximalexanian

Same issue here, when integrated with Home Assistant the physical buttons stop working after a while until the power is turned off (after which it happens again). When it's not connected with Home Assistant this problem does not occur.

I would say that the most logical explanation is that python-miio somehow triggers a bug (or a hidden child lock function?) in the firmware, but maybe we can find a workaround for it?

Emilv2 avatar Mar 04 '20 17:03 Emilv2

Hey, any news about this? I really would like to help, but not sure how.

pniewiadowski avatar Apr 01 '20 18:04 pniewiadowski

Well, the only real way (in my opinion) to find out is to use the command-line tool (or create a script to do those calls) and find out at which point and at which call it will get stuck.

My intuition agrees with the analysis of @Emilv2 on that regard, but we need to find out what triggers it and then create a workaround for it.

As it does not hit until a few days later, maybe this has something to do with the sequence numbers? So perhaps:

  • Too high sequence numbers trigger that behavior, or
  • Cycling the ID back to one triggers this.

One way to try that out would be to initialize the device with a large sequence number and see what happens when it hits the limit (see https://github.com/rytilahti/python-miio/blob/master/miio/miioprotocol.py#L231).

rytilahti avatar Apr 02 '20 12:04 rytilahti

To refresh the discussion of the defect, I am joining the party and become another additional victim of the issue.

seafoodrice avatar Jun 24 '20 10:06 seafoodrice

I have exactly the same problem with 3 lamps, it is annoying because my children can no longer use the lamp, you can find a solution? Thanks you

xekil avatar Aug 13 '20 20:08 xekil

A have the same problem with xiaomi zhimi heater and it started after firmware upgrade.

bazuchan avatar Aug 14 '20 06:08 bazuchan

Same issue with 2x Philips Eyecare lamps, only happened since integrating with HA which is a shame as they are now useless for "dumb" operations (using buttons) which my wife prefers.

Would really like a fix!

Light Xiaomi firmware version: 1.2.8.0026

Stupco avatar Sep 02 '20 01:09 Stupco

Same issue, for already a year... all the time i need to get a new token and as soon as it is connected to Home Assistant, buttons on the device are disabled. Please, need a solution for this.

TigranAsaturjan avatar Oct 26 '20 17:10 TigranAsaturjan

same issue philips eyecare 2 I used openhab before and everything worked there, after switching to homeassistant the buttons stopped working

janowakps avatar Jan 18 '21 17:01 janowakps

@janowakps Are you sure? Can we try to compare both implementations?

syssi avatar Jan 18 '21 18:01 syssi

This seems to be the https://github.com/openhab/openhab-addons/tree/main/bundles/org.openhab.binding.miio miio OpenHAB implementation.

Edit: Think this is the official one

Emilv2 avatar Jan 18 '21 18:01 Emilv2

This issue applies to the sread1, right?

syssi avatar Jan 18 '21 18:01 syssi

https://github.com/openhab/openhab-addons/blob/main/bundles/org.openhab.binding.miio/src/main/resources/database/philips.light.sread1.json

syssi avatar Jan 18 '21 18:01 syssi

Implemented properties and commands:

$ cat philips.light.sread1.json | grep property
                                "property": "power",
                                "property": "bright",
                                "property": "ambstatus",
                                "property": "ambvalue",
                                "property": "dvalue",
                                "property": "eyecare",
                                "property": "bl",
$ 
$ cat philips.light.sread1.json | grep command
                                                "command": "set_power",
                                                "command": "set_bright",
                                                "command": "set_power",
                                                "command": "enable_amb",
                                                "command": "set_amb_bright",
                                                "command": "set_eyecare",
                                                "command": "enable_bl",

We are using this properties: https://github.com/rytilahti/python-miio/blob/master/miio/philips_eyecare.py#L122-L132

syssi avatar Jan 18 '21 18:01 syssi

# python-miio, https://github.com/rytilahti/python-miio/blob/master/miio/philips_eyecare.py#L122-L131
            "power",
            "bright",
            "ambstatus",
            "ambvalue",
            "dvalue",
            "eyecare",
            "bls", // typo?
            "notifystatus", // not requested at openhab
            "scene_num", // not requested at openhab

syssi avatar Jan 18 '21 18:01 syssi

The mi home plugin (react app) uses this set of properties:

 _miot.Device.getDeviceWifi().callMethod('get_prop', ["power", "bright", "notifystatus", "ambstatus", "ambvalue", "eyecare", "scene_num", "bls", "dvalue"]).then(function (response) {

syssi avatar Jan 18 '21 18:01 syssi

Anybody here available for an experiment?

  1. Remove this device from HA (comment out the philipslight platform).
  2. Reboot the lamp and test the phyiscal buttons. They should work now.
  3. Install this custom component: https://github.com/syssi/xiaomi_raw/
  4. Configure the lamp as switch (because this component doesn't support a light entity):
switch:
  - platform: xiaomi_miio_raw
    name: Philips Eyecare Lamp
    host: <host>
    token: <token>
    turn_on_command: 'set_power'
    turn_on_parameters: 'on'
    turn_off_command: 'set_power'
    turn_off_parameters: 'off'
    state_property: 'power'
    state_property_getter: 'get_prop'
    state_on_value: 'on'
    state_off_value: 'off'
  1. Restart Home Assistant
  2. You should be able to control the lamp via the switch entity (switch.philips_eyecare_lamp) now. You cannot change the brightness remotely etc. because we are requesting a single property (periodically) now (power) and we use the set_power method only. If the phyiscal buttons are working now and doesn't get stuck we are on the right track. If the phyiscal buttons doesn't work after some time, we can stop this experiment and we don't need to care about the number of requested properties.

syssi avatar Jan 18 '21 18:01 syssi

This issue applies to the sread1, right?

yes, everything except this lamp works fine I'm starting an experiment, I'll let you know in a few days

janowakps avatar Jan 18 '21 19:01 janowakps

I'll give it a try too

Emilv2 avatar Jan 18 '21 19:01 Emilv2

Trying this one as well. Will see.

pniewiadowski avatar Jan 18 '21 20:01 pniewiadowski

I have two of these lights. I have integrated them and reset the same time 4 days ago. One currently running on the "xiaomi_raw" custom component. another one on Home Assistant integration. The one running "xiaomi_raw" - no issue with buttons but the second one, I have found out today buttons stops working so the "xiaomi_raw" custom component looks promising :)

Continue testing.

pniewiadowski avatar Jan 22 '21 12:01 pniewiadowski

same here, xiaomi_raw 4 days without issue

janowakps avatar Jan 22 '21 12:01 janowakps

Yes, seems like you're on the right track @syssi

Emilv2 avatar Jan 24 '21 16:01 Emilv2

@syssi a week has passed and I can confirm with almost 100% certainty that in this configuration with xiaomi_raw it does not block the physical buttons

janowakps avatar Jan 25 '21 22:01 janowakps

@syssi everything still works fine, can we move on? I will be happy to take part in further experiments

janowakps avatar Feb 09 '21 00:02 janowakps

The next step is to request a properties periodically as the custom component is doing it. Just add this block to your configuration:

# first try

sensor:
  - platform: xiaomi_miio_raw
    name: Philips Eyecare Lamp Properties
    host: <host>
    token: <token>
    sensor_property: 'bright'
    sensor_unit: '%'
    default_properties_getter: 'get_prop'
    default_properties:
      - power
      - bright
      - notifystatus
      - ambstatus
      - eyecare
      - scene_num
      - bls
      - dvalue

A new sensor (sensor.philips_eyecare_lamp_properties) will be registered. It will show the brightness property as value. The values of the other properties are available as attributes. As soon the device crashs we will reduce the number of properties.

# second try. The set of properties used at openhab. Using "bl" instead of "bls".

sensor:
  - platform: xiaomi_miio_raw
    name: Philips Eyecare Lamp Properties
    host: <host>
    token: <token>
    sensor_property: 'bright'
    sensor_unit: '%'
    default_properties_getter: 'get_prop'
    default_properties:
      - power
      - bright
      - ambstatus
      - ambvalue
      - dvalue
      - eyecare
      - bl

syssi avatar Feb 09 '21 07:02 syssi

I was trying to add this today but there seems to be a problem with sensor_unit

Invalid config for [sensor.xiaomi_miio_raw]: [sensor_unit] is an invalid option for [sensor.xiaomi_miio_raw]. Check: sensor.xiaomi_miio_raw->sensor_unit. (See ?, line ?).

pniewiadowski avatar Feb 09 '21 20:02 pniewiadowski

I've released a fixed xiaomi_miio_raw version (1.4.0) right now. Please give it a try.

syssi avatar Feb 10 '21 10:02 syssi

Weird, I didn't have that issue. The buttons just stopped working with the first test values. I will try the second test now.

Emilv2 avatar Feb 10 '21 14:02 Emilv2

@syssi hi so here is my results: first test with bls physical buttons stops responding after just one day second test with bl instead bls 9 days and still everytning works

so i think we have a solution

janowakps avatar Feb 22 '21 22:02 janowakps

@syssi hi so here is my results: first test with bls physical buttons stops responding after just one day second test with bl instead bls 9 days and still everytning works

so i think we have a solution

Not yet I think, there are more differences between the two: there's also scene_num and notifystatus. Changing bl into bls does still work after 5 days here.

Emilv2 avatar Feb 22 '21 22:02 Emilv2

there are more differences between the two: there's also scene_num and notifystatus

in fact, I didn't even notice these code differences but still it's been 10 days and I get this data from the integration

model: philips.light.sread1
firmware_version: 1.2.8
hardware_version: ESP8266
properties: eyecare, bright, power, notifystatus, scene_num, dvalue, bl, ambstatus
sensor_property: bright
eyecare: off
bright: 100
power: off
notifystatus: off
scene_num: 1
dvalue: 0
bl: on
unit_of_measurement: %
friendly_name: Philips Eyecare Lamp Properties
icon: mdi:flask-outline

so everything is fine except for the "ambstatus" property which should be turned on now (because I turned it on with the button) but it doesn't show at all

janowakps avatar Feb 22 '21 23:02 janowakps

For me it's been six days now with these values in the configuration:

      - power
      - bright
      - ambstatus
      - ambvalue
      - dvalue
      - eyecare
      - bls

ambvalue and ambstatus work for me:

model: philips.light.sread1
firmware_version: 1.2.8
hardware_version: ESP8266
properties: dvalue, ambstatus, power, bls, eyecare, ambvalue, bright
sensor_property: bright
dvalue: 0
ambstatus: off
power: on
bls: on
eyecare: off
ambvalue: 41
bright: 5
unit_of_measurement: %
friendly_name: Philips Eyecare Lamp Properties
icon: mdi:flask-outline

I'll wait a few more days to be 100% sure, but I don't think bls is the issue. Maybe it's a combination that does it?

I'm also not really sure what ambvalue, abmstatus and bls/bl are supposed to represent, they do not seem to change values at all.

Emilv2 avatar Feb 23 '21 09:02 Emilv2

I would be happy if everybody could provide a list of good vs. bad properties.

ambvalue: Brightness of the ambient light.
ambstatus: Ambient light on/off
bls/bl: True if the smart night light mode is on.

syssi avatar Feb 23 '21 09:02 syssi

I was too quick in replying, those properties do indeed what you say and seem to work correctly for me.

Emilv2 avatar Feb 23 '21 10:02 Emilv2

I have added notifystatus and the buttons stopped working after 5 days.

Emilv2 avatar Mar 02 '21 08:03 Emilv2

24 days and still everythings works my properties:

      - power
      - bright
      - notifystatus
      - ambstatus
      - eyecare
      - scene_num
      - bl
      - dvalue

as you can see, notifystatus is not causing the problem

janowakps avatar Mar 19 '21 01:03 janowakps

I will remove notifystatus from python-miio.

syssi avatar Mar 19 '21 05:03 syssi

@syssi I think you misread, @janowakps has no issue with notifystatus.

I've been running this configuration for 17 days now and everything still works:

      - power
      - bright
      - ambstatus
      - scene_num
      - ambvalue
      - dvalue
      - eyecare
      - bls

So I'd say bls isn't the problem either. Maybe it's a combination that triggers the issue?

Emilv2 avatar Mar 19 '21 08:03 Emilv2

Ups. You are right. In this case the exact solution is still undefined. :-(

syssi avatar Mar 19 '21 08:03 syssi

Isn't it possible to hook up Arduino studio to this lamp and check the logs/output?

ratcashdev avatar May 02 '21 20:05 ratcashdev

Hello, you can find a solution? Thanks you

xekil avatar Jul 10 '21 13:07 xekil

It works like a charm! 2nd day and buttons on lamp still works. I am missing a bit brightness and ambient light control but even without it this lamp makes sense now. @syssi not sure if you are author of this fix do you think this can be implemented to final code or you can fix original integration?

misterymisery avatar Sep 25 '21 20:09 misterymisery

Could somebody test this property set on the long run:

sensor:
  - platform: xiaomi_miio_raw
    name: Philips Eyecare Lamp Properties
    host: <host>
    token: <token>
    sensor_property: 'bright'
    sensor_unit: '%'
    default_properties_getter: 'get_prop'
    default_properties:
      - power
      - bright
      - ambstatus
      - notifystatus
      - ambvalue
      - dvalue
      - eyecare
      - bls

I've replaced scene_num by notifystatus to retrieve the most useful properties from the device.

syssi avatar Sep 26 '21 08:09 syssi

Could somebody test this property set on the long run:

sensor:
  - platform: xiaomi_miio_raw
    name: Philips Eyecare Lamp Properties
    host: <host>
    token: <token>
    sensor_property: 'bright'
    sensor_unit: '%'
    default_properties_getter: 'get_prop'
    default_properties:
      - power
      - bright
      - ambstatus
      - notifystatus
      - ambvalue
      - dvalue
      - eyecare
      - bls

I've replaced scene_num by notifystatus to retrieve the most useful properties from the device.

I would like to help but I am not so good in writing in yaml.

This is my setup. How it should look with your settings you would like to test?

switch:

  • platform: xiaomi_miio_raw name: Attic Philips Raw host: XXX.XXX.XXX.XXX token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx turn_on_command: 'set_power' turn_on_parameters: 'on' turn_off_command: 'set_power' turn_off_parameters: 'off' state_property: 'power' state_property_getter: 'get_prop' state_on_value: 'on' state_off_value: 'off'

misterymisery avatar Sep 30 '21 08:09 misterymisery

Could somebody test this property set on the long run:

sensor:
  - platform: xiaomi_miio_raw
    name: Philips Eyecare Lamp Properties
    host: <host>
    token: <token>
    sensor_property: 'bright'
    sensor_unit: '%'
    default_properties_getter: 'get_prop'
    default_properties:
      - power
      - bright
      - ambstatus
      - notifystatus
      - ambvalue
      - dvalue
      - eyecare
      - bls

I've replaced scene_num by notifystatus to retrieve the most useful properties from the device.

I tried this config and the buttons still stop working after a while.

Emilv2 avatar Oct 11 '21 08:10 Emilv2

24 days and still everythings works my properties:

      - power
      - bright
      - notifystatus
      - ambstatus
      - eyecare
      - scene_num
      - bl
      - dvalue

as you can see, notifystatus is not causing the problem

For me this configuration also does not seem to cause any issues. @syssi Maybe take this one then?

Emilv2 avatar Oct 28 '21 20:10 Emilv2

hello, any idea of the official integration modification date?

xekil avatar Nov 08 '21 15:11 xekil

The set of properties provided by @Emilv2 cannot be used without dropping a feature (brightness of the ambient light). I'm unsure how to proceed here.

syssi avatar Nov 08 '21 16:11 syssi

I see, that is unfortunate. This one worked for me (don't know about others, has anyone confirmed it worked?):

  - power
  - bright
  - ambstatus
  - scene_num
  - ambvalue
  - dvalue
  - eyecare
  - bls

Anything important missing here?

That aside, for me at least, being able to control the lamp manually is much more important than any other feature.

Emilv2 avatar Nov 08 '21 17:11 Emilv2

That aside, for me at least, being able to control the lamp manually is much more important than any other feature.

+++ 10000, update please, especially since the variation in the brightness of the ambient light is barely perceptible I find

xekil avatar Nov 09 '21 12:11 xekil

after update ha 2021.12

Found an unsupported model 'philips.light.sread1' for class 'PhilipsEyecare'. If this is working for you, please open an issue at https://github.com/rytilahti/python-miio/

xekil avatar Dec 12 '21 10:12 xekil

@xekil that's a separate issue, but I added the model to #1246 so that it will disappear from the logs in time.

rytilahti avatar Dec 13 '21 18:12 rytilahti

@rytilahti OK, thanks. Any ideas on the availability of the fix for the physical buttons problem?

thank you

xekil avatar Dec 13 '21 18:12 xekil

Same problem here. 2 Lamps, worked perfectly for months until I added them to HA. since I added them, after hours or days the physical buttons stops responding. plugging off fixes it temporarily. I thought maybe it happens after HA turns them on (manually or by automation) but nope. I seems not deterministic.

YuvalWS avatar May 01 '22 19:05 YuvalWS

Any ideas on the availability of the fix for the physical buttons problem? thank you

xekil avatar Jun 04 '22 12:06 xekil

Sorry, I have no idea what is causing the problem nor do I have such a device myself, so I cannot really help here :-(

rytilahti avatar Jun 04 '22 23:06 rytilahti

any update ?

xekil avatar Jul 22 '22 12:07 xekil