Simple automation, blue tooth tracker

trying to set up a new automation with blue tooth tracker. right now I get the lights to come on at sun set if I’m home. but if I come home after sun set they will not trigger, which is what I am trying to accomplish. I was not able to find the answer on my own.

  • alias: Turn on Christmas Tree When Home
    initial_state: True
    hide_entity: False
    trigger:
    platform: sun
    event: sunset
    offset: ‘-00:30:00’
    condition:
    condition: state
    entity_id: group.all_devices
    state: ‘home’
    action:
    service: switch.turn_on
    entity_id: switch.christmas_tree_lights

I would trigger on the event of a device changing to ‘home’ and the sun is set as a condition

alias: Turn on Christmas Tree When Home
initial_state: True
hide_entity: False
trigger:
platform: state
entity_id: group.all_devices
to: ‘home’
condition: sun
after: sunset:
after_offset: ‘-00:30:00’
action:
service: switch.turn_on
entity_id: switch.christmas_tree_lights