I have the following set up:
notify:
- platform: file
name: Energy Midnight
filename: /config/readings/Energy.txt
shell_command:
delete_energy: 'rm /config/readings/Energy.txt'
sensors:
- platform: file
name: 'Import Midnight'
file_path: /config/readings/Energy.txt
value_template: '{{value_json.Import}}'
- platform: file
name: 'Export Midnight'
file_path: /config/readings/Energy.txt
value_template: '{{value_json.Export}}'
- platform: file
name: 'Generate Midnight'
file_path: /config/readings/Energy.txt
value_template: '{{value_json.Generate}}'
automation:
- alias: Energy Readings
id: '1524401320302'
trigger:
- at: 00:00:00
platform: time
action:
- service: shell_command.delete_energy
- service: notify.energy_midnight
data_template:
message: >-
{ "Import" : "{{states.sensor.grid_import_active_energy.state}}",
"Export" : "{{states.sensor.grid_export_active_energy.state}}",
"Generate" : "{{states.sensor.solar_import_active_energy.state}}" }
The automation produces the following text file at midnight:
Home Assistant notifications (Log started: 2018-04-29T17:36:21.386964+00:00)
--------------------------------------------------------------------------------
{ "Import" : "36557.53", "Export" : "10348.46", "Generate" : "21467.02" }
I have created sensors to read these values when required.
The problem is that these sensors are not visible in the States tab. Tried to look at the docs but could not spot what I am doing wrong.
If anyone can please heeeelp!!
Thank you.