Need help with automation (Check to see if a Harmony Hub activity is active at sunset and turn on certain lights if so)

Hello,

Could someone help me extend the below automation. Currently it only checks the situation at sunset. I would like to also catch this situation if the harmony activity was already on before sunset but I would only want the accents to come on at sunset still.

Thank you all for any guidance you can give me on this!!

alias: Den in use starts after sunset (set accents)
description: ""
trigger:
  - platform: state
    entity_id:
      - select.harmonyhub_living_room_activities
    from: null
    to: Media Player- Projector
  - platform: state
    entity_id:
      - select.harmonyhub_living_room_activities
    from: null
    to: PC- Projector
condition:
  - condition: sun
    after: sunset
action:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id:
        - light.all_kitchenette_accent_lights
        - light.all_den_accent_lights
mode: single

does this do what you want?

alias: Den in use starts after sunset (set accents)
description: ""
trigger:
  - platform: state
    entity_id:
      - remote.harmonyhub_living_room_activities
    to: "on"
  - platform: sun
    event: sunset
    offset: 0
condition:
  - condition: sun
    after: sunset
  - condition: state
    entity_id: remote.harmonyhub_living_room_activities
    state: "on"
action:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id:
        - light.all_kitchenette_accent_lights
        - light.all_den_accent_lights
mode: single

note that i simplified your harmonyhub to use the remote entity instead of the select.
that lets me choose for on/off state instead of hardcoding specific select values.

then that simplfiies the typical trick of triggering on both events (sunset and turning on) and setting both as conditions as well. that will cause your actions to happen as soon as both conditions are true… no matter which order they happen in.

Ahh, I follow you now. Very nice. This is perfect and what you are saying makes sense. Thank you again!!

1 Like