Mi Smart Pedestal Fan

Hi, I thought I had exactly this fan but it is discovered as “zhimi.fan.sa1”. Is it a different fan?

Yes. It’s a new(?) model.

Hi syssi, you are right. It became obvious when I had problems running it in battery mode - as there is no battery :smiley:
There is only little information but it seems to be a new 2018 version.
Be careful if ordering such a fan, Gearbest states it has a built-in battery which it has not.

I read of a cheaper version of the fan. Is this it? How much did you end up paying for this?

It is this one:

https://m.gearbest.com/other-home-improvement/pp_009920834265.html?wid=1433363

Meanwhile they changed the description but it said Built-in battery, which it has not. Price was 140USD.
I just have a discussion with GB Support, they offer a 30USD refund but in my opinion it is still too expensive. It is quite silent, though.

Hi all,
Got myself one of these cheaper, battery-less fans @99USD including shipping… Think I got a good rate as it is now 30% more on Aliexpress. Lucky!
Anyways, this works great, except in Home Assistant. Got the token and tried to set it up the same way as the air purifier (zhimi.airpurifier.v6) or the battery version of this fan (zhimi.fan.v3). This one (zhimi.fan.sa1) will not be recognised by HA 75.2. Token is right, so is IP.
I’ve installed the latest miio python as advised on GitHub.
It looks like @syssi is hard at work and a solution may be found soon. Thanks for the efforts!

i have Xiaomi Smart Fan version zhimi.fan.v2 but after instert in config.yaml this string
fan:

  • platform: xiaomi_miio_fan
    name: Xiaomi Smart Fan
    host: xxx.xxx.xxx.xxx
    token: b7c4a758c251955d2c24b1d9e41ce47d
    not appear nothing on home page of home assistant.
    where could i found on HA the Smart Fan?
    I have already created the [custom_components/fan]
    this is log
    2018-08-23 17:38:05 ERROR (MainThread) [homeassistant.components.fan] xiaomi_miio_fan: Error on device update!
    Traceback (most recent call last):
    File “/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
    File “/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 320, in async_device_update
    yield from self.async_update()
    File “/home/homeassistant/.homeassistant/custom_components/fan/xiaomi_miio_fan.py”, line 433, in async_update
    key, value in self._available_attributes.items()})
    File “/home/homeassistant/.homeassistant/custom_components/fan/xiaomi_miio_fan.py”, line 433, in
    key, value in self._available_attributes.items()})
    File “/home/homeassistant/.homeassistant/custom_components/fan/xiaomi_miio_fan.py”, line 297, in _extract_value_from_attribute
    value = getattr(state, attribute)
    File “/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/miio/fan.py”, line 178, in button_pressed
    KeyError: ‘button_pressed’

thankyou very much

Hi syssi:

I’m new to HA, using zhimi.fan.sa1 with your xiaomi_fan component, great work!

I would like to create a switch to control the nature wind mode in HA UI (and thus Homekit)
and I tried to modify the instruction here to fit in your component:
smart_mi_fan

however, it’s not working. Would you please give me some help? Thanks!

my yaml:

fan:
  - platform: xiaomi_miio_fan
    name: bedroom_fan
    host: 192.168.1.32
    token: !secret mi_fan_token

switch:
  - platform: template
    switches:
      Bedroom_fan_natural_wind:
        value_template: "{{ (states.fan.bedroom_fan.state == 'on') and (states.fan.bedroom_fan.attributes.natural_speed != 0) }}"
        turn_on:
          service: fan.xiaomi_miio_set_natural_mode_on
          data: 
            entity_id: switch.Bedroom_fan_natural_wind_on
        turn_off:
          service: fan.xiaomi_miio_set_natural_mode_off
          data: 
            entity_id: switch.Bedroom_fan_natural_wind_off    

Error log:
2018-08-26 03:32:14 ERROR (MainThread) [homeassistant.config] Invalid config for [switch.template]: [Bedroom_fan_natural_wind] is an invalid option for [switch.template]. Check: switch.template->switches->Bedroom_fan_natural_wind. (See ?, line ?). Please check the docs at https://home-assistant.io/components/switch.template/

(ps. I have tried to delete the “data” under service, but the error remained)

Your entity_id is wrong. What’s the entity_id of your fan? It must be used in both cases.

strange! still not working after adding entity_id, same error message

switch:
  - platform: template
    switches:
      Bedroom_fan_natural_wind:
        value_template: "{{ (states.fan.bedroom_fan.state == 'on') and (states.fan.bedroom_fan.attributes.natural_speed != 0) }}"
        turn_on:
          service: fan.xiaomi_miio_set_natural_mode_on
          data:
            entity_id: fan.bedroom_fan
        turn_off:
          service: fan.xiaomi_miio_set_natural_mode_off
          data:
            entity_id: fan.bedroom_fan

I will try to reproduce the problem tonight. It’s a config issue and unrelated to the used (custom) component.

i’ve notice that sometimes HA not load at start custom component. there are some solution?

Btw: Do you have plans to integrate this custom
component into the home assistant component already supporting the air purifier?

2 Likes

Solved! The problem is explained in Templete Switch manual:

Considerations

If you are using the state of a platform that takes extra time to load, the Template Switch may get an unknown state during startup. This results in error messages in your log file until that platform has completed loading. If you use is_state() function in your template, you can avoid this situation. For example, you would replace {{states.switch.source.state == 'on' }} with this equivalent that returns true / false and never gives an unknown result: {{ is_state('switch.source', 'on') }}

So it finally works after changing to:

switches:
  bedroom_fan_natural_wind:
    value_template: "{{ is_state('fan.bedroom_fan', 'on') and not(is_state_attr('fan.bedroom_fan', 'natural_speed', 0)) }}"
    turn_on:
      service: fan.xiaomi_miio_set_natural_mode_on
      data:
        entity_id: fan.bedroom_fan
    turn_off:
      service: fan.xiaomi_miio_set_natural_mode_off
      data:
        entity_id: fan.bedroom_fan

But I met another problem: the fan seemed turned off itself after calling the fan.xiaomi_miio_set_natural_mode_off service, for no reason, no error log.

(edited: adding the new problem)

Please open an issue at the xiaomi_fan repo.

hi, i tried to add my zhimi.fan.za1 to the config as shown above. However i am not able to control (ie. turn on or turn off ) it from HA.

I have used the mi home app method to extract the token but I realized that the zhimi fan token always change when i extract it. I did the extraction 3 times and different token value appeared on each time. Though this method works for other xiaomi device.

Can someone share how to extract the zhimi fan token to make it work? Thanks

@syssi sorry I have been renovating and this little fan has been in the garage for a few months. Is this component still requiring some testing support? I have it all back up and running again.

Did all you geniuses find a way to make the sa1 model work well in Hass?
Also, is this now a standard implementation in Hass or still a custom component?
I’m struggling as hell with this model when the zha1 works perfectly.

@jimpower: love your custom Lovelace state card. Care to share?