Dyson switch - Turned on, auto mode & speed selection

Hi @mgim,

This is what I have ended up with: (all toggle buttons)

screenshot.2020-02-13

This is the code in lovelace I used:

        - type: glance
          title: Dyson Fan Control
          entities:
            - entity: switch.fanpower
              tap_action:
                action: toggle
            - entity: switch.fan_auto
              tap_action:
                action: toggle
            - entity: switch.fan_night
              icon: mdi:weather-night
              tap_action:
                action: toggle
            - entity: switch.oscillation
              tap_action:
                action: toggle

I made a switch for each mode and then refer to the switch in lovelace.

switch:
  - platform: template
    switches:
      # DYSON FAN SWITCHES
      fanpower:
        friendly_name: "Fan Power"
        value_template: "{{ ( is_state('fan.living_room', 'on') or is_state_attr('fan.living_room', 'auto_mode', true)  )}}"
        turn_on:
          service: fan.turn_on
          data:
            entity_id: fan.living_room
        turn_off:
          service: fan.turn_off
          data:
            entity_id: fan.living_room
        icon_template: >
          {% if is_state('fan.living_room', 'on') or is_state_attr('fan.living_room', 'auto_mode', true) %}
            mdi:fan
          {% else %}
            mdi:minus-circle-outline
          {% endif %}
      oscillation:
        friendly_name: Oscillation
        value_template: "{{ ( is_state('fan.living_room', 'on') or is_state_attr('fan.living_room', 'auto_mode', true)  ) and is_state_attr('fan.living_room', 'oscillating', true) }}"
        turn_on:
          service: fan.oscillate
          data:
            entity_id: fan.living_room
            oscillating: true
        turn_off:
          service: fan.oscillate
          data:
            entity_id: fan.living_room
            oscillating: false
        icon_template: >
          {% if is_state('fan.living_room', 'on') or is_state_attr('fan.living_room', 'auto_mode', true) and is_state_attr('fan.living_room', 'oscillating', true) %}
            mdi:cached
          {% else %}
            mdi:minus-circle-outline
          {% endif %}
      fan_night:
        friendly_name: "Night Mode"
        value_template: "{{ ( is_state('fan.living_room', 'on') or is_state_attr('fan.living_room', 'auto_mode', true)  ) and is_state_attr('fan.living_room', 'night_mode', true) }}"
        turn_on:
          service: dyson.set_night_mode
          data:
            entity_id: fan.living_room
            night_mode: true
        turn_off:
          service: dyson.set_night_mode
          data:
            entity_id: fan.living_room
            night_mode: false
        icon_template: >
          {% if is_state('fan.living_room', 'on') and is_state_attr('fan.living_room', 'night_mode', true) %}
            mdi:weather-night
          {% else %}
            mdi:minus-circle-outline
          {% endif %}
      fan_auto:
        friendly_name: "Auto Mode"
        value_template: "{{ is_state_attr('fan.living_room', 'auto_mode', true) }}"
        turn_on:
          service: dyson.set_auto_mode
          data:
            entity_id: fan.living_room
            auto_mode: true
        turn_off:
          service: dyson.set_auto_mode
          data:
            entity_id: fan.living_room
            auto_mode: false
        icon_template: >
          {% if is_state_attr('fan.living_room', 'auto_mode', true) %}
            mdi:brightness-auto
          {% else %}
            mdi:minus-circle-outline
          {% endif %}
1 Like

Perfect! That is sooo useful! Here is my UI now.

If Dyson is off:
image

If Dyson is on:

1 Like

Oh nice, that looks good! Are you able to post yours as well? I might use some of it :slight_smile:

Sure!

For the card:

cards:
  - entity: switch.dyson_fan_power
    hold_action:
      action: more-info
    icon: 'mdi:fan'
    name: Dyson
    show_icon: true
    show_name: true
    tap_action:
      action: toggle
    type: entity-button
  - card:
      cards:
        - entities:
            - entity: input_number.dyson_fan_speed
              name: Fan speed
          type: entities
        - entities:
            - entity: switch.dyson_auto_mode
              icon: 'mdi:brightness-auto'
              name: Auto
              tap_action:
                action: toggle
            - entity: switch.dyson_night_mode
              icon: 'mdi:weather-night'
              name: Night
              tap_action:
                action: toggle
            - entity: switch.dyson_oscillation
              name: Oscillate
              tap_action:
                action: toggle
          type: glance
        - control:
            hvac: true
          decimals: 0
          entity: climate.dyson
          hide:
            state: true
          label:
            temperature: Bedroom
          name: false
          sensors:
            - entity: sensor.paris_02e_arrondissement_temperature
              name: Paris
            - entity: sensor.meross_1_daily_cost
              name: Today
          step_size: 1
          type: 'custom:simple-thermostat'
      type: 'custom:vertical-stack-in-card'
    conditions:
      - entity: switch.dyson_fan_power
        state: 'on'
    type: conditional
type: 'custom:vertical-stack-in-card'

input number for fan speed

# inputnumber to control dyson fan speed on UI
  dyson_fan_speed:
    name: Dyson fan speed
    min: 1
    max: 10
    step: 1
    icon: mdi:fan

and the related automations:

- id: '1581251639556'
  alias: Dyson fan speed controller
  description: ''
  trigger:
  - entity_id: input_number.dyson_fan_speed
    platform: state
  condition: []
  action:
  - data_template:
      speed: '{{states(''input_number.dyson_fan_speed'')|int}}'
    entity_id: fan.dyson
    service: fan.set_speed
- id: '1581284638564'
  alias: Update Dyson UI controllers
  description: ''
  trigger:
  - entity_id: fan.dyson
    platform: state
    to: 'on'
  condition: []
  action:
  - data_template:
      value: '{{state_attr(''fan.dyson'', ''speed'')}}'
    entity_id: input_number.dyson_fan_speed
    service: input_number.set_value

There is maybe a way to improve the fan speed controller automation but it works for now.

1 Like

Great, thanks @mgim . I was thinking of implementing the speed controller, making it an conditional entry and only displayed when the fan is not in auto mode. I will have a go at that :slight_smile:

1 Like

@mgim What do the id numbers do in the automation’s?

Nothing. They are automatically generated when using the configuration ui for automation

Ah ok, thanks @mgim

So after looking at yours, now I have modified mine so that it shows the speed slider when it is turned on normal mode:

screenshot.2020-02-16

Then the slider goes away when it is turned on auto mode:

screenshot.2020-02-16b