ok, that would have to be ‘remembered’ or stored in a variable (a custom component) or an input_boolean/select maybe, which would be set by an automation, which is what your are describing…
But first you’d need to decide what would happen if someone else would open the door?
about the ‘legal’ names. You could easily have a condition like:
condition: template
value_template: >
{{state_attr('lock.door',changed_by') in ['you', 'your_wife','kid1','kid2','kid3','etc']))
but you’d have to decide what would happen if this condition isn’t met. No action at all, or a warning maybe? Why else bother who opened/closed the door?
but for my main idea have a look at this:
- alias: 'Notify outside daylight'
id: 'Notify outside daylight'
# initial_state: on
trigger:
platform: state
entity_id: binary_sensor.outside_daylight_sensor
# to: 'off'
condition: []
action:
- service: variable.set_variable
data:
variable: virtual_light_daylight
attributes_template: >
{
"history_1": "{{ variable.state }}",
"history_2": "{{ variable.attributes.history_1 }}",
"history_3": "{{ variable.attributes.history_2 }}",
"history_4": "{{ variable.attributes.history_3 }}",
"history_5": "{{ variable.attributes.history_4 }}"
}
data_template:
value: >
{{trigger.to_state.state}} : {{states('sensor.virtual_light')}}
- condition: template
value_template: >
{{is_state('input_boolean.notify_system', 'on')}}
- service: notify.notify
data_template:
message: >
{{as_timestamp(now()) | timestamp_custom("%X") }}:
Daylight {{states('binary_sensor.outside_daylight_sensor') }}: Outside lights are powered
{{'on ' if is_state('binary_sensor.outside_daylight_sensor', 'off') else 'off, '-}}
at Solar angle: {{states('sensor.solar_angle')}}.
and think of the binary_sensor.outside_daylight_sensor s your lock.door.
when it goes on/open, it stores that value with the attributes value mentioned, in my setting a lx sensor. Would be the equivalent of the door lock and name of the opener in your setting. You’d need the Custom component for ‘saving’ these values, as that is what you said you wanted to do in your 2nd post.
If you don’t want the opener to be saved, you can simply skip that part and use the sensor from before, and maybe a message the door is unlocked/locked.
So, options galore
You might also want to consider if you wouldn’t simply want to trigger in state change, so either open or close, and have an automation respond to that. As you can see I have the to: off
in my automation commented out, to do exactly that. I think that is what you would want to?