Using the sensor.file to log my intercom messages I can see the sensor change only quite some time, lets say a second or 10-20 sometimes updated after the notification has been played.
Is there a way we can trigger the sensor.file to update immediately upon triggering of the automation I use to populate the sensor?
sensor:
- name: filed_intercom_messages
platform: file
filename: /config/logging/filed_intercom_messages.txt
and automation:
- alias: 'Person forward intercom messages to filed intercom messages'
id: 'Person forward intercom messages to filed intercom messages'
trigger:
platform: state
entity_id: script.intercom_text_message
condition: []
action:
service: notify.filed_intercom_messages
data_template:
message: >
{% set message = states('input_select.intercom_message') %}
{% set device = states('input_select.intercom') %}
{% set language = states('input_select.intercom_language') %}
{% set id = trigger.to_state.context.user_id %}
{% set time = as_timestamp(now())|timestamp_custom('%d %b: %X') %}
{% set user = states.person|selectattr('attributes.user_id','eq',id)|first %}
{% set user = user.attributes.friendly_name %}
{{time}}: {{user}} played "{{message}}" on {{device}} in {{language}}
and the script:
script:
intercom_text_message:
alias: 'Intercom text message'
icon: mdi:text-to-speech
sequence:
- condition: state
entity_id: input_boolean.announce_intercom
state: 'on'
- service: media_player.volume_set
data_template:
entity_id: >
{{states('sensor.intercom')}}
volume_level: >
{{states('input_number.intercom_volume')|float}}
- service: tts.google_say
data_template:
language: >
{{states('input_select.intercom_language')|lower}}
entity_id: >
{{states('sensor.intercom')}}
message: >
{{states('input_select.intercom_message')}}
thanks for having a look, and any suggestion you might have.