Super simple TV lighting based on sunset using harmony

I’ve moving from ST I’m new to this, but I belive this will do what I expect

Goal: If the harmony is on and the sun goes down, set my evening TV lighting
additionally if the sun is already down when I turn on the harmony, do the same.

Two automations

  - alias: TV Lighting after sunset if TV is turned on
    trigger:
    - platform: sun
      event: sunset
    condition:
    - condition: state
      entity_id: remote.living_room_harmony_hub
      state: 'on'
    action:
    - service: script.turn_on
      entity_id: script.kitchen_tv_lights_hue_scene
    - service: script.turn_on
      entity_id: script.living_room_tv_lights_hue_scene

  - alias: TV Lighting after sunset if TV was already on
    trigger:
    - platform: state
      entity_id: remote.living_room_harmony_hub
      from: 'off'
      to: 'on'
    condition:
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
    action:
    - service: script.turn_on
      entity_id: script.kitchen_tv_lights_hue_scene
    - service: script.turn_on
      entity_id: script.living_room_tv_lights_hue_scene

You could combine your automations into one.
Haven’t fully tested the one below but with some minor tinkering your should be able to use it.

  - alias: TV Lighting after sunset if TV is turned on
    trigger:
    - platform: sun
      event: sunset
    - platform: state
      entity_id: remote.living_room_harmony_hub
      from: 'off'
      to: 'on'
    condition:
      condition: or
      conditions:
        - condition: state
          entity_id: remote.living_room_harmony_hub
          state: 'on'
        - condition: sun
          after: sunset
    action:
    - service: script.turn_on
      entity_id: script.kitchen_tv_lights_hue_scene
    - service: script.turn_on
      entity_id: script.living_room_tv_lights_hue_scene
2 Likes

interesting, I’ll have to try that. I’m all about simplifying automations.

So in your example, with 2 triggers (sunset and harmony turning on). Would it be either one or both at same time?

I get the or with the conditons, either one being valid would be considered true.

My goal is if I turn the TV on before sunset, then change the lights after sunset
or
If I turn the tv on after sunset just go ahead and set light now.

Thanks for the help, I still learning, so the multiple triggers seems a bit confusing.

Whenever one of the triggers fires, your automation is executed.
The conditions can be a bit tricky when combining automations but with either clever use of condition: or most shortcomings can be overcome :wink:

Ahh, I get it. So either one will trigger.

So when sunset happens, if the TV is not on, this will also not be true

        - condition: sun
          after: sunset

Because it will BE sunset, not after. Might have to play with the timing on this, but overall that’s the logic I was missing.

But if the TV was on (or turned on and it was after sunset, it would work. Very cool.

Thanks!

1 Like

Hmm, I think that the lights would turn on during the day, right

    - platform: state
      entity_id: remote.living_room_harmony_hub
      from: 'off'
      to: 'on'

Would trigger the automation
and this condition would also be true, right

        - condition: state
          entity_id: remote.living_room_harmony_hub
          state: 'on'

I think I’m reading it right.

Worked perfectly. Thanks so much for the help.

1 Like