Support get_prop ['all']
anhnvme opened this issue · 18 comments
Hello,
I'm trying get all data from yunmi.waterpuri.lx11 (Xiaomi Water Purifier) but with xiaomi_raw data, it's show only one value instead ull valued
Example, It's only show: 0,
It's should be: 0, 7200, 8640, 770, 1041, 7200, 17280, 380, 1057, 80, 10, 0, 29, 100, 7200, 8640, 380, 1057
Or, can you write a addon for this device ? i have get full attribute here:
rytilahti/python-miio#692
Thanks you @syssi
@anhnvme
Hi, you can use the addon here for the yunmi.waterpuri.lx11.
小米净水器C1 三出水可以用这个插件:
https://github.com/ptbsare/homeassistant-mi-water-purifier
@anhnvme
Hi, you can use the addon here for the yunmi.waterpuri.lx11.
小米净水器C1 三出水可以用这个插件:
https://github.com/ptbsare/homeassistant-mi-water-purifier
Wow, thanks you so much !!!!!
@anhnvme
Hi, you can use the addon here for the yunmi.waterpuri.lx11.
小米净水器C1 三出水可以用这个插件:
https://github.com/ptbsare/homeassistant-mi-water-purifier
2020-11-22 07:26:47 ERROR (SyncWorker_22) [custom_components.mi_water_purifier.sensor] Fail to get_prop from Xiaomi water purifier
Traceback (most recent call last):
File "/config/custom_components/mi_water_purifier/sensor.py", line 172, in parse_data
get_all = self._device.send('get_prop', ["all"])
File "/usr/local/lib/python3.8/site-packages/miio/device.py", line 143, in send
return self._protocol.send(
File "/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py", line 213, in send
self._handle_error(payload["error"])
File "/usr/local/lib/python3.8/site-packages/miio/miioprotocol.py", line 273, in _handle_error
raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -9999, 'message': 'user ack timeout'}
Looklike it's not work with xiaomi C1
@anhnvme This is normal when the device has poor wifi connection. Try send raw command get_prop ['all'] using miio cli and post the result here.
Some devices responses with "user ack timeout" if you request invalid/unsupported properties. If you have a yunmi.waterpuri.lx11
this doesn't apply for you. The property all
is supported here.
@anhnvme Each xiaomi_raw sensor can only has one property as state, other peoperties can be found as property. If you want to direct show properties in HA, you can wrap them with template.
Is any help or enhancement needed here? Normally a list of properties is retrieved, so every retrieved property can be added as attribute to the sensor. This case is an edge-case because a bunch of (unnamed) properties is retrieved by the keyword "all". If these unnamed properties should be added as attributes they must get a name (f.e. all0, all1, all2, all3 or something else generic). The configuration of the custom component shouldn't get to complex here.
@anhnvme Please give it a try. As @lovelylain said you can add a template sensor for every attribute now.
Hello,
I'm get error on get multi attribute
2020-11-25 10:03:22 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.any_xiaomi_miio_device fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
raise exc
File "/config/custom_components/xiaomi_miio_raw/sensor.py", line 276, in async_update
self._state = state.get(self._sensor_property)
UnboundLocalError: local variable 'state' referenced before assignment
2020-11-25 10:03:52 ERROR (MainThread) [custom_components.xiaomi_miio_raw.sensor] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}
2020-11-25 10:03:52 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.any_xiaomi_miio_device fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
raise exc
File "/config/custom_components/xiaomi_miio_raw/sensor.py", line 276, in async_update
self._state = state.get(self._sensor_property)
UnboundLocalError: local variable 'state' referenced before assignment
2020-11-25 10:04:22 ERROR (MainThread) [custom_components.xiaomi_miio_raw.sensor] Got exception while fetching the state: {'code': -9999, 'message': 'user ack timeout'}
2020-11-25 10:04:22 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.any_xiaomi_miio_device fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
raise exc
File "/config/custom_components/xiaomi_miio_raw/sensor.py", line 276, in async_update
self._state = state.get(self._sensor_property)
UnboundLocalError: local variable 'state' referenced before assignment```
My config
- platform: xiaomi_miio_raw
name: Any Xiaomi MiIO device
host: 192.168.1.xx
token: xxxx
sensor_property: 'tds_out'
default_properties_getter: 'get_prop'
default_properties:- f3_usedtime
- f2_usedtime
Thank you
@anhnvme Some models doesn't support a list of properties, while fetching them one
per time usually runs into "ack timeout" error. Thus fetch them all at one
time.
Key "mode" (always 'purifying') and key "tds_out_avg" (always 0) are not
included in return values.
"""
values = self.send("get_prop", ["all"])
see here for details:
https://github.com/rytilahti/python-miio/blob/fcb95a3a048dc959f5e8707f0e1952514d65ef2e/miio/waterpurifier_yunmi.py#L360
@anhnvme Try send raw command get_prop ['all'] using miio cli and post the result here.
I've fixed this issue:
UnboundLocalError: local variable 'state' referenced before assignment
But @ptbsare is on the right track. If get_prop ['all']
is more stable as get_prop ['tds_out', 'f3_usedtime', 'f2_usedtime']
you should use all
.
Some details about the yunmi.waterpuri.*
devices:
The react native app (mihome plugin) retrieves the following properties:
# yunmi.waterpuri.lx5
# yunmi.waterpuri.lx7
# yunmi.waterpuri.lx9
# yunmi.waterpuri.lx10
# yunmi.waterpuri.lx11
# yunmi.waterpuri.lx12
["run_status", "f1_totaltime", "f1_usedtime", "f2_totaltime", "f2_usedtime", "tds_in", "tds_out", "rinse", "temperature", "tds_warn_thd"]
# yunmi.waterpuri.lx10
["run_status", "f1_totaltime", "f1_usedtime", "f2_totaltime", "f2_usedtime", "tds_in", "tds_out", "rinse", "temperature", "tds_warn_thd"] + ["f3_totaltime", "f3_usedtime", "uv_working"]
# yunmi.waterpuri.lx9
# yunmi.waterpuri.lx10
# yunmi.waterpuri.lx11
# yunmi.waterpuri.lx12
["run_status", "f1_totaltime", "f1_usedtime", "f2_totaltime", "f2_usedtime", "tds_in", "tds_out", "rinse", "temperature", "tds_warn_thd"] + ["f3_totaltime", "f3_usedtime"]
## dead code path
## yunmi.waterpurifier.v1
## yunmi.waterpurifier.v2
## yunmi.waterpurifier.v3
## yunmi.waterpuri.lx2
## yunmi.waterpuri.lx3
## yunmi.waterpuri.lx4
## yunmi.waterpuri.lx6
## yunmi.waterpuri.lx8
# ["run_status", "f1_totaltime", "f1_usedtime", "f2_totaltime", "f2_usedtime", "tds_in", "tds_out", "rinse", "temperature"] + ["f3_totaltime", "f3_usedtime", "uv_working"]
# supportPlMachine
+ ["plmachine"]
# yunmi.waterpurifier.v1
# yunmi.waterpurifier.v2
# yunmi.waterpurifier.v3
# yunmi.waterpuri.lx2
# yunmi.waterpuri.lx3
# yunmi.waterpuri.lx4
# yunmi.waterpuri.lx6
# yunmi.waterpuri.lx8
[]