New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template sensor value_template will generate 'no default' errors if availability_template renders false. #57287
Comments
I’m using the new way of how to do templates and I have the same behavior. It’s like the Error:
Code: - binary_sensor:
- name: "Ventilo Cave"
unique_id: XXX
device_class: moving
state: >-
{{ states('sensor.cave_th_humidity')|float >= 60
and states('sensor.cave_th_humidity')|float >=
(states('sensor.jardin_th_humidity')|float + 5) }}
availability: >-
{{ states('sensor.cave_th_humidity') not in ['none', 'unknown', 'unavailable']
and states('sensor.jardin_th_humidity') not in ['none', 'unknown', 'unavailable'] }} |
@emontnemery Sorry to tag you here but you were the one working on #56453 Is there something we can do? |
exactly the same thing happening with me. Logically, if Availability is rendered true, state should not be rendered. |
Hey there @PhracturedBlue, @tetienne, @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration ( template documentation |
The availability template does not block rendering of other templates, it just means the entity's state will be set to |
I gave it a shot. |
That's right, it will require some changes to |
This is an attempt of suppressing errors when the availability template doesn't render as |
@emontnemery I'm still seeing these logs using HA 2021.11.3:
|
@mbo18 OK, what's the configuration of the template entity which complains? |
Not all but these 3 for sure:
|
Can you enable these logs and attach a log when it happens again: logger:
default: info
logs:
homeassistant.core: debug
homeassistant.components.template: debug
homeassistant.helpers.event: debug |
I can't reproduce the problem
|
It happen each time I restart HA. I'm sure that I'm currently running latest release of HA (updated this morning to 2021.11.3 on HAOS 6.6). I do not use custom components nor custom frontend code. I have no local modifications of HA. |
I have the same problem with 2021.11.3. Example:
The resulting state of the sensor is |
@mbo18 please contact me on discord, emontnemery#6618, if you don't want to publish the log here |
@gfrancesco Can you collect and share a log too please? |
Below the log lines that refer to I'll just give you an overview of the sensors involved:
- name: "Inv-1 E"
state: "{{ states('sensor.inverter_1').split(',')[0] | int(default='NaN') }}"
- name: "Inv-1 V DC"
state: "{{ states('sensor.inverter_1').split(',')[1] | int(default='NaN') }}"
- name: "Inv-1 I DC"
state: "{{ states('sensor.inverter_1').split(',')[2] | int(default='NaN') }}"
- name: "Inv-1 V AC-1"
state: "{{ states('sensor.inverter_1').split(',')[3] | int(default='NaN') }}"
- name: "Inv-1 V AC-2"
state: "{{ states('sensor.inverter_1').split(',')[4] | int(default='NaN') }}"
- name: "Inv-1 V AC-3"
state: "{{ states('sensor.inverter_1').split(',')[5] | int(default='NaN') }}"
- name: "Inv-1 I AC-1"
state: "{{ states('sensor.inverter_1').split(',')[6] | int(default='NaN') }}"
- name: "Inv-1 I AC-2"
state: "{{ states('sensor.inverter_1').split(',')[7] | int(default='NaN') }}"
- name: "Inv-1 I AC-3"
state: "{{ states('sensor.inverter_1').split(',')[8] | int(default='NaN') }}"
- name: "Inv-1 Power Factor"
state: "{{ states('sensor.inverter_1').split(',')[9] | float(default='NaN') / 1000 }}"
- name: "Inv-1 P"
state: "{{ states('sensor.inverter_1').split(',')[10] | float(default='NaN') / 100 }}"
- name: "Inv-1 f"
state: "{{ states('sensor.inverter_1').split(',')[11] | float(default='NaN') / 100 }}" All the template sensors above share the same availability template via this customize glob: "sensor.inv_1_*":
availability: >-
{{ states('sensor.inverter_1') not in ['unavailable', 'unknown', 'none'] }} When there is no sun, the inverter shuts down, at this point I can see that
|
You can't use |
Didn't know about that, is it documented somewhere? - name: "Inv-1 E"
state: "{{ states('sensor.inverter_1').split(',')[0] | int(default='NaN') }}"
availability: "{{ states('sensor.inverter_1') not in ['unavailable', 'unknown', 'none'] }}" The first sensor looks like it works (no more
|
Please share a log showing both the state change of |
Here is a state change during startup. Starts as As far as I can see it is only raising this errors on HA startup, I looked at when the inverter shuts off at sunset (state goes into
|
Template errors during startup is fixed by #59827 which will be included in Home Assistant Core 2021.12. |
The problem
With templates sensors, I used to be able to do input validation exclusively via the
availability_template:
template feature.Prior to 2021.10 if
availability_template
renders false, whatvalue_template
renders to was irrelevant because availability_template took precedence and forced the state to unavailable. The rendering ofvalue_template
at least from the user's perspective was seemingly blocked.After 2021.10 if
availability_template
renders falsevalue_template
is still rendered and checked for any filter default value errors and logged when the expected behavior is to completely disregard the rendered value or not render the template at all.This new behavior requires input validation/default filter values to be added to
value_template
for the sole purpose of avoiding spamming the log whenavailability_template
was enough to handle error checking on its own.What is version of Home Assistant Core has the issue?
2021.10.0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
template
Link to integration documentation on our website
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response
The text was updated successfully, but these errors were encountered: