Hi all,
I’m trying to make an automation for my trash. I have an automation which looks everyday at 19:00:00 o’clock if a binary sensor is on. When the sensor is on, i send a message to my phone. Now I want to know which of the binary sensors from my conidtion was the one who make the automation start. Here is my code:
- alias: 'Notify Trash Black'
trigger:
platform: time
at: "19:00:00"
condition:
condition: or
conditions:
- condition: state
entity_id: binary_sensor.morgen_schwarze_tonne
state: 'on'
- condition: state
entity_id: binary_sensor.morgen_blaue_tonne
state: 'on'
- condition: state
entity_id: binary_sensor.morgen_gruene_tonne
state: 'on'
- condition: state
entity_id: binary_sensor.morgen_gelbe_tonne
state: 'on'
action:
- service: counter.increment
entity_id: counter.iosbadgecount_tim
- service: counter.increment
entity_id: counter.iosbadgecount_vio
- service: notify.ios_tims_devices
data_template:
title: "Morgen wird Müll abgeholt"
message: "INSERT FRIENDLY NAME OF BINARY SENSOR HERE"
data:
push:
badge: '{{states.counter.iosbadgecount_tim.state}}'
thread-id: "Muell"
I’m sure you can do this with if statements, someone else can take the liberty of posting that. Here’s an expandable template but it uses ‘high level’ templating. I suggest you read up on templates and jinja and you could probably come up with an if - elif - else template on your own.
- alias: 'Notify Trash Black'
trigger:
platform: time
at: "19:00:00"
condition:
condition: or
conditions:
- condition: state
entity_id: binary_sensor.morgen_schwarze_tonne
state: 'on'
- condition: state
entity_id: binary_sensor.morgen_blaue_tonne
state: 'on'
- condition: state
entity_id: binary_sensor.morgen_gruene_tonne
state: 'on'
- condition: state
entity_id: binary_sensor.morgen_gelbe_tonne
state: 'on'
action:
- service: counter.increment
entity_id: counter.iosbadgecount_tim
- service: counter.increment
entity_id: counter.iosbadgecount_vio
- service: notify.ios_tims_devices
data_template:
title: "Morgen wird Müll abgeholt"
message: >
{% set sensors = [
states.binary_sensor.morgen_schwarze_tonne,
states.binary_sensor.morgen_blaue_tonne,
states.binary_sensor.morgen_gruene_tonne,
states.binary_sensor.morgen_gelbe_tonne ] %}
{{ sensors | selectattr('state', 'eq', 'on') | map(attribute='name') | list | first }}
data:
push:
badge: '{{states.counter.iosbadgecount_tim.state}}'
thread-id: "Muell"