brunombo
(Bruno gascogne)
1
Hello Team
i have created two sensors, and i want to be notified if the value is not reached
the HA dev_template return me correctly the values.
{{ (state_attr(‘frigo_consomation’, ‘today_energy_kwh’)|float) > float(0.1) }}
=> send False
and it’s ok,
but when i put in automation.yaml this code,
condition:
conditions: or
- condition: template
value_template: "{{ (state_attr('frigo_consomation', 'today_energy_kwh')|float) > float(0.1) }}"
- condition: template
value_template: "{{ (state_attr('congelateur_consomation', 'today_energy_kwh')|float) > float(0.1) }}"
at verfication time i have the message:
Error loading /config/configuration.yaml: mapping values are not allowed here
Thanks for yours help.
Bruno
lolouk44
(lolouk44)
2
Can you format your code using the blue bar on top? Sounds like an indentation issue but without formatting your code correctly I can’t verify this
brunombo
(Bruno gascogne)
3
i have simplified the code
this one is ko:
condition:
condition: template
value_template: '{% if (value.congelateur_consomation |float) < float(0.3)%}true{%else%}false{%endif%}'
and this one too; ko
condition:
condition: template
value_template: "{{ (state_attr('frigo_consomation', 'today_energy_kwh')|float) > float(0.1) }}"
lolouk44
(lolouk44)
4
on your first code example, there are missing indentations
Try this and see if it passes the code check:
condition:
conditions: or
- condition: template
value_template: "{{ (state_attr('frigo_consomation', 'today_energy_kwh')|float) > float(0.1) }}"
- condition: template
value_template: "{{ (state_attr('congelateur_consomation', 'today_energy_kwh')|float) > float(0.1) }}"
brunombo
(Bruno gascogne)
5
this one is ok, run nice :
alias: verif frigo
trigger:
- at: '18:30:00'
platform: time
condition:
- condition: template
value_template: "{{ (state_attr('frigo_consomation', 'today_energy_kwh')|float) < float(0.6) }}"
action:
- data:
message: problème consomation frigo trop faible
title: verif frigo problème frigo consomation
service: notify.flocknotification
thanks for answers
123
(Taras)
6
Why does the template use the float
filter here:
< float(0.6)
when this is the same thing and involves one less conversion:
< 0.6