I’m trying to declutter my automations and I’ve been pretty successful with most of them and decreasing the number of content similar automation.
But not this one…
I have 4 different trash sensors optimised to my needs and 4 different automations that are almost the same despite the sensor, message, title and some indivdual data.
What I want to achieve is only 1 automation where I can nest in all 4 actions at once.
I’ve tried with trigger IDs and choose but want to get 4 messages and not only 1 when all 4 sensors have the wished state. And of course with choose I only get the first notification.
Every automations looks like this right now.
alias: 'Trash: Bio'
description: ''
trigger:
- platform: time
at: '18:30'
condition:
- condition: state
entity_id: sensor.trashbio
state: morgen
action:
- service: notify.all_mobile_phones
data:
message: Please put the trashbag out!
title: ⏰ Bio trash is due tomorrow
data:
icon_url: /local/Icons/bio.png
notification_icon: mdi:delete-clock
tag: biom
mode: single
Would be thankful for years if anybody could give me a hand or and idea.
This one is good. I would combine the text in one message as well, like my window alert
{{ fenster | join('-, ') | regex_replace(find=',([^,]*)$', replace=' und\\1', ignorecase=False) }}fenster immer noch lange auf
But the initial post at least seams, that the RodgerDoger is not yet that familiar with all the stuff, so I would start with something like.
alias: 'Trash: Bio'
description: ''
trigger:
- platform: time
at: '18:30'
condition:
- condition: or
conditions:
- condition: state
entity_id: sensor.trashbio
state: morgen
- condition: state
entity_id: sensor.bla
state: morgen
- condition: state
entity_id: sensor.blub
state: morgen
action:
- if:
- condition: state
entity_id: sensor.trashbio
state: morgen
then:
- service: notify.all_mobile_phones
data:
message: Please put the trashbag out!
title: ⏰ Bio trash is due tomorrow
data:
icon_url: /local/Icons/bio.png
notification_icon: mdi:delete-clock
tag: biom
- if:
- condition: state
entity_id: sensor.bla
state: morgen
then:
- service: notify.all_mobile_phones
data:
message: Please put the trashbag out!
title: ⏰ Bio trash is due tomorrow
data:
icon_url: /local/Icons/bio.png
notification_icon: mdi:delete-clock
tag: biom
- if:
- condition: state
entity_id: sensor.blub
state: morgen
then:
- service: notify.all_mobile_phones
data:
message: Please put the trashbag out!
title: ⏰ Bio trash is due tomorrow
data:
icon_url: /local/Icons/bio.png
notification_icon: mdi:delete-clock
tag: biom
mode: single
But of course, you can learn more if you try the understand, what Taras proposed. And yes, this example has a lot of spots for improvements, but brings you at least in if-the, conditions, or, etc.
FWIW, I had intended to do that but I don’t know enough German to ensure the resulting message’s grammar is correct (gender; singular vs plural). So I left it as separate notifications using the original phrases RodgerDodger created. Plus it preserves the unique icon and tag that has been defined for each trash collection type. However, yes, it’s possible to consolidate multiple trash collection types into a single notification.
@arganto & @123 Thank you guys very much for the extensive replys and different perspectives to solve my “problem”.
Both automation look like something I could use and supplementary I can expand horizon on. I will mark 123s post as the solution as he needs it the most but argantos will be useful for me and hopefully anybody who stumbles into this thread.