syssi / xiaomi_raw

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

fix default_properties by enter order #15

Open titanfox88 opened 3 years ago

titanfox88 commented 3 years ago

enter order is default_properties:

titanfox88 commented 3 years ago

wrong order log 2021-03-01 00:20:36 DEBUG (SyncWorker_5) [miio.miioprotocol] 192.168.31.120:54321 >>: {'id': 3, 'method': 'get_prop', 'params': ['appointEnd', 'errStatus', 'hotWater', 'needClean', 'washStatus', 'modeType', 'velocity', 'targetTemp', 'appointStart', 'waterTemp']}

2021-03-01 00:20:37 DEBUG (SyncWorker_5) [miio.miioprotocol] 192.168.31.120:54321 (ts: 1970-02-07 23:20:10, id: 3) << {'id': 3, 'error': {'code': -9998, 'message': 'user ack invalid'}, 'exe_time': 330} right order log

2021-02-25 20:29:37 -> {"id":6881,"method":"get_prop","params":["washStatus","velocity","waterTemp","targetTemp","errStatus","hotWater","needClean","modeType","appointStart","appointEnd"]} 2021-02-25 20:29:37 <- {"code":0,"exe_time":900,"id":6881,"net_cost":175,"ot_cost":19047,"otlocalts":1614256178122844,"result":[2,0,74,75,0,100,0,1,22,3]}

countrysideboy commented 3 years ago

me too

blakadder commented 3 years ago

Same issue.

Default properties list gets sorted alphabetically which in my case generates and error on get_prop. Device requires a specific get_prop value in the first place.

To make the bug more interesting I have created a configuration like this

  - platform: xiaomi_miio_raw
    name: xjx_tunwash
    <<: *deviceinfo
    sensor_property: "status_tunwash"
    default_properties_getter: "get_prop"
    default_properties: ["water_temp_t","water_strong_t","water_pos_t","moving","massage"]

which manages to send get_prop successfuly where sensor_propery is first then default_properties get sorted alphabetically

{'id': 418, 'method': 'get_prop', 'params': ['status_tunwash', 'moving', 'massage', 'water_temp_t', 'water_pos_t', 'water_strong_t']}

but the returned values are assigned to properties according to alphabetical order.

Furthermore...

If I add another sensor before it with same requirements, it starts to order the list alphabetically again for the sensor below:

Further
  - platform: xiaomi_miio_raw
    name: xjx_dry
    <<: *deviceinfo
    sensor_property: "status_warmdry"
    default_properties_getter: "get_prop"
    default_properties: ["fan_temp"]

  - platform: xiaomi_miio_raw
    name: xjx_tunwash
    <<: *deviceinfo
    sensor_property: "status_tunwash"
    default_properties_getter: "get_prop"
    default_properties: ["water_temp_t","water_strong_t","water_pos_t","moving","massage"]

logs result

 {'id': 207, 'method': 'get_prop', 'params': ['status_warmdry', 'fan_temp']}
 {'id': 409, 'method': 'get_prop', 'params': ['water_temp_t', 'moving', 'massage', 'water_pos_t', 'status_tunwash', 'water_strong_t']}