rednas
November 9, 2021, 8:44pm
1
Hello,
I have added this in my automation:
condition: "{{ (state_attr('climate.toon_thermostaat', 'temperature')|float) > 17.0 }}"
But it still fires when the temperature equals 17.0 while it should fire when it’s over 17.0.
How is this possible?
AllHailJ
(J Gent)
November 9, 2021, 10:38pm
2
It could be a rounding error as it is cast as a float. Have you considered this:
condition: "{{ (state_attr('climate.toon_thermostaat', 'temperature')|float | round(1)) > 17.0 }}"
WallyR
(Wally)
November 9, 2021, 11:54pm
3
check the values in the developer tools.
rednas
November 10, 2021, 6:28am
4
It is really strange, as I already checked it with the developer tools.
{{ (state_attr('climate.toon_thermostaat', 'temperature')|float) > 17 }}
{{ (state_attr('climate.toon_thermostaat', 'temperature')|float|round(1)) > 17.0 }}
This produces False and False. However the automation runs even with these conditions being False.
Currently this is my trigger and condition.
trigger:
- platform: time
at: '15:00'
condition: "{{ (state_attr('climate.toon_thermostaat', 'temperature')|float|round(1)) > 17.0 }}"
Currently it doesn’t even work when the temperature is set at 16.5…
Does anyone have any idea why it doesn’t work as expected?
koying
(Chris B)
November 10, 2021, 8:14am
5
Show the full automation. There might something else than the bits you focus on.
rednas
November 10, 2021, 10:49am
6
- id: '1796441963042'
alias: Notify - Verwarming uit
description: ''
trigger:
- platform: time
at: '15:00'
condition: "{{ (state_attr('climate.toon_thermostaat', 'temperature')|float|round(1)) > 17.0 }}"
action:
- alias: Set up variables for the actions
variables:
cv_17: '{{ ''CV_17_'' ~ context.id }}'
- alias: Ask to set the heating
service: notify.mobile_app_telefoon_x
data:
message: 'Kan de verwarming naar 17°C? Nu ingesteld op: {{ state_attr(''climate.toon_thermostaat'',''temperature'')|float
}}°C'
data:
actions:
- action: '{{ cv_17 }}'
title: 17°C
- alias: Wait for a response
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ cv_17 }}'
- alias: Perform the action
choose:
- conditions:
- condition: template
value_template: '{{ wait.trigger.event.data.action == cv_17 }}'
sequence:
- service: climate.set_temperature
data:
temperature: 17
target:
entity_id: climate.toon_thermostaat
mode: single
This is the complete one!
Everything works, except the condition…
WallyR
(Wally)
November 10, 2021, 5:40pm
7
Also show the values from the developer tools.
Sometimes there is a thing that makes it fail, like some European sensors that report values with a comma instead of a dot as a decimal indicator.
rednas
November 11, 2021, 10:57am
8
This:
{{ state_attr('climate.toon_thermostaat', 'temperature') }}
{{ (state_attr('climate.toon_thermostaat', 'temperature')|float|round(1)) > 17.0 }}
Shows:
20.0
True
Or
17.0
False
So this shows exactly what I want, but doesn’t work like I want…
rednas
November 15, 2021, 1:07pm
9
So, why doesn’t this work as expected?
nanobra1n
(Nanobra1n)
November 16, 2021, 3:13pm
10
I agree that it should work. Maybe for further troubleshooting look at the trace of the automation execution next time it fails under Configuration >> Automations >> (the clock rewind button next to your Notify - Verwarming uit automation. Also see if there are any error messages in the log.