Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 101899

Dyson switch - Turned on, auto mode & speed selection

$
0
0

@DrSpaldo wrote:

Recently @tom_l helped me in writing a switch for my Dyson fan. I have created a new topic as it is going down another path.

The switch he created was as follows:

switch:
  - platform: template
    switches:
      oscillation:
        friendly_name: Oscillation
        value_template: "{{ is_state('fan.bedroom', 'on') and is_state_attr('fan.bedroom', 'oscillating', true) }}"
        turn_on:
          service: fan.oscillate
          data:
            entity_id: fan.bedroom
            oscillating: true
        turn_off:
          service: fan.oscillate
          data:
            entity_id: fan.bedroom
            oscillating: false
        icon_template: >
          {% if is_state('fan.bedroom', 'on') and is_state_attr('fan.bedroom', 'oscillating', true) %}
            mdi:arrow-left-right-bold
          {% else %}
            mdi:minus-circle-outline
          {% endif %}

This works most of the time, however, it turns out that the sensor/state reports differently depending on the mode the fan is in. So if it is turned on with a manually selected speed, then:

fan.bedroom state is on
fan.bedroom auto_mode is false

If the fan is turned on and in auto mode:

fan.bedroom state is off
fan.bedroom auto_mode is true

If the fan is not on at all

fan.bedroom state is off
fan.bedroom auto_mode is false

So I think that the above code needs minor modification, however, I am just unsure how to add the OR statement or what is required to check two states to give the required answer. It looks like two sections need to be updated:

 value_template: "{{ is_state('fan.bedroom', 'on') and is_state_attr('fan.bedroom', 'oscillating', true) }}"

{% if is_state('fan.bedroom', 'on') and is_state_attr('fan.bedroom', 'oscillating', true) %}
            mdi:arrow-left-right-bold

So, finally, to my actual question :slight_smile: How do I add into the above code to also check if the fan is in auto_mode as well, because this also indicates that it is turned on. Not just the state.

Hopefully this makes sense

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 101899

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>