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

How do I skip a light in a script if it's already off?

$
0
0

@jmiheve wrote:

My google-fu has failed me, so I’m hoping someone here can point me in the right direction.

I have a script for bedtime (“sunset”) that slowly dims the lights before turning them off. I also have an input_boolean that controls a “reading mode” setting for my lights (toggling between an ‘on’ and ‘off’ script to change the lights). Right now I have the sunset script set up to turn reading mode off, but if it’s not already on then that flashes one of the lights that’s only on as part of the reading mode as it resets the brightness. Is there a way to make my sunset script skip turning off reading mode if it’s not already on? So far, I have:

'1560502398295':
  alias: Sunset
  sequence:
  - data:
      entity_id: input_boolean.reading_mode
    service_template: >
      {% if is_state('input_boolean.reading_mode', 'on') %}
        input_boolean.turn_off
      {% else %}{% endif %}
  - data:
      entity_id: [continues on to dimming the lights]

Unfortunately, with this it only works when reading mode is on. Otherwise, it seems to stop when the ‘if’ condition returns false. Is there a way to tell it to continue if the state is ‘off’? I can’t find anything in the documentation to figure this out.

Posts: 7

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 95284

Trending Articles



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