Hello to all HAs
Newly using Home Assistant, I enjoy creating automations.
And I actually created one which should generate a daily notification with the namesday.
To achieve this, I first created two REST calls:
- resource: https://nameday.abalin.net/api/V1/today?country=fr&timezone=Europe/Paris
scan_interval: 172000
sensor:
- name: NameDay Today
unique_id: nameday_today
value_template: "{{ value_json['nameday']['fr'] }}"
- resource: https://nameday.abalin.net/api/V1/tomorrow?country=fr&timezone=Europe/Paris
scan_interval: 172000
sensor:
- name: NameDay Tomorrow
unique_id: nameday_tomorrow
value_template: "{{ value_json['nameday']['fr'] }}"
Then an automation triggers one hour every day which calls the update_entity service to update my entities and which then sends a notification to my devices:
- id: '1698232436488'
alias: NameDay
description: ''
trigger:
- platform: time
at: 07:00:00
condition: []
action:
- service: notify.notifybenjy
data:
message: "{{ date }}\r\n{{ namedaytoday }}\r\n{{ namedaytomorrow }} {{ states.sensor.nameday_today.last_updated
}}"
- service: homeassistant.update_entity
data: {}
target:
entity_id:
- sensor.nameday_today
- sensor.nameday_tomorrow
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
enabled: false
- service: notify.notifybenjy
data:
message: "{{ date }}\r\n{{ namedaytoday }}\r\n{{ namedaytomorrow }} {{ states.sensor.nameday_today.last_updated
}}"
variables:
date: Nous sommes le {{ states('sensor.date_du_jour') }}
namedaytoday: Nous fêtons les {{ states('sensor.nameday_today') }}
namedaytomorrow: Demain nous fêterons les {{ states('sensor.nameday_tomorrow')
}}
mode: single
All of this works very well except that the notification I receive in the morning contains the data from the day before.
It is only when I restart the automation a second time that the data is up to date.
I suspect that the call to the update_entity service followed by the notification does not update the data.
How can I ensure that my notification contains the new updated data?
PS: I already tried to add a delay between calling the service and sending the notification, it doesn’t change anything
Thank you for your help !