opened
ekkljs
username_0
Just connected a zhimi.fan.sa1 to HA 0.94. Able to control fan speed and turn off&on fan natural mode. Can't figure out how to turn on&off oscillating and adjust angles. Can someone to share configurations.yaml file? In the end I'd like to go automation but I'd like to know how it works first. Many thanks!
Tutorial?
issue
created
syssi
username_1
The "fan card" just provides your mentioned features. To turn on/off f.e. oscillation you can go to the `/dev-service` panel. Just click on the remote control symbol at the bottom left corner. Select a service (`fan.oscillate`), select your fan entity and extend the JSON object by `oscillating: True`:

```
{
  "entity_id": "fan.your_fan_entity",
  "oscillating": True
}
```

![dev-service](https://user-images.githubusercontent.com/2735933/59252646-d1557880-8c2c-11e9-8b83-d9a28e034e7a.png)

That's all.
comment
created
ekkljs
username_0
Thank for detail explanation! I should be more clear on the question. I'd like to know how it could be implemented on configuration.yaml. :)
comment
created
syssi
username_1
What do you want to implement? An automation or a template switch for some services?
comment
created
ekkljs
username_0
It would be nice if you could show me how to turn on&off oscillating and adjust angles through an automation or a template switch.
comment
created
syssi
username_1
Please read the HA documentation. It's everthing there. For example:

```
# https://www.home-assistant.io/cookbook/automation_sun/
automation:
  trigger:
    platform: sun
    event: sunset
    offset: "-00:45:00"
  action:
    service: fan.oscillate
    entity_id: fan.your_fan_entity
    data:
        oscillating: true
```

```
# Use a script for open loop actions
script:
  fan_move_left:
    can_cancel: false
    alias: "Move left"
    sequence:
      - service: fan.set_direction
        entity_id: fan.your_fan_entity
        data:
          direction: 'left'
  fan_move_right:
    can_cancel: false
    alias: "Move right"
    sequence:
      - service: fan.set_direction
        entity_id: fan.your_fan_entity
        data:
          direction: 'right'
```

```
# https://www.home-assistant.io/components/switch.template/
switch:
  - platform: template
    switches:
      fan_buzzer:
        value_template: "{{ is_state_attr('fan.your_fan_entity', 'buzzer', 'on') }}"
        turn_on:
          service: fan.xiaomi_miio_set_buzzer_on
          entity_id: fan.your_fan_entity
        turn_off:
          service: fan.xiaomi_miio_set_buzzer_off
          entity_id: fan.your_fan_entity
```
comment
created
ekkljs
username_0
Thank you. Actually following one I was trying to apply for the oscillating switch.  Do you know why it won't work? 

      smart_mi_fan_oscllating_switch:
        value_template: "{{ (states.fan.fan_wire.state == 'on')  }}"
        turn_on:
          service: fan.oscillate
          data:
            entity_id: fan.fan_wire
            oscillating: true
        turn_off:
          service: fan.oscillate
          data:
            entity_id: fan.fan_wire
            oscillating: false
comment
created
syssi
username_1
You are using the `state` of the fan (power on/off) as indicator for the current state of oscillate. You've to use the attribute `oscillate` instead: 

```
switch:
  - platform: template
    switches:
      fan_oscillate:
        value_template: "{{ is_state_attr('fan.fan_wire', 'oscillate', 'on') }}"
        turn_on:
          service: fan.oscillate
          entity_id: fan.fan_wire
          data:
            oscillating: true
        turn_off:
          service: fan.oscillate
          entity_id: fan.fan_wire
          data:
            oscillating: false
```
comment
created
ekkljs
username_0
Oh Ok! Now oscillate can be turned on. But the switch goes to "off" in a few sec. Thus there is no way I could turn off oscillate with this switch. How do I make this switch to used for "turn off" as well?
comment
created
syssi
username_1
In this case the `value_template` doesn't work. Could you test this part 

```
{{ is_state_attr('fan.fan_wire', 'oscillate', 'on') }}
```

at the `template` page?
comment
closed
syssi
username_1
issue