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 %}
3 Likes

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.

2 Likes

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

New HA user here so please bear with me. I have managed to get the dyson fan integrated and can control via the lovelace card.

image

When I toggle AUTO it turns the switch off. How can I control AUTO/NIGHT via the lovelace card?

Do i have to create a switch to toggle the boolean auto_mode or night_mode ?

switch:
  - platform: template
    switches:
      template_service_dyson_set_auto_mode_1:
        friendly_name: Bedroom Room Fan Auto Mode
        value_template: "{{ is_state_attr('fan.living_room', 'auto_mode', true) }}"
        turn_on:
          service: dyson.set_auto_mode
          data:
            entity_id: fan.bedroom
            auto_mode: true
        turn_off:
          service: dyson.set_auto_mode
          data:
            entity_id: fan.bedroom
            auto_mode: false

and created a lovelace card with


      - entity: fan.bedroom
        hold_action:
          action: more-info
        icon_height: 50px
        show_icon: true
        show_name: true
        show_state: true
        tap_action:
          action: call-service
          service: fan.set_auto_mode
          service_data:
            entity_id: fan.dyson_fan
            auto_mode: true
        type: button

When I toggle the button I get the error

Failed to call service/fan_set_auto_mode. Service not found

Hello DrSpaldo, could you show your code?

Thanks

@giangi007

Sorry for the delay, I am not getting post notifications. Which part were you after?

Ho DrSpaldo Iā€™m interesting for lovelace card part. Thanks

        - type: custom:vertical-stack-in-card
          cards:
          - type: conditional
            conditions:
            - entity: fan.master_bedroom
              state: 'on'
            card:
              entities:
                - entity: input_number.dyson_fan_speed
                  name: Dyson Fan Speed
              type: entities
          - type: glance
            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

Hello,

I cannot make the Fan Speed Controller (slider) to change the actual speed on the fan.
It only shows the current fan speed, which is nice but not enough for me :slight_smile:

I have set everything else up and that works like a charm.

Iā€™ve tried this but that has no effect.

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.kokken
    service: fan.set_speed
mode: single

Iā€™ve also tried this, as it seems like the Dyson.set_speed required the dyson_speed attribute. But still no luck.

action:
  - service: dyson.set_speed
    data:
      dyson_speed: '{{states(''input_number.dyson_fan_speed'')|int}}'
    entity_id: fan.kokken

Performing a call-service from developer tools with dyson.set_speed and dyson_speed: 5 DOES workā€¦ Just canā€™t make it work in the automation. Any ideas?

Do you have the input number set in your configuration.yaml?

input_number:
    dyson_fan_speed:
      name: Dyson fan speed
      min: 1
      max: 10
      step: 1
      icon: mdi:fan

You also need the automations that @mgim posted above.

Yes, Iā€™ve done that. And it is able to show the current fan speed and updates if I change the speed in the Dyson Link app. So the input_number slider works.

The automation that should perform the action does not work for me:
From @mgim.

- 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

(Yes I have corrected the entity id to my own)

Did you solve this problem?
Add two more space in front of ā€˜entity_id: fan.dysonā€™ then this automation will work correctly.

I did manage to find a solution by using Node-RED but I wasnā€™t really satisfied with that. Havenā€™t really looked at it since but just tried to add a few more spacesā€¦ Of course that worked :slight_smile:

Thanks for helping me out Chris.

I am completly new to Home Assistant but I would love to use a dyson card as above.
I know about the edit ui button and the cards list and entities being the valies thats about it.
So I would need to llearn how to do something like @DrSpaldo and @mgim
But no idea what I am meant to be doing with any configs apart from the dashboard editor.