I am writing data from sensors to a file with:
configuration.yaml:
notify:
- platform: file
name: filenotify
filename: /share/Temper.csv
timestamp: true
automation:
- alias: sensor_values_to_file
initial_state: 'on'
trigger:
- platform: time_pattern
minutes: '/ 5'
action:
- service: notify.filenotify
data_template:
message: "; {{states.sensor.shelly1_f4cfa2e47733_temperature_2.state}}; {{states.sensor.shelly1_f4cfa2e47733_temperature.state}}"
It works very well
But since I have my other Automations not showing up in UI I wrote in the configuration.yaml
automation:! include automations.yaml
now I see the other automations, but no longer “sensor_values_to_file” and it is no longer executed
If I now write in the automations.yaml
- id: '1611772681272'
alias: sensor_values_to_file
initial_state: 'on'
trigger:
- platform: time_pattern
minutes: '/ 5'
seconds: 00
action:
- service: notify.filenotify
data_template:
message: "; {{states.sensor.shelly1_f4cfa2e47733_temperature_2.state}}; {{states.sensor.shelly1_f4cfa2e47733_temperature.state}}"
comes the mistake
Error loading /config/configuration.yaml: mapping values are not allowed here in “/config/automations.yaml”, line 37, column 18 (initial_state: ‘on’)
The problem with automation sensor_values_to_file is that you are mentioning initial state. please remove it and try. Initial value on is no longer valid.
If you have added automation:! include automations.yaml
to the configuration, HA will only read automations from that file. If you still have any automations in configuration.yaml, it wont be loaded. You will have to copy that to automation.yaml.
Also if you are adding automations by directly editing the automations.yaml, then you wont be able to edit them in UI, this is because those created in UI have an ID which is not there with directly editted ones. You can give an arbitrary id to the automation, so that it can be editted in UI again.
Here are my configurations that don’t work
configuration.yaml
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
media_player:
- platform: dlna_dmr
url: http://192.168.xxx.xxx:2870/dmr.xml
#media_player:
# - platform: lg_netcast
# host: 192.168.xxx.xxx
# Example configuration.yaml entry
sensor:
- platform: systemmonitor
resources:
- type: disk_use_percent
arg: /home
- type: memory_free
- type: disk_free
arg: /
- type: processor_use
- type: processor_temperature
- type: last_boot
notify:
- platform: file
name: filenotify
filename: /share/Temper.csv
timestamp: true
#automation:
# - alias: sensor_values_to_file
# initial_state: 'on'
# trigger:
# - platform: time_pattern
# minutes: '/5'
## seconds: 00
# action:
# - service: notify.filenotify
# data_template:
# message: ";{{ states.sensor.shelly1_f4cfa2e47733_temperature_2.state }};{{ states.sensor.shelly1_f4cfa2e47733_temperature.state }}"
automation: !include automations.yaml
automations.yaml:
- id: '1611741889596'
alias: OneplusAusschaltenLaden
description: kuku
trigger:
- platform: numeric_state
entity_id: sensor.oneplus_7t_akkufullstand
above: '35'
condition: []
action:
- type: turn_off
device_id: 52ce05ed1a1b73fd088185282a5c4e1a
entity_id: switch.steckdose_03
domain: switch
mode: single
- id: '1611772681271'
alias: Steckdose3Aus
description: Wenn steckdose 2 geschalte wir soll was mit der 3 passieren
trigger:
- platform: device
type: turned_on
device_id: 09944db20ce4dbd9e169c2064090923c
entity_id: switch.steckdose_02
domain: switch
for:
hours: 0
minutes: 0
seconds: 1
condition: []
action:
- type: turn_off
device_id: 52ce05ed1a1b73fd088185282a5c4e1a
entity_id: switch.steckdose_03
domain: switch
mode: single
- id: '1611772681272'
alias: sensor_values_to_file
initial_state: 'on'
trigger:
- platform: time_pattern
minutes: '/5'
seconds: 00
action:
- service: notify.filenotify
data_template:
message: ";{{ states.sensor.shelly1_f4cfa2e47733_temperature_2.state }};{{ states.sensor.shelly1_f4cfa2e47733_temperature.state }}"
Please remove this initial_state: 'on'
. It is no longer supported. Then save, check config for any errors, restart.
1 Like
try this
- id: '1611772681272'
alias: sensor_values_to_file
initial_state: 'on'
trigger:
- platform: time_pattern
minutes: '/5'
seconds: 00
action:
- service: notify.filenotify
data_template:
message: ";{{ states.sensor.shelly1_f4cfa2e47733_temperature_2.state }
1 Like
your trigger need to be in the same column like the alias and id
1 Like
@deluxestyle Thank you
it is working
@sheminasalam
also with initial_state: ‘on’
Since I don’t have what it is for, I leave it in
initial_state is just for the state after a reboot. you can leave it out. it will keep the state as the automation had before the reboot.
1 Like
tom_l
January 28, 2021, 1:10pm
10
See: https://www.home-assistant.io/docs/automation/yaml/#automation-initial-state
It should be
initial_state: true
i.e. Use the boolean true
not the string 'on'
.
It will also work with the boolean on
,
initial_state: on
No quotes around on
mean it is a boolean type (true/false), not a string (sequences of characters).