thank you taras for helping me, i will wait patiently
If you are interested, you can reduce the automation’s size like this:
alias: "Notifica ritiro spazzatura"
trigger:
- platform: numeric_state
entity_id:
- sensor.plastica
- sensor.carta
- sensor.umido
- sensor.indifferenziata
- sensor.vetro
attribute: "days"
below: 1
condition: []
action:
- service: notify.mobile_app_iphone
data:
message: "Attenzione: domani è giorno di ritiro frazione {{ trigger.to_state.name }}."
mode: queued
ok perfect thank you, but wanting to add the notification via alexa? what should i put in the code? I’m sorry if I’m taking advantage but I’m a beginner
and also enter a notification time
That’s easy. For example, this template displays the hour and minute.
{{ now().timestamp() | timestamp_custom('%H:%M') }}
It’s possible but it’s not straightforward. It requires a connection between your Home Assistant and Amazon’s Alexa services and there’s more than one way to do it. You can send a Text-To-Speech message to an Echo via:
- Home Assistant Cloud (paid service provided by Nabu Casa)
- Alexa Media Player custom integration
- Direct connection if your Home Assistant is accessible via the internet
There are other ways as well but the one via Nabu Casa is probably the simplest (but it’s not free).
alexa I can make it talk via “service”, I integrated it into home assistant
Good! Then just use that service.
I created this code, can you tell me if there are errors, or if it can be improved:
’
alias: Notifica ritiro spazzatura
trigger:
- platform: numeric_state
entity_id:- sensor.plastica
- sensor.carta
- sensor.umido
- sensor.indifferenziata
- sensor.vetro
attribute: days
below: 1
- platform: time
at: ‘20:30:00’
condition: []
action: - service: notify.mobile_app_iphone
data:
title: Domotica
message: ‘Attenzione: domani è giorno di ritiro frazione {{ trigger.to_state.name
}}.’ - service: notify.alexa
data:
target: media_player.alexa
data:
type: tts
message: Attenzione: domani è giorno di ritiro frazione {{ trigger.to_state.name }}.
mode: queued
’
It will fail to report trigger.to_state.name
when it triggers at 20:30
for the reason I explained in my previous post. A Time Trigger only provides trigger.platform
and trigger.now
.
NOTE
Please format the YAML you post. Unformatted YAML is difficult to read.
Select the YAML and click the </>
icon in the forum’s editing menu. For more information, refer to guideline 11 in the FAQ.
and how do I get the notification at a set time?
What do you want the notification to report at 20:30
?
the notification both from alexa and on the phone
Based on your reply, you appear to have misunderstood my question.
The Time Trigger doesn’t produce trigger.to_state.name
so it cannot use the same message as the one you have when the automation is triggered by its Numeric State Trigger.
The message it uses must reference different information. What is the information you want it to report? For example, do you want it to report the days
value of each sensor or only the sensors that are below 1
or what?
I would like to have the notification both on the phone and on alexa of the ‘0’ which cyclically appears on the sensors I created with “Garbage Collection”, at a set time, for example 20:30
This will send notifications only at 20:30 if any sensor’s days
attribute is zero.
alias: "Notifica ritiro spazzatura"
variables:
sensors:
- sensor.plastica
- sensor.carta
- sensor.umido
- sensor.indifferenziata
- sensor.vetro
zero_day: >
{{ expand(sensors) | selectattr('attributes.days', 'eq' , 0)
| map(attribute='name') | list }}
trigger:
- platform: time
at: '20:30:00'
condition:
- condition: template
value_template: "{{ zero_day | count > 0 }}"
action:
- variables:
names: "{{ zero_day | join(', ') }}"
- service: notify.mobile_app_iphone
data:
message: "Attenzione: domani è giorno di ritiro frazione {{ names }}."
- service: notify.alexa
data:
message: "Attenzione: domani è giorno di ritiro frazione {{ names }}."
target: media_player.alexa
data:
type: tts
EDIT
Correction. Added missing data:
to second notification.
thanks 123 Taras, the automation works only with notification to the mobile phone, as for notification alexa gives me this error
Change it to this:
- service: notify.alexa_media_alexa_cucina
data:
message: "Attenzione: domani è giorno di ritiro frazione {{ names }}."
target: media_player.alexa
data:
type: tts
thanks 123 Taras, everything ok works
hi, now that “Garbage Collection” no longer works, do you have any advice for me to replace it?
I suggest you ask the question in a new topic (as opposed to this old one which was solved six months ago) where it will attract the attention of a wider audience.