Compare string and float #121
Replies: 1 comment
-
this is more of a js question, than an issue with custom-ui, so please search the community or simply google. you need ParseFloat() to do that
or:
closing, and happy to help in the community if still not working |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
TLDR: Is there a way I can convert in customize.yaml the state type to compare two entities? Example, convert the state from string to float.
Hi,
I have a lot of customization in customize.yaml working perfectly, but the one on my temp sensors do not work correctly when the temperature goes below 10 degrees, it uses the "hot" color (red) instead of the "cold" color (blue).
Interestingly, it works correctly with "warm" (orange - above 25 degrees), "hot" (red - above 28 degrees), and "normal" (green - between 10 and 25 degrees), so it is only with the "cold" (below 10 degrees) that I get an unexpected color.
Config in customize.yaml:
Example,
sensor.temp_and_humidity_sensor_outdoor
has 6 degrees, but it getsred
instead ofRoyalBlue
.Trying to understand why, I did some tests in the Developer_Tools/Template.
When I compared without converting the type, it gives
False
, where it "should" beTrue
:{{ states('sensor.temp_and_humidity_sensor_outdoor') <= states('input_number.climate_temperature_outdoor_cold_indicator') }}
When I try to change one, any of them to float, using | float, I get a msg saying I can't compare
str
andfloat
, so it means both are string:or
True
, what should be what I need:So, it there a way I can convert in customize.yaml from str to float? If so, I will convert both, the sensor and the input_number) to float.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions