Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xiaomi-Philips Eyecare control fail #74

Closed
pandemixxx opened this issue Sep 11, 2017 · 15 comments
Closed

Xiaomi-Philips Eyecare control fail #74

pandemixxx opened this issue Sep 11, 2017 · 15 comments
Labels

Comments

@pandemixxx
Copy link

pandemixxx commented Sep 11, 2017

Got a token from android, trying to control, I'll be appreciate for any help, thanx!
Here's what I got:

$ mieye --ip=10.0.1.211 --token=4aaf6dd769bcb0a87dbe9aff278cc53a -d
INFO:mirobo.philips_eyecare_cli:Debug mode active
DEBUG:mirobo.philips_eyecare_cli:Connecting to 10.0.1.211 with token 4aaf6dd769bcb0a87dbe9aff278cc53a
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
DEBUG:mirobo.device:Got a response: Container: 
    data = Container: 
        length = 0
        value =  (total 0)
        data =  (total 0)
        offset2 = 32
        offset1 = 32
    header = Container: 
        length = 16
        value = Container: 
            length = 32
            unknown = 0
            devtype = 760
            serial = 2211
            ts = 1970-01-01 00:06:43
        data = !1\x00 \x00\x00\x00\x00\x02\xf8\x08\xa3\x00\x00\x01\x93 (total 16)
        offset2 = 16
        offset1 = 0
    checksum = \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (total 16)
DEBUG:mirobo.device:Discovered 760 2211 with ts: 1970-01-01 00:06:43, token: b'00000000000000000000000000000000'
DEBUG:mirobo.device:10.0.1.211:54321 >>: {'id': 2, 'method': 'get_prop', 'params': ['power', 'bright', 'notifystatus', 'ambstatus', 'ambvalue', 'eyecare', 'scene_num', 'bls', 'dvalue']}
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 2706, in _parse
    return self.subcon._parse(stream, context, path)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 1550, in _parse
    obj = self.cases.get(key, self.default)._parse(stream, context, path)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 2264, in _parse
    hash2 if not isinstance(hash2,bytes) else hexlify(hash2), ))
construct.core.ChecksumError: wrong checksum, read b'ffffffffffffffffffffffffffffffff', computed b'08c44fdf612e6748f7bd83d008b21da8'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/mieye", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/mirobo/philips_eyecare_cli.py", line 82, in cli
    ctx.invoke(status)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/mirobo/philips_eyecare_cli.py", line 95, in status
    res = dev.status()
  File "/usr/local/lib/python3.4/dist-packages/mirobo/philips_eyecare.py", line 71, in status
    properties
  File "/usr/local/lib/python3.4/dist-packages/mirobo/device.py", line 156, in send
    m = Message.parse(data, ctx)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 165, in parse
    return self.parse_stream(BytesIO(data), context, **kw)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 178, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 848, in _parse
    subobj = sc._parse(stream, context, path)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 2710, in _parse
    raise e.__class__("%s\n    %s" % (e, path))
construct.core.ChecksumError: wrong checksum, read b'ffffffffffffffffffffffffffffffff', computed b'08c44fdf612e6748f7bd83d008b21da8'
    (parsing) -> checksum
@syssi
Copy link
Collaborator

syssi commented Sep 11, 2017

Could you also post the output of

mirobo --ip=10.0.1.211 --token=4aaf6dd769bcb0a87dbe9aff278cc53a -d info

(It's right. The command is called "mirobo" this time)

@pandemixxx
Copy link
Author

@syssi of course, thanx!

mirobo --ip=10.0.1.211 --token=4aaf6dd769bcb0a87dbe9aff278cc53a -d info
INFO:mirobo.vacuum_cli:Debug mode active
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1063, in invoke
    Command.invoke(self, ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/mirobo/vacuum_cli.py", line 71, in cli
    x = json.load(f)
  File "/usr/lib/python3.4/json/__init__.py", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

@rytilahti
Copy link
Owner

Could you try the same command a double d (-dd) to get a more precise output what is being sent and received. Looks like it does not respond to the info call with a proper json.

Regarding to the checksum, a series of 'f's is normally received as a part of the handshake, which is unexpected here.

@pandemixxx
Copy link
Author

@rytilahti Yap, here it is:

mirobo --ip=10.0.1.211 --token=4aaf6dd769bcb0a87dbe9aff278cc53a -dd info
INFO:mirobo.vacuum_cli:Debug mode active
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1063, in invoke
    Command.invoke(self, ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/mirobo/vacuum_cli.py", line 71, in cli
    x = json.load(f)
  File "/usr/lib/python3.4/json/__init__.py", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

@rytilahti
Copy link
Owner

rytilahti commented Sep 13, 2017

Please remove /tmp/python-mirobo.seq and try again, the json parser could not read the file and bailed out. I commited also a fix to avoid crashing on invalid JSON.

@pandemixxx
Copy link
Author

Deleted, here's what I got now:

mirobo --ip=10.0.1.211 --token=4aaf6dd769bcb0a87dbe9aff278cc53a -dd info
INFO:mirobo.vacuum_cli:Debug mode active
ERROR:mirobo.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
DEBUG:mirobo.vacuum_cli:Connecting to 10.0.1.211 with token 4aaf6dd769bcb0a87dbe9aff278cc53a
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
DEBUG:mirobo.device:Got a response: Container: 
    data = Container: 
        offset2 = 32
        length = 0
        value =  (total 0)
        offset1 = 32
        data =  (total 0)
    header = Container: 
        offset2 = 16
        length = 16
        value = Container: 
            length = 32
            unknown = 0
            devtype = 760
            serial = 2211
            ts = 1970-01-03 08:51:01
        offset1 = 0
        data = !1\x00 \x00\x00\x00\x00\x02\xf8\x08\xa3\x00\x03\x1fu (total 16)
    checksum = \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (total 16)
DEBUG:mirobo.device:Container: 
    data = Container: 
        offset2 = 32
        length = 0
        value =  (total 0)
        offset1 = 32
        data =  (total 0)
    header = Container: 
        offset2 = 16
        length = 16
        value = Container: 
            length = 32
            unknown = 0
            devtype = 760
            serial = 2211
            ts = 1970-01-03 08:51:01
        offset1 = 0
        data = !1\x00 \x00\x00\x00\x00\x02\xf8\x08\xa3\x00\x03\x1fu (total 16)
    checksum = \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (total 16)
DEBUG:mirobo.device:Discovered 760 2211 with ts: 1970-01-03 08:51:01, token: b'00000000000000000000000000000000'
DEBUG:mirobo.device:10.0.1.211:54321 >>: {'method': 'miIO.info', 'id': 1, 'params': []}
DEBUG:mirobo.device:send (timeout 5): Container: 
    data = Container: 
        offset2 = 80
        length = 48
        value = {'method': 'miIO.info', 'id': 1, 'params': []}
        offset1 = 32
        data = !g\xe93(>\xb8\xeeo`\xbf\xd0\xebAG\xb1\x10^X\xa7#\xf6\xcb\x8a\x93\xd9\xcd\xc5"\x8d\xc9B[\xb6!{(\xbf\\\xc1\xe8L\xfd\xbf\x9eJ]\xc1 (total 48)
    header = Container: 
        offset2 = 16
        length = 16
        value = Container: 
            length = 80
            unknown = 0
            devtype = 760
            serial = 2211
            ts = 1970-01-03 08:51:02
        offset1 = 0
        data = !1\x00P\x00\x00\x00\x00\x02\xf8\x08\xa3\x00\x03\x1fv (total 16)
    checksum = ?\xa0\xfb\xe0\xdc\x94\x00k\xd3\x94\xd3\xfd`\xf0\xec\x87 (total 16)
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 2705, in _parse
    return self.subcon._parse(stream, context, path)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 1549, in _parse
    obj = self.cases.get(key, self.default)._parse(stream, context, path)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 2263, in _parse
    hash2 if not isinstance(hash2,bytes) else hexlify(hash2), ))
construct.core.ChecksumError: wrong checksum, read b'ffffffffffffffffffffffffffffffff', computed b'48917010a9a9ecd6d618658c06505f31'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/mirobo/vacuum_cli.py", line 341, in info
    res = vac.info()
  File "/usr/local/lib/python3.4/dist-packages/mirobo/device.py", line 185, in info
    return DeviceInfo(self.send("miIO.info", []))
  File "/usr/local/lib/python3.4/dist-packages/mirobo/device.py", line 157, in send
    m = Message.parse(data, ctx)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 161, in parse
    return self.parse_stream(BytesIO(data), context, **kw)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 174, in parse_stream
    return self._parse(stream, context2, "(parsing)")
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 844, in _parse
    subobj = sc._parse(stream, context, path)
  File "/usr/local/lib/python3.4/dist-packages/construct/core.py", line 2709, in _parse
    raise e.__class__("%s\n    %s" % (e, path))
construct.core.ChecksumError: wrong checksum, read b'ffffffffffffffffffffffffffffffff', computed b'48917010a9a9ecd6d618658c06505f31'
    (parsing) -> checksum

@syssi
Copy link
Collaborator

syssi commented Sep 14, 2017

Are you sure your token is the right one? Could you provide the complete row of your sqlite database? Do you have multiple philips eyecare devices?

@pandemixxx
Copy link
Author

pandemixxx commented Sep 14, 2017

@syssi I have only one xiaomi-philips product - this lamp, but also have xiaomi gateway and yeelight.

Here's a line from database:

28:CF:E9:83:55:74	1	0	Lamp off 		null	49809571	null	{"isSetPincode":0,"fw_version":"1.3.0","needVerifyCode":0,"isPasswordEncrypt":0,"mcu_version":"0024","is_factory":false}	2849	1	50.0127	10.0.1.211	1	36.2521	28:6C:07:28:CC:8E	[{"name":"set_power","allow_values":""}]	philips.light.sread1	Philips EyeCare connected desk lamp gen2.	null	null			16	0	{"power":"off"}	0	-54	1	4aaf6dd769bcb0a87dbe9aff278cc53a	null

Should I try anything else to make it work?

@ghost
Copy link

ghost commented Sep 24, 2017

Got the Xiaomi Philips Eyecare Smart Lamp 2 today.
Working fine on my Raspberry Pi All-In-One.

Solution could be backing up your system, reinstalling it and try again to ensure it is not your system.
Got kind of the same problem before.

As I am an Xiaomi Philips Eyecare Smart Lamp 2 owner,
if I can assist @pandemixxx @syssi , please let me know.

Which brings me to the next point, please add the Xiaomi-Philips Eyecare lamp to home assistant.

mieye --ip=12.12.12.16 --token=ea9405da516b121347f7ccdd56876c14 -dd on
INFO:mirobo.philips_eyecare_cli:Debug mode active
DEBUG:mirobo.philips_eyecare_cli:Connecting to 12.12.12.16 with token
ea9405da516b121347f7ccdd56876c14
DEBUG:mirobo.protocol:Unable to decrypt, returning raw bytes.
DEBUG:mirobo.device:Got a response: Container:
    data = Container:
        offset2 = 32
        offset1 = 32
        length = 0
        value =  (total 0)
        data =  (total 0)
    header = Container:
        offset2 = 16
        offset1 = 0
        length = 16
        value = Container:
            length = 32
            unknown = 0
            devtype = 756
            serial = 13005
            ts = 1970-01-01 16:02:47
        data = !1\x00 \x00\x00\x00\x00\x02\xf42\x00\x00\x00\xe1\xa7 (total
16)
    checksum = \xea\x94\x05\xdaQk\x12\x13G\xf7\x00\xd3y\x00\x14 (total 16)
DEBUG:mirobo.device:Discovered 756 13005 with ts: 1970-01-01 16:02:47,
token: b'ea9405da516b121347f7ccdd56876c14'
DEBUG:mirobo.device:12.12.12.16:54321 >>: {'params': ['on'], 'id': 3,
'method': 'set_power'}
DEBUG:mirobo.device:12.12.12.16:54321 (ts: 1970-01-01 16:02:47, id: 3) <<
{'result': ['ok'], 'id': 3}
Power on: ['ok']

@pandemixxx
Copy link
Author

@buikdaanser Glad you made it work. But that's kind of radical, I have my lights+some other home iot stuff running on raspberry, so it's not that easy for me to make such an experiment for the lamp only.
But thank you for feedback anyway!

@ghost
Copy link

ghost commented Sep 25, 2017

@pandemixxx Understood.
I was assuming that you are using the Xiaomi-Philips Eyecare lamp on an none home-production machine. I.e. test machine.

Given the fact that the lamp does not work yet.
And on the same time your home automation should just work as it should be.

Because testing, make changes to the code, restart the home automation could result in the dysfunction of your home automation.

Hopefully your problem could be fixed by either @syssi or @rytilahti.

@bockelaar
Copy link

@buikdaanser thanks! I managed to switch the philips led bulb on and off. Any hints in how to set the other options as well?

output now:
DEBUG:miio.device:Discovered 923 7580 with ts: 1970-01-15 16:40:53, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.2.17:54321 >>: {'id': 3, 'method': 'get_prop', 'params': ['power', 'bright', 'notifystatus', 'ambstatus', 'ambvalue', 'eyecare', 'scene_num', 'bls', 'dvalue']}
DEBUG:miio.device:192.168.2.17:54321 (ts: 1970-01-15 16:40:53, id: 3) << {'id': 3, 'result': ['off', 100]}
DEBUG:miio.philips_eyecare:Count (9) of requested properties does not match the count (2) of received values.
Power: off
Brightness: 100
Eye Fatigue Reminder: False
Ambient Light: False
Ambient Light Brightness: None
Eyecare Mode: False
Eyecare Scene: None
Night Light: False
Countdown of the delayed turn off: None minutes

and putting it in off:
sudo mieye --ip 192.168.2.17 --token 00000x0sjfjaff -dd on
INFO:miio.philips_eyecare_cli:Debug mode active
DEBUG:miio.philips_eyecare_cli:Connecting to 192.168.2.17 with token 00000x0sjfjaff
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes.
DEBUG:miio.device:Got a response: Container:
data = Container:
length = 0
value = (total 0)
offset1 = 32
data = (total 0)
offset2 = 32
header = Container:
length = 16
value = Container:
length = 32
unknown = 0
devtype = 923
serial = 7580
ts = 1970-01-15 16:44:48
offset1 = 0
data = !1\x00 \x00\x00\x00\x00\x03\x9b\x1d\x9c\x00\x13`\x80 (total 16)
offset2 = 16
checksum = \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 (total 16)
DEBUG:miio.device:Discovered 923 7580 with ts: 1970-01-15 16:44:48, token: b'00000000000000000000000000000000'
DEBUG:miio.device:192.168.2.17:54321 >>: {'method': 'set_power', 'id': 3, 'params': ['on']}
DEBUG:miio.device:192.168.2.17:54321 (ts: 1970-01-15 16:44:49, id: 3) << {'result': ['ok'], 'id': 3}
Power on: ['ok']

@syssi
Copy link
Collaborator

syssi commented Nov 11, 2017

@bockelaar Please create a new issue and tell the product name of your device.

@bockelaar
Copy link

@syssi yea i am sorry, wrong issue to post to :(
miceil is the way to go for the xiaomi philips light bulbs

@syssi
Copy link
Collaborator

syssi commented Apr 1, 2018

Please try again with a recent version of python-miio and re-open the issue if the problem persists.

@syssi syssi closed this as completed Apr 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants