I’m trying an automation with conditions, but I always get an error message that it’s not correct.
The various actions should be executed depending based on settings of the
input boolean (input_boolean.enable_sensor_notify, input_boolean.enable_sensor_alexamessage).
- The “notification to homeassitant” should only be sent if “input_boolean.enable_sensor_notify” is on.
- The “notification to all Amazon devices” should only be sent if “input_boolean.enable_sensor_alexamessage” is on.
- All other actions should always be performed.
ERROR MESSAGE
Invalid config for [automation]: [service] is an invalid option for [automation]. Check: automation->action->2->conditions->1->service. (See ?, line ?).
AUTOMATION
## ----------------------------------------------------------------------------------
## BITIWEND RF SENSOR WITH SONOFF RFBRIDGE: POST BOX
## ---------------------------------------------------------------------------------
- id: postbox_sensor
alias: postbox_sensor
initial_state: true
trigger:
- platform: mqtt
topic: "tele/rfbridge/RESULT"
condition:
condition: and
conditions:
- condition: template
value_template: '{{ trigger.payload_json.RfReceived.Data == "21A8F3" }}'
action:
## ----------------------------------------------
## publish the postbox sensors state: OPEN
## ----------------------------------------------
- service: mqtt.publish
data_template:
topic: "security/sensor/postbox"
retain: false
payload: >-
{
"timestamp": "{{ now().strftime('%Y-%m-%d %H:%M:%S') | string}}",
"state": "open",
"location": "postbox",
"sensor": "{{ trigger.payload_json.RfReceived.Data | string }}",
"sync": {{ trigger.payload_json.RfReceived.Sync | string}}
}
## ----------------------------------------------
## set the boolean input state Postbox OPEN
## ----------------------------------------------
- service: input_boolean.turn_on
data:
entity_id: input_boolean.sensor_postbox
- condition: or
conditions:
## ----------------------------------------------
## send notification to homeassitant gui
## ----------------------------------------------
- condition: state
entity_id: input_boolean.enable_sensor_notify
state: 'on'
- service: persistent_notification.create
data:
message: "Postkasten wurde um {{ now().strftime('%Y-%m-%d %H:%M:%S') }} geöffnet !"
title: "Security Postkasten"
## ----------------------------------------------
## send notification to all amazon devices
## ----------------------------------------------
- condition: state
entity_id: input_boolean.enable_sensor_alexamessage
state: 'on'
- service: media_player.alexa_tts
data:
entity_id:
- media_player.esszimmer ## echo show 2nd Gen
- media_player.wohnzimmer ## echo dot 2nd Gen
- media_player.office ## echo 2nd Gen
- media_player.bad ## echo 1st Gen
- media_player.fitnessraum ## echo dot 2nd Gen
message: "Hausmeister meldet, Trara, Trara, die Post ist da, es ist etwas im Postkasten."
## ----------------------------------------------
## set the boolean input state Postbox COSED
## ----------------------------------------------
- delay: '00:01:00' ## postman need's time
- service: input_boolean.turn_off
data:
entity_id: input_boolean.sensor_postbox
## ----------------------------------------------
## publish the postbox sensors state: CLOSED
## ----------------------------------------------
- service: mqtt.publish
data_template:
topic: "security/sensor/postbox"
retain: false
payload: >-
{
"timestamp": "{{ now().strftime('%Y-%m-%d %H:%M:%S') | string}}",
"state": "closed",
"location": "postbox",
"sensor": "{{ trigger.payload_json.RfReceived.Data | string }}",
"sync": {{ trigger.payload_json.RfReceived.Sync | string}}
}
I can not figure out where I’m doing it wrong. Can somebody help me with it?
Thanks