I have a template to convert radon value from Bq/m³ to pCi/L. No matter what I try, the UI overview always shows the value as 0.0 when it should be 0.27. The calculation to convert is the Bq/m³ value divided by 37. The value of Bq/m³ is 10.0. The following is what I have for my template (after testing it):
What am I doing wrong? The template tester shows correct value.
Home Assistant Core 2022.5.5
Home Assistant Supervisor 2022.05.3
Home Assistant OS 8.1
Kernel version 5.15.32-v7l
Agent version 1.2.1
Frontend version: 20220504.1 - latest
I received the following error: Invalid config for [template]: [step] is an invalid option for [template]. Check: template->sensor->0->step. (See /config/configuration.yaml, line 23).
That should work. Did you reload templates? Home assistant only truncates trailing zeros in the UI. If the template tester is showing the correct value, then the issue lies somewhere in your configuration or if you didn’t restart. Your configuration looks fine, so did you restart/reload templates?
Are you sure you are looking at the right entity and not some derelict old attempt? the unique id in the template above is not correct as far as I can tell, captital letters in it, missing domain.
Maybe the final filter converting it to string? That is not what is expected for measurements, is it? But I guess you tried that seeing your example before.
Is it also displaying 0 in the states tab of the developer view? In case it is an UI thing.
check your log for errors. The only thing that stands out is that float does not have a default and will cause issues when sensor.airthings_radon is unknown at startup.
Yep, that’s the issue.
Template warning: ‘float’ got invalid input ‘unknown’ when rendering template ‘{{ (states(‘sensor.airthings_radon’) | float / 37) | round(2) }}’ but no default was specified. Currently ‘float’ will return ‘0’, however this template will fail to render in Home Assistant core 2022.6
If I were you I’d use float(0) to get rid if the error. That will give the float filter the default it is about to be required and it will produce the 0 result. But the else should in my opinion be “unknown” for the result to be the way it should be. 0 is not the accurate representation.
But I guess it still is not working? And please do not tell me radon levels have dropped below 3 in the mean time
That works, but the value is now unavailable. Will it eventually get set? I’m still trying to figure out the order of things. BTW, thanks for the help!
Went back and read the documentation on the integration and it polls every 5 minutes. Shouldn’t it persist the value from the last poll through a restart?