syssi / xiaomi_raw

Custom component for Home Assistant to faciliate the reverse engeneering of Xiaomi MiIO devices
Apache License 2.0
107 stars 20 forks source link

Support for numeric parameters #9

Open ptbsare opened 3 years ago

ptbsare commented 3 years ago

The following command line works:

miiocli device --ip 192.168.1.12 --token XXX raw_command setPrepareDish "[5,6390]"

But when I set the following in the config:

  - platform: xiaomi_miio_raw
    name: 餐厅蒸烤箱预约
    host: 192.168.1.12
    token: XXX
    turn_on_command: "setPrepareDish"
    turn_on_parameters: [5, 6390]
    turn_off_command: "canclePrepare"
    turn_off_parameters: ""
    state_property: "prepareTime"
    state_property_getter: "get_prop"
    state_on_value: "0639"
    state_off_value: "0000"

From the log I can see that it sends the following instead:

2020-12-30 15:26:16 DEBUG (SyncWorker_5) [miio.miioprotocol] 192.168.1.112:54321 >>: {'id': 6, 'method': 'setPrepareDish', 'params': ['5’, ’6390’]}

What I want is sending the following:

{'id': 6, 'method': 'setPrepareDish', 'params': [5, 6390]}

What should I do?

I tried the config:

  - platform: xiaomi_miio_raw
    name: 餐厅蒸烤箱预约
    host: 192.168.1.12
    token: XXX
    turn_on_command: "setPrepareDish"
    turn_on_parameters: "[5, 6390]"
    turn_off_command: "canclePrepare"
    turn_off_parameters: ""
    state_property: "prepareTime"
    state_property_getter: "get_prop"
    state_on_value: "0639"
    state_off_value: "0000"

It sends the following parameters:

{'id': 6, 'method': 'setPrepareDish', 'params': ['[5, 6390]']}

Which is also incorrect. THANKS.

ptbsare commented 3 years ago

xiaomi_miio_raw.sensor_raw_command also works.

syssi commented 3 years ago

@rytilahti May I ask you about your support here? My python skills are pretty limited. Could you provide an example how to convert a string "[1,2,3]" to a list of integers?

rytilahti commented 3 years ago

Hey @syssi, check out ast.literal_eval() :-):

>>> import ast
>>> ast.literal_eval("[1,2,3]")
[1, 2, 3]
anhnvme commented 3 years ago

I have the same issue with xiaomi.aircondition.ma1. I can't not set "set_energysave" with params [1] to enable Eco mode