home-assistant.io
home-assistant.io copied to clipboard
value_template not work
Feedback
Example not allowed in 2022.5.4
URL
https://www.home-assistant.io/docs/automation/condition/
Version
2022.5.4
Additional information
Test Conditions are not only strings. Value_template not worked with numeric
I have tried to re-create this and also got the same error message as your second screenshot when i press the Test button on the condition.

The automation I created saved without any validation issue so not sure why it's giving the error message.
This is what it generated in my YAML file:
- id: '1652617644447'
alias: New Automation
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.office_motion
to: 'on'
condition:
- condition: template
value_template: '{{ state_attr(''sun.sun'', ''elevation'') < 4 }}'
action:
- service: scene.turn_on
data: {}
target:
entity_id: scene.office_main_light_on
mode: single
The test button is to be expected, and has an open issue report @ the frontend (red herring).
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved. If this issue is still relevant, please let us know by leaving a comment 👍 This issue has now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Error has not been eliminated

alias: Neue Automatisierung description: '' trigger:
- platform: template value_template: >- {{ ( states( "sensor.min_eco_temperatur" ) | float == states( "var.callmon_offset" ) | float ) }} condition:
- condition: template value_template: '{{ state_attr( "sun.sun", "elevation" ) < 4 }}' action:
- service: var.set data: entity_id: var.callmon_test value: >- {{ ( states( "sensor.min_eco_temperatur" ) | float + 0.5 - states( "var.callmon_offset" ) | float ) }} mode: single
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved. If this issue is still relevant, please let us know by leaving a comment 👍 This issue has now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.