I try to use an OR condition in an automation for my media player.
However it returns an error. Can someone see what is wrong? When I only use one condition without the OR it works fine.
[homeassistant.components] Invalid config for [automation]: [condition] is an invalid option for [automation]. Check: automation->action->4->condition. (See /home/homeassistant/.homeassistant/configuration.yaml, line 18). Please check the docs at https://home-assistant.io/components/automation/
should have thought about this before!
This seems to be the answer to the issue we discussed here with @NotoriousBDG of phones device_trackers triggering on all attribute changes too, when one uses the platform: state, and to/from: home.
sometimes the obvious stares you in the eyes…
simply add:
value_template: >
{{ trigger.to_state.state is in ['home', 'not_home'] and
trigger.to_state.state != trigger.from_state.state }}
or:
- alias: Send notification when sun changes state
id: 'Send notification when sun changes state'
trigger:
platform: state
entity_id: sun.sun
condition:
- condition: template
value_template: >
{{ trigger.to_state.state is in ['above_horizon', 'below_horizon'] and
trigger.to_state.state != trigger.from_state.state }}
- condition: state
entity_id: input_boolean.notify_notify
state: 'on'
action:
service: notify.notify
data_template:
message: >
Sun state change - {{as_timestamp(now()) | timestamp_custom("%X") }} The Sun is
{{'up' if is_state('sun.sun','above_horizon') else 'down'}}