Hi.
One of my automation is no longer working.
I don’t understand why, and I hope some of you can help me?
I’m currently running version 0.116.4 and I’m not sure when my automation stopped working.
So what is my automation:
To control my lights I use a input_select component.
When the input changes, the light changes brightness and temperature according to a light_profiles.csv.
The input_select component will change based on an automation, or I can change it manually.
From my Lovelace:
I’ve defined the input_select component like this:
input_select:
current_light_profile:
name: Current light Profile
options:
- bright
- reading
- concentrate
- energize
- relax
- dimmed
- movie
- nightlight
I’ve updated my automation trigger accordingly to ver 0.115
It triggers at “two different settings”.
One: At some specified input_time
Two: When changing these input_time
- platform: time
at:
- input_datetime.bright_time_weekend
- input_datetime.reading_time_weekend
- input_datetime.relax_time_weekend
- input_datetime.dimmed_time_weekend
- input_datetime.bright_time
- input_datetime.reading_time
- input_datetime.relax_time
- input_datetime.dimmed_time
- platform: state
entity_id:
- input_datetime.bright_time_weekend
- input_datetime.reading_time_weekend
- input_datetime.relax_time_weekend
- input_datetime.dimmed_time_weekend
- input_datetime.bright_time
- input_datetime.reading_time
- input_datetime.relax_time
- input_datetime.dimmed_time
So to the action part of my automation:
I’ve played with the template part here. But I’m not comfortable with this!
First I determine if it is a normal day, or weekend/holiday.
Then I find out what “timeslot” I’m in and return the correct input_select value to set (or option).
action:
- service: input_select.select_option
data:
entity_id: input_select.current_light_profile
option: >
{% set n = now() %}
{% set n = (n.hour*60+n.minute)*60+n.second %}
{% if is_state('binary_sensor.workday_light', 'off') %}
{% set time_bright = state_attr('input_datetime.bright_time_weekend', 'timestamp') %}
{% set time_reading = state_attr('input_datetime.reading_time_weekend', 'timestamp') %}
{% set time_relax = state_attr('input_datetime.relax_time_weekend', 'timestamp') %}
{% set time_dimmed = state_attr('input_datetime.dimmed_time_weekend', 'timestamp') %}
{% else %}
{% set time_bright = state_attr('input_datetime.bright_time', 'timestamp') %}
{% set time_reading = state_attr('input_datetime.reading_time', 'timestamp') %}
{% set time_relax = state_attr('input_datetime.relax_time', 'timestamp') %}
{% set time_dimmed = state_attr('input_datetime.dimmed_time', 'timestamp') %}
{% endif %}
{% if time_bright < time_reading < time_relax < time_dimmed %}
{% if time_bright < n and n < time_reading %}
bright
{% elif time_reading < n and n < time_relax %}
reading
{% elif time_relax < n and n < time_dimmed %}
relax
{% elif time_dimmed < n or n < time_bright %}
dimmed
{% endif %}
{% elif time_dimmed < time_bright < time_reading < time_relax %}
{% if time_dimmed < n and n < time_bright %}
dimmed
{% elif time_bright < n and n < time_reading %}
bright
{% elif time_reading < n and n < time_relax %}
reading
{% elif time_relax < n or n < time_dimmed %}
relax
{% endif %}
{% else %}
relax
{% endif %}
When I change the time in Lovelace and thereby trigger the automation (platform: state), everything works fine. But if the automation is triggered by the time part (platform: time), nothing happens. And I get this in the log:
Logger: homeassistant.components.input_select
Source: components/input_select/__init__.py:256
Integration: Input select ([documentation](https://www.home-assistant.io/integrations/input_select), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+input_select%22))
First occurred: 12:12:00 PM (3 occurrences)
Last logged: 2:50:00 PM
Invalid option: (possible options: bright, reading, concentrate, energize, relax, dimmed, movie, nightlight)
So I guess my template is no longer 100% valid? But it is strange that what type of trigger sets of the automation should affect the action part of the automation?
I’m not to bright with coding, so when I read this: breaking change in the template integration, I don’t really understand anything. So could this be the problem?
My complete code if it helps:
binary_sensor:
- platform: template
sensors:
workday_light:
friendly_name: "Worday tomorrow ( Updates after 12:00 )"
value_template: >-
{{ (states.sensor.time.state > '12:00' | timestamp_custom('%H:%M', False)
and is_state('binary_sensor.tomorrow', 'on'))
or
(states.sensor.time.state < '12:00' | timestamp_custom('%H:%M', False)
and is_state('binary_sensor.today', 'on')) }}
icon_template: mdi:briefcase
input_datetime:
# Work days
bright_time:
name: Bright
has_time: true
has_date: false
icon: mdi:weather-sunny
reading_time:
name: Reading
has_time: true
has_date: false
icon: mdi:brightness-5
relax_time:
name: Relax
has_time: true
has_date: false
icon: mdi:brightness-6
dimmed_time:
name: Dimmed
has_time: true
has_date: false
icon: mdi:brightness-4
# Hollidays days
bright_time_weekend:
name: Bright
has_time: true
has_date: false
icon: mdi:weather-sunny
reading_time_weekend:
name: Reading
has_time: true
has_date: false
icon: mdi:brightness-5
relax_time_weekend:
name: Relaxed
has_time: true
has_date: false
icon: mdi:brightness-6
dimmed_time_weekend:
name: Dimmed
has_time: true
has_date: false
icon: mdi:brightness-4
input_select:
current_light_profile:
name: Current light Profile
options:
- bright
- reading
- concentrate
- energize
- relax
- dimmed
- movie
- nightlight
automation:
- alias: Light presets
id: light_presets
trigger:
- platform: state
entity_id: input_boolean.sleep_mode_active
to: 'off'
- platform: state
entity_id: input_boolean.light_presets
to: 'on'
- platform: time
at:
- input_datetime.bright_time_weekend
- input_datetime.reading_time_weekend
- input_datetime.relax_time_weekend
- input_datetime.dimmed_time_weekend
- input_datetime.bright_time
- input_datetime.reading_time
- input_datetime.relax_time
- input_datetime.dimmed_time
- platform: state
entity_id:
- input_datetime.bright_time_weekend
- input_datetime.reading_time_weekend
- input_datetime.relax_time_weekend
- input_datetime.dimmed_time_weekend
- input_datetime.bright_time
- input_datetime.reading_time
- input_datetime.relax_time
- input_datetime.dimmed_time
condition:
# Override if sleep mode is active
- condition: state
entity_id: input_boolean.sleep_mode_active
state: 'off'
# Enable This Automations
- condition: state
entity_id: input_boolean.light_presets
state: 'on'
action:
- service: input_select.select_option
data:
entity_id: input_select.current_light_profile
option: >
{% set n = now() %}
{% set n = (n.hour*60+n.minute)*60+n.second %}
{% if is_state('binary_sensor.workday_light', 'off') %}
{% set time_bright = state_attr('input_datetime.bright_time_weekend', 'timestamp') %}
{% set time_reading = state_attr('input_datetime.reading_time_weekend', 'timestamp') %}
{% set time_relax = state_attr('input_datetime.relax_time_weekend', 'timestamp') %}
{% set time_dimmed = state_attr('input_datetime.dimmed_time_weekend', 'timestamp') %}
{% else %}
{% set time_bright = state_attr('input_datetime.bright_time', 'timestamp') %}
{% set time_reading = state_attr('input_datetime.reading_time', 'timestamp') %}
{% set time_relax = state_attr('input_datetime.relax_time', 'timestamp') %}
{% set time_dimmed = state_attr('input_datetime.dimmed_time', 'timestamp') %}
{% endif %}
{% if time_bright < time_reading < time_relax < time_dimmed %}
{% if time_bright < n and n < time_reading %}
bright
{% elif time_reading < n and n < time_relax %}
reading
{% elif time_relax < n and n < time_dimmed %}
relax
{% elif time_dimmed < n or n < time_bright %}
dimmed
{% endif %}
{% elif time_dimmed < time_bright < time_reading < time_relax %}
{% if time_dimmed < n and n < time_bright %}
dimmed
{% elif time_bright < n and n < time_reading %}
bright
{% elif time_reading < n and n < time_relax %}
reading
{% elif time_relax < n or n < time_dimmed %}
relax
{% endif %}
{% else %}
relax
{% endif %}