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

qmi.powerstrip.v1 no longer working on 0.40 #334

Closed
AlbrtoSam opened this issue Jun 10, 2018 · 15 comments
Closed

qmi.powerstrip.v1 no longer working on 0.40 #334

AlbrtoSam opened this issue Jun 10, 2018 · 15 comments
Assignees

Comments

@AlbrtoSam
Copy link

AlbrtoSam commented Jun 10, 2018

This is a QMCXB01ZN powerstrip ( 3 usb ) i have just upgraded to version 0.40

I can get the info about the device:

root@pi3:/home/pi# miiocli powerstrip --ip 192.168.1.206 --token abc123 info
Model: qmi.powerstrip.v1
Hardware version: RTL8711AF
Firmware version: 3.4.2_71
Network: {'gw': '192.168.1.1', 'mask': '255.255.255.0', 'localIp': '192.168.1.206'}

But when i try to get the status i get this error:

root@pi3:/home/pi# miiocli powerstrip --ip 192.168.1.206 --token abc123 status
ERROR:miio.protocol:unable to parse json '{"result":[,,,,,,,],"id":1}': Expecting value: line 1 column 12 (char 11)
Traceback (most recent call last):
  File "/usr/local/bin/miiocli", line 11, in <module>
    sys.exit(create_cli())
  File "/usr/local/lib/python3.5/dist-packages/miio/cli.py", line 43, in create_cli
    return cli(auto_envvar_prefix="MIIO")
  File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 53, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 251, in wrap
    kwargs['result'] = func(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 218, in command_callback
    return miio_command.call(miio_device, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 180, in call
    return method(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/miio/powerstrip.py", line 191, in status
    properties
  File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 263, in send
    self.__id = m.data.value["id"]
TypeError: 'NoneType' object is not subscriptable

It worked before using 0.39

Others powerstrip v2 and so on, working fine.

@syssi
Copy link
Collaborator

syssi commented Jun 10, 2018

Could you provide the output of:

miiocli powerstrip --ip 192.168.1.206 --token abc123 raw_command get_prop "['power','temperature','current','mode','power_consume_rate','voltage','power_factor','elec_leakage']"

The the command returns the same error please reduce the requested properties gradually. May be one of the properties isn't supported.

@syssi syssi self-assigned this Jun 10, 2018
@AlbrtoSam
Copy link
Author

/usr/local/bin/miiocli powerstrip --ip 192.168.1.206 --token c48f53f25f913d2dbe226ccd9f0bf4bc raw_command get_prop "['power','temperature','current','mode','power_consume_rate','voltage','power_factor','elec_leakage']"

Running command raw_command
Traceback (most recent call last):
File "/usr/local/bin/miiocli", line 11, in
sys.exit(create_cli())
File "/usr/local/lib/python3.5/dist-packages/miio/cli.py", line 43, in create_cli
return cli(auto_envvar_prefix="MIIO")
File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 53, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 251, in wrap
kwargs['result'] = func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 218, in command_callback
return miio_command.call(miio_device, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 180, in call
return method(*args, **kwargs)
TypeError: raw_command() got an unexpected keyword argument 'parameters'

It doesnt work even with one parameter

root@pi3:/home/pi# miiocli powerstrip --ip 192.168.1.206 --token c48f53f25f913d2dbe226ccd9f0bf4bc raw_command get_prop "['power']"
Running command raw_command
Traceback (most recent call last):
File "/usr/local/bin/miiocli", line 11, in
sys.exit(create_cli())
File "/usr/local/lib/python3.5/dist-packages/miio/cli.py", line 43, in create_cli
return cli(auto_envvar_prefix="MIIO")
File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 53, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 251, in wrap
kwargs['result'] = func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 218, in command_callback
return miio_command.call(miio_device, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 180, in call
return method(*args, **kwargs)
TypeError: raw_command() got an unexpected keyword argument 'parameters'

@syssi
Copy link
Collaborator

syssi commented Jun 11, 2018

This is another bug. :-( Please use:

mirobo --ip 192.168.1.206 --token abc123 raw_command get_prop "['power','temperature','current','mode','power_consume_rate','voltage','power_factor','elec_leakage']"

instead.

@AlbrtoSam
Copy link
Author

Not working too:

root@pi3:/home/pi# mirobo --ip 192.168.1.206 --token abc123 raw_command get_prop "[ 'power', 'temperature', 'current', 'mode', 'power_consume_rate', 'voltage', 'power_factor', 'elec_leakage']"
Sending cmd get_prop with params ['power', 'temperature', 'current', 'mode', 'power_consume_rate', 'voltage', 'power_factor', 'elec_leakage']
ERROR:miio.protocol:unable to parse json '{"result":[,,,,,,,],"id":8}': Expecting value: line 1 column 12 (char 11)
Traceback (most recent call last):
File "/usr/local/bin/mirobo", line 11, in
sys.exit(cli())
File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 53, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/miio/vacuum_cli.py", line 608, in raw_command
click.echo(vac.raw_command(cmd, params))
File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 302, in raw_command
return self.send(cmd, params)
File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 263, in send
self.__id = m.data.value["id"]
TypeError: 'NoneType' object is not subscriptable

@syssi
Copy link
Collaborator

syssi commented Jun 11, 2018

This is the expected error. Now reduce the number of properties. Remove the last one first. Try to identify the problematic property:

"['power','temperature','current','mode','power_consume_rate','voltage','power_factor','elec_leakage']"
"['power','temperature','current','mode','power_consume_rate','voltage','power_factor']"
"['power','temperature','current','mode','power_consume_rate','voltage','elec_leakage']"
"['power','temperature','current','mode','power_consume_rate','voltage']"

@AlbrtoSam
Copy link
Author

Maybe im doing something wrong or it is a format or sintaxis issue but if I send just ONE command, it works fine, but i cant send 2 commands:

root@pi3:/home/pi# mirobo --ip 192.168.1.206 --token abc123 raw_command get_prop "[ 'power', 'temperature']"
Sending cmd get_prop with params ['power', 'temperature']
ERROR:miio.protocol:unable to parse json '{"result":[,],"id":11}': Expecting value: line 1 column 12 (char 11)
Traceback (most recent call last):
File "/usr/local/bin/mirobo", line 11, in
sys.exit(cli())
File "/usr/local/lib/python3.5/dist-packages/miio/click_common.py", line 53, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/miio/vacuum_cli.py", line 608, in raw_command
click.echo(vac.raw_command(cmd, params))
File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 302, in raw_command
return self.send(cmd, params)
File "/usr/local/lib/python3.5/dist-packages/miio/device.py", line 263, in send
self.__id = m.data.value["id"]
TypeError: 'NoneType' object is not subscriptable

But i can ask for power and temperature separatedly.

root@pi3:/home/pi# mirobo --ip 192.168.1.206 --token c48f53f25f913d2dbe226ccd9f0bf4bc raw_command get_prop "[ 'power',]"
Sending cmd get_prop with params ['power']
['on']

root@pi3:/home/pi# mirobo --ip 192.168.1.206 --token c48f53f25f913d2dbe226ccd9f0bf4bc raw_command get_prop "[ 'temperature',]"
Sending cmd get_prop with params ['temperature']
[50]

@syssi
Copy link
Collaborator

syssi commented Jun 11, 2018

Did you block the internet access of the device? Could you try to unblock just for testing?

@AlbrtoSam
Copy link
Author

wow, you did the trick !

Yes i had no internet on this powerstrip....

@AlbrtoSam
Copy link
Author

Now it works using the powertrip command:

/usr/local/bin/miiocli powerstrip --ip 192.168.1.206 --token abc123 status
Power: on
Temperature: 50 °C
Voltage: 232.2 V
Current: 55 A
Load power: 6 W
Power factor: 535
Power price: None
Leakage current: 8 A
Mode: PowerMode.Normal
WiFi LED: None

@syssi
Copy link
Collaborator

syssi commented Jun 11, 2018

Good to know. In this case it's hard to improve the behaviour. Are you able to request all properties (one by one) if you block the internet? I could implement a fallback here. If the request of the property list fails the values are retrieved one by one.

@AlbrtoSam
Copy link
Author

No, i think this is a issue regarding powerstrip, if i request one property i get an empy value just []. Let me check on wireshark what behaviour the powerstrip has.

Thank you so much !!!!

@syssi
Copy link
Collaborator

syssi commented Jun 11, 2018

You are welcome! Please close the issue if it's solved.

@valpackett
Copy link
Contributor

Just hit the same [,,,,,,,] problem after moving the powerstrip onto a LAN-only VLAN. Started investigating.

So Dustcloud can emulate the MiIO cloud. I don't have cloud keys (which are different from tokens), so I'm running a janky modified dustcloud server that can't even proxy anything to the cloud — any "advanced" (non-ping) messages are not even processed due to checksum exceptions. And yet, just responding to pings on both UDP and TCP is enough to make it return the data again \o/ I'll release a much simpler fake cloud server soon.

@valpackett
Copy link
Contributor

@rytilahti
Copy link
Owner

@unrelentingtech feel free to create a PR to add it to the (newly created) related projects section (https://github.com/rytilahti/python-miio/blob/master/README.rst#other-related-projects) to make it easier to find :-) I wouldn't be surprised if that could also be useful for some other devices.

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

No branches or pull requests

4 participants