Simple if case

Hi,

I tried to change colour depending on a value and get this error.
Error: string > float not implemented

temp_in = data['state']		

if temp_in > 20.0:
	col_in="#a00" # röd
else:
	col_in="#0a0" # grön

I know that the value is in the format xx.x

Any suggestions?

Thanks

You need to convert the string to a float. For example:

if float(temp_in) > 20.0:
1 Like

Thanks!

It worked if I did like this

if float(temp_in) > 20:

I wonder a little bit if i wanted to use the decimal how would that look since it did not accept 20.0

Out of curiosity, what error do you get? I don’t have the full context of your program, but that statement works for me with the decimal.

Very strange I must say.
Today when I tried it works as it should even with a decimal.

Strange