Help making a currently on light change brightness/colour when sensor changes

I’ve made a sensor which changes state depending on the time of day. I then have an automation which uses this state to set the light colour & brightness when they turn on. This works perfectly.
But, I also want lights that are currently on, to change mode when the sensor changes. I thought I’d figured it out, but it doesn’t work. Even if I manually trigger it, it does nothing. I copied the action from the working automation, so I know it shouldn’t be that. The condition just checks if the light is on, so that should be fine. Everything I’ve read suggests that the trigger I’ve put should make the automation run whenever the sensor state changes, but I’m not 100% sure.
Can anyone see a reason this isn’t working?
Also, as a bonus question, is there anyway to include minutes in the sensor? I’d love it if some of the changes happened at half past instead of on the hour.

sensors:
  platform: template
    sensors:
      default_light_mode:
        entity_id: sensor.time
        friendly_name: 'Default Light Mode'
        value_template: >-
         {% if 00 <= now().hour < 01 %}
          Soft
         {% elif 01 <= now().hour < 02 %}
          Dim
         {% elif 02 <= now().hour < 06 %}
          Dark
         {% elif 06 <= now().hour < 08 %}
          Dim
         {% elif 08 <= now().hour < 10 %}
          Soft
         {% elif 10 <= now().hour < 21 %}
          Bright
         {% elif 21 <= now().hour < 24 %}
          Soft
         {% else %}
          Soft
         {% endif %}


automations:
- alias: Set Default Mode When Lamp Turns On
  trigger:
     - platform: state
       entity_id: light.lamp
       from: 'off'
       to: 'on'
  action:
     - service: input_select.select_option
       data_template:
        entity_id: input_select.lamp_mode
        option: "{{ states.sensor.default_light_mode.state }}"

- alias: Transition to Default Mode if Lamp is On
  trigger:
     - platform: state
       entity_id: sensor.default_light_mode
  condition:
     - condition: state
       entity_id: light.lamp
       state: 'on'
  action: 
     - service: input_select.select_option
       data_template:
        entitiy_id: input_select.lamp_mode
        option: "{{ states.sensor.default_light_mode.state }}"

Typo: entitiy_id

1 Like

Thank you! I have a have read that over and over and didn’t see they damn typo. :flushed:

Did you run Check Config?

As a test, I just created the same spelling error in a template_sensor and then ran Check Config. It reported the error.

I’ve run check config dozens of times since making that script and nothing. It didn’t pick it up.

That’s strange. Which version of Home Assistant are you using?

I’m using 0.80. Here’s an example of it catching a typo in an automation:

typo

I’m on 0.87.1
Maybe something’s wrong with it? It’s been picking up other errors I’ve made today (and there’s been a lot of them.

If Check Config is reporting other errors, you may need to fix them first before it will identify this typo.

If Check Config reports no errors, including the typo, then there’s a problem.

No errors at the moment. I even put the type back in automations and tested it again. Still nothing.

You can create a new thread here and report the problem (“0.87.1 Check Config fails to find typo”) to see if anyone else has experienced it (and maybe they have a solution).

Alternately, you report the problem as an Issue (in Home Assistant’s GitHub repo). That gets the attention of developers and becomes part of the official record of the software’s evolution.