frontend
frontend copied to clipboard
UI Testing of Automation Conditions Does Not Work with Template Conditions
The problem
In order to implement a somewhat more complex template condition, I came across the problem that (at least testing) templates conditions do not work (anymore).
What I did:
Create a simple automation having a template condition:
- condition: template
value_template: "{{ 1 > 2 }}"
So, this is extremely simplifed. The expression should return False, but instead I get the following error when testing this expression in the condition frontend (under automatisations):
Error handling message: template value should be a string for dictionary value @ data['value_template']. Got None (invalid_format)
If I enter the same snippet of code in the templates section un der developer tools, it prints false.
Either there is a problem in the code just adding the template condition in the automatisation frontend or something is completely borked.
What version of Home Assistant Core has the issue?
2022.4.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Automation
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
- condition: template
value_template: "{{ 1 > 2 }}"
Anything in the logs that might be useful for us?
2022-04-08 14:40:54 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140209354674720] Error handling message: template value should belue_template']. Got None (invalid_format)
Additional information
No response
Same issue here!
Just to be clear, in my experience it's only the actual test button that doesn't show the correct result, the template itself and the automation condition still work as expected.
I am new to Home Assistant, but I am having what I believe to be the same issue. I am attempting to trigger off the following value_template “{{ is_state_attr('fan.fanlinc_51_d1_37_fan', 'percentage', 33) }}” . The trigger never runs. But it returns the correct true or false in the developer tools, and it gets this error message from test if I try to use it as a condition instead of a trigger: "template value should be a string for dictionary value @ data['value_template']. Got None". So the difference for me from what Plawasan commented is that the automation does not trigger as I would expect it to when using the value_template as a trigger, and if I trigger on the device state change, and add the template as a condition, it appears that the condition is not satisfied and the automation doesn't trigger. This is 2022.4.5 running in a VM using VMWare Player 16.
I am having exactly this issue with automations that worked in earlier versions (although I cannot tell you what version this started showing up). These automations show up in the log file as an Error evaluating condition, same with using the test buttons although conditions are satisfied with developer mode.
The conditions take the form of:
{{ ( as_timestamp(now()) - as_timestamp(states.automation.automation_name.attributes.last_triggered) |int(0) ) > 86400 }}
let me know if there is anything useful I can add.
I have the same issue:
condition: template value_template: '{{is_state (''input_boolean.watering'',''on'')}}'
Same here, was thinking that my template doesn't work but it seems like it's a bug in UI
Same
I'm getting that same error on this condition:
{{ (states.sensor.wk_temperatuur_vloerverwarming_cv_in|float(999.0) - states.sensor.wk_temperatuur_vloerverwarming_vloer_uit|float(0.0)) <= 1.0 }}
Don't use the test "feature", go to Template and test it there, better this way, till they will fix it...
I have the same issue
ha 2022.4.5 on Ubuntu 20.04.2 LTS
I have the same issue
ha 2022.4.5 on Ubuntu 20.04.2 LTS
I have the same issue
ha 2022.4.5 on Ubuntu 20.04.2 LTS
Currently updated to 2022.4.7 the problem is still
Same issue 2022.4.7 on Hyper-V
I'm having the same issue
Same here, in my case the error blocks the condition of the automation, so the automation does not start when it should. It was working fine in previous HA versions, so I can confirm it's a bug introduced in the last couple of months maybe.
Oh my gosh I've been wracking my brains over this for past hour until I stumbled upon this bug report - didn't realise but YES what I've been dong IS working, it's just the editor that's popping up the error.
Same problem here this template in developer tools works good, but in automation return an error: {{ states.sensor.uptime_raspberry_tv.state | float < 30 }} The error is template value should be a string for dictionary value @ data['value_template']. Got None
Same here, in my case the error blocks the condition of the automation, so the automation does not start when it should. It was working fine in previous HA versions, so I can confirm it's a bug introduced in the last couple of months maybe.
That will be something else, because the templates regarding this issue will work fine in the automation. It is just the test button which throws an error. Put your template in developer tools > templates and check if it works there
I have this problem too. Is there anything being done about it?
I have also experienced this problem with well-formed templates that work in the Developer Tools section and in actual automations.
Same problem on 2022.6.1
Same Problem! Home Assistant Core 2022.6.1 Home Assistant Supervisor 2022.05.3 Home Assistant OS 8.1
Same Problem, unfortunately. Home Assistant Core 2022.6.4
I am having the same issue however my automation does not run. The template statement works in Dev tools but not in the automation
@petebanham: my automation also stopped working. Have a look at https://community.home-assistant.io/t/automation-template-value-should-be-a-string-for-dictionary-value-data-value-template-got-none/419519
Can anyone explain why nothing is being done about this as I don't understand how this works/when/how it gets addressed.
Having same issue still on 2022.6.5. My automation does not trigger, but the template checks out fine in dev tools.
I have a simple template to evaluate the battery level of my Shark vacuum.
{{state_attr('vacuum.vicky', 'battery_level') > 85 }}
In the Dev tools -> Template I get a true or false response as expected. In an automation window get the error:
Error occurred while testing condition template value should be a string for dictionary value @ data['value_template']. Got None
I too ran into the same issue (HA 2022.6.3), and have made an observation which may be useful to those with the necessary insight into the inner workings of the automation function. I have a temperature sensor on my water heater, and control over the element, and I also set up an input_number slider to control the target temperature. Switching off uses the following template in the trigger section:
{{
states('sensor.geyser_temperature')|float >=
states('input_number.geyser_target_temp')|float
}}
I.e. trigger when the actual temperature equals or exceeds the target. And this works just fine, both simulated in Dev Tools, and in operational practice.
HOWEVER
The element is switched on at a specific time (and/or when the solar panels are producing nicely), but we need to check that the water is actually cold before doing so: hence we take that very same code above, just changing the comparison to a less-than <, and put it in the Conditions section, instead of in Triggers, and immediately we get the same error:
Error occurred while testing condition template value should be a string for dictionary value @ data['value_template']. Got None
So it seems to work as a Trigger, but not as a Condition. (Also, less importantly, the Test function is available right in the Automation UI editor for template code added under Conditions, but not under Triggers. To this untrained eye the two seem rather similar, so it was natural to wonder if there is maybe some structural variation under the hood necessitating this difference, and if this perhaps also pertains to the difference in behaviour that is observed.)
With much respect and gratitude to those who labour on behalf of us unwashed masses, to make the world a better, or at least more automated and entertaining place.
@JohanViljoen it will also work as a condition, it is just the check button which will display the error, the condition will actually work fine.
For testing triggers in the GUI it works different, as a trigger is just a moment where something turns from false
to true
it makes no sense to have a similar button as on a condition. When the trigger occurs, the GUI will show a green bar which you can click to show the details.
Wow, I was debugging some automatisation code for over an hour what appears to be OK code all along! Damn! HASS OS 2022.6.4
Same problem here: core version 2022.6.6