I have a very simple condition that is not working correct. It is returning true and it should be false.
This is my code:
- condition: template
value_template: >-
{{ trigger.to_state.attributes.warning_count !=
trigger.from_state.attributes.warning_count }}
When I check values in trace I can see that to and from values are both 0.
I am on version 2022.12.8
Any idea what am I doing wrong?
What do you mean by “not working correct”?
If you are using the condition tester in the UI automation editor… there is a bug in the tester that makes it unable to correctly assess template conditions. Also, the trigger
variable is undefined until a trigger fires, so it likely be untestable even if the tool could do template conditions.
I know that I cannot test it with UI as I have trigger variable.
When I say it is not working, I mean it returns wrong result.
Executed: 2 January 2023 at 08:16:06
Result:
result: true
trigger:
id: stadt_mettmann
idx: '0'
alias: null
platform: state
entity_id: sensor.warnwetter_stadt_mettmann_advance_warning_level
from_state:
entity_id: sensor.warnwetter_stadt_mettmann_advance_warning_level
state: '0'
attributes:
region_name: Stadt Mettmann
region_id: 805158024
last_update: '2023-01-02T06:46:06.654000+00:00'
warning_count: 0
attribution: Data provided by DWD
icon: mdi:close-octagon-outline
friendly_name: Warnwetter Stadt Mettmann Advance Warning Level
last_changed: '2023-01-02T05:31:06.450326+00:00'
last_updated: '2023-01-02T06:46:06.682720+00:00'
context:
id: 01GNRKNWJT44QVHW0GENGX5AQ9
parent_id: null
user_id: null
to_state:
entity_id: sensor.warnwetter_stadt_mettmann_advance_warning_level
state: '0'
attributes:
region_name: Stadt Mettmann
region_id: 805158024
last_update: '2023-01-02T07:16:06.668000+00:00'
warning_count: 0
As you can see, from and to values for warning_count are both 0.
Ok, I figured it out. I had one additional condition that was disabled. Not sure why but when condition is disabled it returns always true and as parent condition was with “or” logic it always returned true.
This is definitelly wrong behaviour as disabled conditions should not make any conflicts.
1 Like
I and several others did report this in the past already. The answer was always, that it is expected and wanted behavior. Whyever.
Ok lol, sometimes things are not logically designed, but good thing is that it can be solved by simply deleting disabled condition.