OK, this is what I did (sorry for the lengthy post):
I collect utility values (electricity) hourly, and place them in a file. I have my configuration split up over several files. My legacy config (in config/notifiers/file.yaml) is:
- name: utility_hourly
platform: file
filename: www/utility_hourly.csv
- name: utility_with_prices_hourly
platform: file
filename: www/utility_with_prices_hourly.csv
These logfiles are created:
- config/www/utility_hourly.csv
- config/www/utility_with_prices_hourly.csv
I did not yet change the automation. The action part is:
service: notify.utility_with_prices_hourly
data:
message: >
{{ states('sensor.remote_date_time') }}, {{
states('sensor.remote_energy_consumption_tarif_1') }}, {{
states('sensor.remote_energy_consumption_tarif_2') }}, {{
states('sensor.remote_energy_production_tarif_1') }}, {{
states('sensor.remote_energy_production_tarif_2') }}, {{
states('sensor.remote_gas_consumption') }}, {{
states('sensor.remote_smartelec_current_marketprice') }}, {{
states('sensor.remote_huidige_gas_marktprijs') }}
I wanted to test the new code by adding a new logfile:
which is confirmed:
resulting in:
Finally I changed the entity name to be more descriptive:
This didn’t change anything in the Integration Entries screen, so I changed that as well via the 3dot-menu=>rename:
Then i made a new automation with this action:
service: notify.send_message
target:
entity_id: notify.mytestfile
data:
message: >
{{ states('sensor.remote_date_time') }}, {{
states('sensor.remote_energy_consumption_tarif_1') }}, {{
states('sensor.remote_energy_consumption_tarif_2') }}, {{
states('sensor.remote_energy_production_tarif_1') }}, {{
states('sensor.remote_energy_production_tarif_2') }}, {{
states('sensor.remote_gas_consumption') }}, {{
states('sensor.remote_smartelec_current_marketprice') }}, {{
states('sensor.remote_huidige_gas_marktprijs') }}
When I run this automation, the file config/www/mytestfile.csv is created and a log line is added to it.
Everything works as expected, so I want to move this config to production.
First I renamed the legacy notifiers to:
- notify.utility_hourly0
- notify.utility_with_prices_hourly0
Then I changed the new notifier:
Name from: mytestfile to: utility_hourly
Entity_id from: notify.mytestfile to: notify.utility_hourly
I also changed the config entry name:
And I disabled the legacy config by renaming the config file to config/notifiers/file.yaml0 and restarting Home Assistant.
Finally I changed the automation as well:
service: notify.send_message
target:
entity_id: notify.utility_with_prices_hourly
data:
message: >
{{ states('sensor.remote_date_time') }}
# rest of template truncated for readability
When I run this automation, The log is still written to config/www/mytestfile.csv
- I reloaded the yaml config, but this didn’t change the behavior
- I restarted Home Assistant, but this didn’t change the behavior
- I also removed config/www/mytestfile.csv, but running the automation just recreates the file.
I checked with the dev tools:
but here the file name that is written to is not visible/available.
I solved this (workaround) by creating a new notifier with the correct filename, but in a year or so I won’t remember the details of this config. As all changes are in names only, my question still is:
Where can I view/change the filename the notifier is writing to?
Another use case: If I want to add the timestamp, where can I enable that afterwards? I see this setting only when creating the notifier entry…