Hi,
To monitor a misbehaving heater in my bathroom I created an automation that checks the temperature every 5 minutes, and sends an e-mail when the temperature is above 22 deg C.
This is the automation code:
- id: '1669620829612'
alias: ENV - Badkamer temperatuur hoog
description: ''
trigger:
- platform: time_pattern
minutes: /5
- platform: numeric_state
entity_id: sensor.cal_vik_temp
for:
hours: 0
minutes: 0
seconds: 10
above: 22
condition:
- condition: numeric_state
entity_id: sensor.cal_vik_temp
above: 22
- condition: numeric_state
entity_id: sensor.buiten_temperature
below: 18
action:
- service: notify.mailnotify
data:
message: 'De badkamertemperatuur is boven de 22 °C terwijl de buitentemperatuur
onder de 18 °C is.
De temperatuur in de badkamer is nu: {{ states.sensor.cal_vik_temp.state }}
°C.
De temperatuur buiten is nu: {{ states.sensor.buiten_temperature.state }}
°C.
'
title: Badkamertemperatuur > 22 °C
mode: single
This automation works as expected.
It is already a pretty old automation, but as far as I remember this automation was entirely made via the HA Automations Frontend UI (may be except for the Notification part?).
However, I now get this Warning log entry whenever I reload the Template Entities YAML configurations on the Developer Tools → YAML page:
Logger: homeassistant.components.homeassistant.triggers.numeric_state
Source: components/homeassistant/triggers/numeric_state.py:185
Integration: Home Assistant Core Integration (documentation, issues)
First occurred: March 3, 2023 at 09:34:58 (48 occurrences)
Last logged: 13:48:52
Error in ‘ENV - Badkamer temperatuur hoog’ trigger: In ‘numeric_state’ condition: no entity specified
Note that when I trigger the automation or reload the Automations YAML configurations this error is not logged.
I am not sure, but it could be that this only started after upgrading HA to 2023.3.1 or 23023.3.0 because I cannot find any of these log entries in logs from older versions of HA.
Can someone please explain why this error is logged, and whether this is an error in the automation or a bug in HA?
If it is an error in the automation, then how can this be resolved?
And why is this problem specifically and only triggered by reloading the Template Entities YAML configurations on the Developer Tools → YAML page?
When I’ve had similar errors I think they were caused by quotes being misinterpreted/misused… I would try a multi-line quote designator and update the templates to use the states() function instead of the state object method.
action:
- service: notify.mailnotify
data:
message: >
De badkamertemperatuur is boven de 22 °C terwijl de buitentemperatuur
onder de 18 °C is.
De temperatuur in de badkamer is nu: {{ states('sensor.cal_vik_temp') }} °C.
De temperatuur buiten is nu: {{ states('sensor.buiten_temperature') }} °C.
Thanks Drew,
Yes, I already did change to the states() function, and I now also did some modifications to the quotes, but it does not make any difference.
This is what I have now:
- id: '1669620829612'
alias: ENV - Badkamer temperatuur hoog
description: ''
trigger:
- platform: time_pattern
minutes: /5
- platform: numeric_state
entity_id: sensor.cal_vik_temp
for:
hours: 0
minutes: 0
seconds: 10
above: 22
condition:
- condition: numeric_state
entity_id: sensor.cal_vik_temp
above: 22
- condition: numeric_state
entity_id: sensor.buiten_temperature
below: 18
action:
- service: notify.mailnotify
data:
message: "De badkamertemperatuur is boven de 22 °C terwijl de buitentemperatuur
onder de 18 °C is.
De temperatuur in de badkamer is nu: {{ states('sensor.cal_vik_temp') }}
°C.
De temperatuur buiten is nu: {{ states('sensor.buiten_temperature') }} °C.
"
title: Badkamertemperatuur > 22 °C
mode: single
What exactly do you mean by “multi-line designator”?
This still is in the legacy (not modern) format, but that should not make a difference, does it?
I did a full restart, and that does not produce these warnings.
Any ideas?
When your template is across multiple lines or contains line breaks, instead of using " or ', you should use | or >. These are block-style indicators used in HA yaml to indicate that whatever follows them should be treated like it is enclosed in quotes.
Ah, I see.
Is this in my case about the “message:” part of the code?
The received e-mail do look OK however:
De badkamertemperatuur is boven de 22 °C terwijl de buitentemperatuur onder de 18 °C is.
De temperatuur in de badkamer is nu: 18.4 °C.
De temperatuur buiten is nu: 4.1 °C.
- id: '1669620829612'
alias: ENV - Badkamer temperatuur hoog
description: ''
trigger:
- platform: time_pattern
minutes: /5
- platform: numeric_state
entity_id: sensor.cal_vik_temp
for:
hours: 0
minutes: 0
seconds: 10
above: 22
condition:
- condition: numeric_state
entity_id: sensor.cal_vik_temp
above: 22
- condition: numeric_state
entity_id: sensor.buiten_temperature
below: 18
action:
- service: notify.mailnotify
data:
message: >
De badkamertemperatuur is boven de 22 °C terwijl de buitentemperatuur onder de 18 °C is.
De temperatuur in de badkamer is nu: {{ states('sensor.cal_vik_temp') }} °C.
De temperatuur buiten is nu: {{ states('sensor.buiten_temperature') }} °C.
title: Badkamertemperatuur > 22 °C
mode: single
The automation still works, but unfortunately I still get these same warnings when I reload the Template Entities YAML configurations on the Developer Tools → YAML page.
So it is still unclear to me where this comes from.
When you reload template entities, sensors like the one you configured are reloaded thus creating the error. I’m not sure how to get rid of that error outright.
Ok, I can accept this, but it still looks like this is only happening after upgrading to HA version 2023.3.1 or 23023.3.0 because I cannot find any of these log entries in logs from older versions of HA, and nothing has been changed to this specific automation and sensor code of my HA instance since months.
So is this a bug in the latest HA versions?
Is anybody else seeing these type of log entries since HA version 2023.3.1 or 23023.3.0?