Dyson switch - Turned on, auto mode & speed selection

Entity buttons do not support icon templates, see the documents for supported options:

So just create another switch entry like the others for this?

That’s one way. There are other custom cards you can use to modify Lovelace but I’d stick with what you know for now.

You mean stick with what you know ? ha

      fanpower:
        friendly_name: "Fan Power"
        value_template: "{{ ( is_state('fan.bedroom', 'on') or is_state_attr('fan.bedroom', 'auto_mode', true)  )}}"
        turn_on:
          service: fan.turn_on
          data:
            entity_id: fan.bedroom
            **oscillating: true**
        turn_off:
          service: fan.turn_off
          data:
            entity_id: fan.bedroom
            **oscillating: false**
        icon_template: >
          {% if is_state('fan.bedroom', 'on') or is_state_attr('fan.bedroom', 'auto_mode', true) %}
            mdi:fan
          {% else %}
            mdi:minus-circle-outline
          {% endif %}

I’ve changed most of one of the switches I already have. Except, the oscillating part (true/false) is wrong. The command fan.turn_on and fan.turn_off is just a service that you call and does not appear to have any value to input there

For those interested. It appears that solution for that part was:

      fanpower:
        friendly_name: "Fan Power"
        value_template: "{{ ( is_state('fan.bedroom', 'on') or is_state_attr('fan.bedroom', 'auto_mode', true)  )}}"
        turn_on:
          service: fan.turn_on
          data:
            entity_id: fan.bedroom
        turn_off:
          service: fan.turn_off
          data:
            entity_id: fan.bedroom
        icon_template: >
          {% if is_state('fan.bedroom', 'on') or is_state_attr('fan.bedroom', 'auto_mode', true) %}
            mdi:fan
          {% else %}
            mdi:minus-circle-outline
          {% endif %}

Next on my list is to get the fan speed sensor to select the speed on click. I will do some searching to work out which tap_action that will be.

Once I have that done, I should be done and I can post the whole lot for anyone interested :slight_smile:

1 Like

Have a read of this:

For me the Oscillation switch is in the entity. Also the speed selection. I don‘t need to create separate switches.

It looks like the Dyson fan integration isn’t reporting the correct state when it is in ‘auto’ mode. How do I report that for the team to look at?

@Krocko So what is the code for you from those screenshots?

It is the Dyson integration.

But for that are you just using this to display it in lovelace?

            - entity: fan.bedroom
              name: Fan

Don‘t understand, sorry.
I have added the fan to an entity card.
This is the 'more info‘ view. You get this, if you tap on the entity name (not the toggle) in this card.

The screenshot you posted. Is that after you click something? If so, what code in Lovelace have you used to get that card

Thank you! Indeed your works is very interesting!

Hi @DrSpaldo, have you made some progress over this?
Have you also created switches or at least UI buttons for night mode and auto mode?

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