Deciding which of the below basic automations would be most efficient, I am uncertain and turn to the community
- alias: Sun switches outside motion sensors
id: Sun switches outside motion sensors
trigger:
- platform: sun
event: sunrise
- platform: sun
event: sunset
action:
service: >
homeassistant.turn_{{'off' if trigger.event == 'sunrise' else 'on'}}
entity_id: group.philips_buiten_motion_sensor_switches
would have the advantage of being triggered less frequently (only on the events) but, as stated in the docs, is not precise enough for its goal.
alias: Outside motion sensors on when dark outside
trigger:
platform: numeric_state
entity_id: sun.sun
attribute: elevation
below: -3.5
action:
service: homeassistant.turn_on
entity_id: group.philips_buiten_motion_sensor_switches
alias: Outside motion sensors off when light outside
trigger:
platform: numeric_state
entity_id: sun.sun
attribute: elevation
above: -3.5
action:
service: homeassistant.turn_off
entity_id: group.philips_buiten_motion_sensor_switches
would be more precise, but will keep being tracked during all sun state changes, which might be insignificant in itself, but on the whole, trying to keep the triggers as few as possible.
would there be a better way of doing this other than maybe using a binary_sensor on the elevation and using the binary as trigger in the automation (I think that would in the end be just as costly, because now the binary sensor will be tracking the suns elevation constantly, so no real, benefit there?) besides creating 1 single automation:
- alias: Daylight sets outside motion sensors
id: Daylight sets outside motion sensors
trigger:
platform: state
entity_id: binary_sensor.outside_daylight_sensor
condition:
- >
{{trigger.from_state is not none and
trigger.to_state is not none and
trigger.to_state.state != trigger.from_state.state}}
action:
service: >
homeassistant.turn_{{'off' if trigger.to_state.state == 'on' else 'on'}}
entity_id: group.philips_buiten_motion_sensor_switches
and being able to allow extra conditions to be taken into account easily:
outside_daylight_sensor:
friendly_name: Outside daylight sensor
device_class: light
value_template: >
{{state_attr('sun.sun','elevation') > -3.5 or
states('sensor.driveway_buiten_sensor_light_level_raw')|int > 5000}}
(dont think we can create such a compacted version for the
trigger:
platform: numeric_state
entity_id: sun.sun
attribute: elevation
automation can we?)
thanks for having a look!