My Xiaomi Smartmi Standing Fan 3 (zhimi.fan.za5) is not supported at the moment. It would be great if this fan could be added to the integration.
Please ping me on Discord Bieniu#4759
.
First test version: Upload files for free - xiaomi_miio_za5.zip - ufile.io
Please extract xiaomi_miio
folder to /config/custom_components
folder, add this:
logger:
default: error
logs:
custom_components.xiaomi_miio: debug
to the configuration.yaml
file and restart HA.
Now you can try to configure the fan via Configuration → Integrations.
@Bieniu I’ve added the custom component and I’m able to control the Xiaomi fan. That’s great, thank you!
I can control the speed, mode (nature / normal) and toggle oscillating mode. It would be great if the oscillating angle could be setup by the component (30/60/90/120 degrees).
Please show me the log.
@Bieniu
There’s nothing in the log about xiaomi
. I think you made a typo xiami_miio
should be xiaomi_miio
, but even with this nothing shows up in the log file.
Yes, should be custom_components.xiaomi_miio: debug
. With this you should find in the log lines that start with “Got new state”.
Please show me entities created for this fan (Configuration → Integrations) and the fan entity from Developer tools → States.
@Bieniu I’ve restarted Home Assistance again and now I got something in the log:
2021-09-19 22:22:00 DEBUG (MainThread) [custom_components.xiaomi_miio] Initializing with host 192.168.1.47 (token 67a10...)
2021-09-19 22:22:01 DEBUG (MainThread) [custom_components.xiaomi_miio] Got new state: <FanStatusZA5 angle=30 battery_supported=False buttons_pressed=None buzzer=False child_lock=False delay_off_countdown=0 fan_level=1 fan_speed=15 humidity=53 ionizer=True is_on=False led_brightness=100 mode=OperationMode.Nature oscillate=True power=off powersupply_attached=True speed_rpm=0 temperature=21.6>
2021-09-19 22:22:01 DEBUG (MainThread) [custom_components.xiaomi_miio] Finished fetching Smartmi Standing Fan 3 data in 1.291 seconds (success: True)
2021-09-19 22:23:01 DEBUG (MainThread) [custom_components.xiaomi_miio] Got new state: <FanStatusZA5 angle=30 battery_supported=False buttons_pressed=None buzzer=False child_lock=False delay_off_countdown=0 fan_level=1 fan_speed=15 humidity=53 ionizer=True is_on=False led_brightness=100 mode=OperationMode.Nature oscillate=True power=off powersupply_attached=True speed_rpm=0 temperature=21.6>
2021-09-19 22:23:01 DEBUG (MainThread) [custom_components.xiaomi_miio] Finished fetching Smartmi Standing Fan 3 data in 0.561 seconds (success: True)
2021-09-19 22:23:07 DEBUG (MainThread) [custom_components.xiaomi_miio.device] Response received from miio device: [{'did': 'power', 'siid': 2, 'piid': 1, 'code': 0}]
2021-09-19 22:23:18 DEBUG (MainThread) [custom_components.xiaomi_miio.device] Response received from miio device: [{'did': 'fan_speed', 'siid': 6, 'piid': 8, 'code': 0}]
This entity is created:
And this is the info from the developer tools → states:
speed_list: off, low, medium, high, Normal, Nature
preset_modes: Normal, Nature
direction: null
oscillating: true
speed: Nature
percentage: 17
percentage_step: 1
preset_mode: Nature
model: zhimi.fan.za5
friendly_name: Smartmi Standing Fan 3
supported_features: 15
Test version 2 Upload files for free - xiaomi_miio_za5_v2.zip - ufile.io
I added sensor, switch and number platform. Please manipulate switch and number entities and post here a log.
@Bieniu
The manifest.json file did not contain a valid version so I’ve added it manually. After that the component is loaded but gives an error:
2021-09-20 16:45:08 DEBUG (MainThread) [custom_components.xiaomi_miio] Initializing with host 192.168.1.47 (token 67a10...)
2021-09-20 16:45:09 DEBUG (MainThread) [custom_components.xiaomi_miio] Got new state: <FanStatusZA5 angle=30 battery_supported=False buttons_pressed=None buzzer=False child_lock=False delay_off_countdown=0 fan_level=1 fan_speed=17 humidity=49 ionizer=True is_on=False led_brightness=100 mode=OperationMode.Nature oscillate=True power=off powersupply_attached=True speed_rpm=0 temperature=22.3>
2021-09-20 16:45:09 DEBUG (MainThread) [custom_components.xiaomi_miio] Finished fetching Smartmi Standing Fan 3 data in 0.950 seconds (success: True)
2021-09-20 16:45:09 ERROR (MainThread) [homeassistant.components.fan] Error while setting up xiaomi_miio platform for fan
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/media/data/.homeassistant/custom_components/xiaomi_miio/fan.py", line 204, in async_setup_entry
entity = XiaomiFanMiot(name, device, config_entry, unique_id, coordinator)
File "/media/data/.homeassistant/custom_components/xiaomi_miio/fan.py", line 769, in __init__
self._nature_mode = self.coordinator.data.natural_speed != 0
AttributeError: 'FanStatusZA5' object has no attribute 'natural_speed'
@Bieniu This version works fine. This is a part of the log file:
2021-09-20 20:40:35 DEBUG (MainThread) [custom_components.xiaomi_miio] Initializing with host 192.168.1.47 (token 67a10...)
2021-09-20 20:40:36 DEBUG (MainThread) [custom_components.xiaomi_miio] Got new state: <FanStatusZA5 angle=30 battery_supported=False buttons_pressed=None buzzer=False child_lock=False delay_off_countdown=0 fan_level=1 fan_speed=17 humidity=50 ionizer=True is_on=False led_brightness=100 mode=OperationMode.Nature oscillate=True power=off powersupply_attached=True speed_rpm=0 temperature=21.6>
2021-09-20 20:40:36 DEBUG (MainThread) [custom_components.xiaomi_miio] Finished fetching Smartmi Standing Fan 3 data in 0.945 seconds (success: True)
2021-09-20 20:41:18 DEBUG (MainThread) [custom_components.xiaomi_miio.device] Response received from miio device: [{'did': 'power', 'siid': 2, 'piid': 1, 'code': 0}]
2021-09-20 20:41:36 DEBUG (MainThread) [custom_components.xiaomi_miio] Got new state: <FanStatusZA5 angle=30 battery_supported=False buttons_pressed=None buzzer=False child_lock=False delay_off_countdown=0 fan_level=1 fan_speed=17 humidity=50 ionizer=True is_on=True led_brightness=100 mode=OperationMode.Nature oscillate=True power=on powersupply_attached=True speed_rpm=314 temperature=21.4>
2021-09-20 20:41:36 DEBUG (MainThread) [custom_components.xiaomi_miio] Finished fetching Smartmi Standing Fan 3 data in 0.756 seconds (success: True)
2021-09-20 20:42:00 DEBUG (MainThread) [custom_components.xiaomi_miio.device] Response received from miio device: [{'did': 'fan_speed', 'siid': 6, 'piid': 8, 'code': 0}]
2021-09-20 20:42:07 DEBUG (MainThread) [custom_components.xiaomi_miio.device] Response received from miio device: [{'did': 'power', 'siid': 2, 'piid': 1, 'code': 0}]
What entitities were created?
Do the number, switch and sensor entities work without errors?
These entities are created:
They all work fine. I’ve tested the temp/humidity, ionizer and oscillation angle and everything seems to works. Thanks!
Hi
Test version 5: Upload files for free - xiaomi_miio_za5_v5.zip - ufile.io
I added a binary sensor powersupply attached
and support for other MIOT models. Please test every entity.
@Bieniu I have tested all entities including the power attached sensor. These all work fine except changing the speed of the fan. When I drag the slider from left to right (to increase the fan speed) I get the following error message in the log:
2021-09-21 21:22:04 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140515856348592]
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
await hass.services.async_call(
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1492, in async_call
task.result()
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1527, in _execute_service
await handler.job.target(service_call)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_component.py", line 213, in handle_service
await self.hass.helpers.service.entity_service_call(
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/service.py", line 658, in entity_service_call
future.result() # pop exception if have
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 843, in async_request_call
await coro
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/service.py", line 695, in _handle_entity_call
await result
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/fan/__init__.py", line 290, in async_set_percentage
await self.async_set_speed(self.percentage_to_speed(percentage))
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/fan/__init__.py", line 275, in async_set_speed
await self.hass.async_add_executor_job(self.set_speed, speed)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/fan/__init__.py", line 242, in set_speed
raise NotImplementedError()
NotImplementedError
@Bieniu Thanks, I can confirm everything works fine now. Question: when the fan is turned off, the speed is displayed as 0. When I turn it on, the fan turns on immediately but the speed remains 0 for some time.
When I check the log I can see that it takes some time before I see a Got new state
line after powering the device. Is this something that can be fixed? Or is the state updated async?