Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Natural speed Homekit switch #137

Open
kristofferR opened this issue Jun 8, 2021 · 5 comments
Open

Natural speed Homekit switch #137

kristofferR opened this issue Jun 8, 2021 · 5 comments

Comments

@kristofferR
Copy link

Thanks for the great plugin, got my new Xiaomi Pedestal 2S fan set up in HA/HomeKit in no time with it.

However, I really like the natural mode of the fan, and would like to switch between it and constant speed using a HomeKit switch(like the presets I disabled were).

How do I create such a switch, so I can toggle Natural mode through HomeKit/Siri? I'd still like to use the speed slider.

@TDK2525
Copy link

TDK2525 commented Jul 11, 2021

Id love to figure this out too!

@damianpasek
Copy link

Here is the solution which I'm using, custom switch using template. Later on you can expose the switch to Homekit. Maybe this will help you 🙂

- platform: template
  switches:
    bedroom_fan_natural:
      friendly_name: "Bedroom Fan Natural Mode"
      icon_template: mdi:weather-windy
      value_template: >- 
        {{ state_attr('fan.bedroom_fan', 'natural_speed')|int > 0 }}
      turn_on:
        service: xiaomi_miio_fan.fan_set_natural_mode_on
        data:
          entity_id: fan.bedroom_fan
      turn_off:
        service: xiaomi_miio_fan.fan_set_natural_mode_off
        data:
          entity_id: fan.bedroom_fan

@TDK2525
Copy link

TDK2525 commented Jul 18, 2021

Here is the solution which I'm using, custom switch using template. Later on you can expose the switch to Homekit. Maybe this will help you 🙂

- platform: template
  switches:
    bedroom_fan_natural:
      friendly_name: "Bedroom Fan Natural Mode"
      icon_template: mdi:weather-windy
      value_template: >- 
        {{ state_attr('fan.bedroom_fan', 'natural_speed')|int > 0 }}
      turn_on:
        service: xiaomi_miio_fan.fan_set_natural_mode_on
        data:
          entity_id: fan.bedroom_fan
      turn_off:
        service: xiaomi_miio_fan.fan_set_natural_mode_off
        data:
          entity_id: fan.bedroom_fan

Thank you so much for sharing and I apologize in advance for my n00b (just started on my Home Assistant journey :)) follow-up questions:

I assume that I need to put this into my configuration.yaml right? When I do that I get the following error when trying to restart home assistant, and I cannot figure out what I need to change to fix it:

Failed to call service homeassistant/restart. The system cannot restart because the configuration is not valid: Error loading /config/configuration.yaml: while parsing a block mapping in "/config/configuration.yaml", line 3, column 1 expected , but found '-' in "/config/configuration.yaml", line 26, column 1

Line 26 in my config file is the - platform: template line

Any tips on what I need to change?

@TDK2525
Copy link

TDK2525 commented Jul 28, 2021

I figure it out, I found a prior example to what was pasted here and I could see that there was a missing line, so if anyone else finds this post then add a line at the top with "switch:" in it to the above code and put it in your configuration.yaml file and then it should work.

@NewsGuyTor
Copy link

The problem with this code is that it creates a totally different switch which isn't grouped with the fan. Creating grouped switches is clearly possible somehow, as the preset mode switches demonstrates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants