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

yeeligth without color temperature status error #802

Closed
petrmelnikov opened this issue Aug 19, 2020 · 7 comments · Fixed by #829
Closed

yeeligth without color temperature status error #802

petrmelnikov opened this issue Aug 19, 2020 · 7 comments · Fixed by #829
Labels

Comments

@petrmelnikov
Copy link

petrmelnikov commented Aug 19, 2020

Trying to get status of yeelight lamp without color temperature support

  • OS: Linux (Raspberry Pi OS)/macOS 10.15.5

  • python-miio: miiocli, version 0.5.3

  • Model: yeelink.light.mono1

  • Hardware version: ?

  • Firmware version: latest

Steps to reproduce the behavior:

  1. execute command miiocli yeelight --ip <ip> --token <token> status on yeelink.light.mono1 device

Expected behavior
getting status of device

Console output

  ctx.obj = self.device_class(*args, **kwargs)
Traceback (most recent call last):
  File "/usr/local/bin/miiocli", line 8, in <module>
    sys.exit(create_cli())
  File "/usr/local/lib/python3.8/site-packages/miio/cli.py", line 45, in create_cli
    return cli(auto_envvar_prefix="MIIO")
  File "/usr/local/lib/python3.8/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/miio/click_common.py", line 285, in wrap
    result_msg = result_msg_fmt.format(**kwargs)
  File "/usr/local/lib/python3.8/site-packages/miio/yeelight.py", line 62, in color_temp
    return int(self.data["ct"])
ValueError: invalid literal for int() with base 10: ''
@rytilahti
Copy link
Owner

Could you run the miiocli with the debug flag and paste the complete response from the device? That conversion is only tried when the bulb is reporting to be in the color temperature mode, so I'm wondering if the device is reporting also other information incorrectly: https://github.com/rytilahti/python-miio/blob/master/miio/yeelight.py#L60

@petrmelnikov
Copy link
Author

petrmelnikov commented Aug 20, 2020

command with debug flag:
miiocli -d yeelight --ip <ip> --token <token> status

result:

/usr/local/lib/python3.8/site-packages/miio/click_common.py:242: UserWarning: Please consider using python-yeelight for more complete support.
  ctx.obj = self.device_class(*args, **kwargs)
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.miioprotocol: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\x00\xd0\x9e\x9f\x00\x00\x01#' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = unhexlify('00d09e9f')
            ts = 1970-01-01 00:04:51
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' (total 16)
DEBUG:miio.miioprotocol:Discovered 00d09e9f with ts: 1970-01-01 00:04:51, token: b'00000000000000000000000000000000'
DEBUG:miio.miioprotocol:192.168.88.20:54321 >>: {'id': 1, 'method': 'get_prop', 'params': ['power', 'bright', 'ct', 'rgb', 'hue', 'sat', 'color_mode', 'name', 'lan_ctrl', 'save_state']}
DEBUG:miio.miioprotocol:192.168.88.20:54321 (ts: 1970-01-01 00:04:51, id: 1) << {'result': ['off', '100', '', '', '', '', '2', '', '0', '0'], 'id': 1}
Traceback (most recent call last):
  File "/usr/local/bin/miiocli", line 8, in <module>
    sys.exit(create_cli())
  File "/usr/local/lib/python3.8/site-packages/miio/cli.py", line 45, in create_cli
    return cli(auto_envvar_prefix="MIIO")
  File "/usr/local/lib/python3.8/site-packages/miio/click_common.py", line 59, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/miio/click_common.py", line 285, in wrap
    result_msg = result_msg_fmt.format(**kwargs)
  File "/usr/local/lib/python3.8/site-packages/miio/yeelight.py", line 62, in color_temp
    return int(self.data["ct"])
ValueError: invalid literal for int() with base 10: ''

@petrmelnikov
Copy link
Author

I'm very new in python. Can you please provide me some links that's help to figure out how to build this project? I want to try fix this bug by myself.
I already have tried to execute this command from sources instead of installed version, but it won't use edited sources.

rytilahti added a commit that referenced this issue Oct 6, 2020
yeelink.light.mono1 is seemingly reporting color_mode to be 2 (color temperature) even when the light does not support ct.
This PR checks that the values for ct (or hue, sat & brightness for hsv mode, and rgb for rgb mode) are not empty.

Fixes #802
@rytilahti
Copy link
Owner

This library uses poetry to maintain dependencies, you can do local installation by commanding:

poetry install

which will create a virtual environment and install the package.

After installation, you can activate the virtual environment with poetry shell or execute commands inside the environment directly with run:

poetry run miiocli --help

I created a PR to fix this issue, feel free to test it and report back!

@petrmelnikov
Copy link
Author

petrmelnikov commented Oct 6, 2020

That's great! Thank you for fixing bug and for this manual!

@rytilahti
Copy link
Owner

You're welcome! Sorry, I just noticed that you wanted to give it a shot yourself, I didn't see that before :( Is it working for you with that PR now, though?

@petrmelnikov
Copy link
Author

petrmelnikov commented Oct 7, 2020

Yes! It is working now! Thank you!
Here my console output:

poetry run miiocli yeelight --ip <ip> --token <token> status

/Users/user/projects/python-miio/miio/click_common.py:242: UserWarning: Please consider using python-yeelight for more complete support.
  ctx.obj = self.device_class(*args, **kwargs)
Name:
Power: True
Brightness: 100
Color mode: 2
RGB: None
HSV: None
Temperature: None
Developer mode: False
Update default on change: False

rytilahti added a commit that referenced this issue Oct 7, 2020
yeelink.light.mono1 is seemingly reporting color_mode to be 2 (color temperature) even when the light does not support ct.
This PR checks that the values for ct (or hue, sat & brightness for hsv mode, and rgb for rgb mode) are not empty.

Fixes #802
swim2sun pushed a commit to swim2sun/python-miio that referenced this issue Oct 13, 2020
yeelink.light.mono1 is seemingly reporting color_mode to be 2 (color temperature) even when the light does not support ct.
This PR checks that the values for ct (or hue, sat & brightness for hsv mode, and rgb for rgb mode) are not empty.

Fixes rytilahti#802
xvlady pushed a commit to xvlady/python-miio that referenced this issue May 9, 2021
yeelink.light.mono1 is seemingly reporting color_mode to be 2 (color temperature) even when the light does not support ct.
This PR checks that the values for ct (or hue, sat & brightness for hsv mode, and rgb for rgb mode) are not empty.

Fixes rytilahti#802
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants