Hi All,
I am having multiple automations where I want to perform a specific condition within, but have this condition applied only to the following service call.
The service call afterwards should be not affected.
Let me give you an example:
My automation looks like e.g.:
automation:
- id: MyAutomation
alias: 'My Automation'
description: 'my test automation'
trigger:
- platform: state
entity_id: light.dummy
to: 'on'
action:
- service: logbook.log
data:
entity_id: light.dummy
name: light.dummy
message: 'Logbook Message 1 '
- condition: state
entity_id: sun.sun
state: "below_horizon"
- service: logbook.log
data:
entity_id: light.dummy
name: light.dummy
message: 'Logbook Message 2 '
- service: logbook.log
data:
entity_id: light.dummy
message: 'Logbook Message 3 '
In this case “Logbook Message 2” and “Logbook Message 3” are only written if the sun is below_horizon.
What I want is that “Logbook Message 2” is only written if the sun is below_horizon, but “Logbook Message 3” is ALWAYS written.
The workaround I applied is as follows via a separated script:
automation:
- id: MyAutomation
alias: 'My Automation'
description: 'my test automation'
trigger:
- platform: state
entity_id: light.dummy
to: 'on'
action:
- service: logbook.log
data:
entity_id: light.dummy
name: light.dummy
message: 'Logbook Message 1 '
- service: script.conditional_logbook
- service: logbook.log
data:
entity_id: light.dummy
name: light.dummy
message: 'Logbook Message 3 '
script:
conditional_logbook:
description: 'Write log only on sun down'
sequence:
- condition: state
entity_id: sun.sun
state: "below_horizon"
- service: logbook.log
data:
entity_id: light.dummy
name: light.dummy
message: 'Logbook Message 2 '
Never the less this does not seem like the most elegant solution to me.
Any recommendations how to solve this “better” without a special script part?
Thanks