iantrich / config-template-card

πŸ“ Templatable Lovelace Configurations
MIT License
425 stars 55 forks source link

Variables with addition are adding decimal places and not whole numbers #120

Closed ghallford closed 1 year ago

ghallford commented 1 year ago

Checklist:

Release with the issue: 1.3.6

Last working release (if known):

Browser and Operating System: Chrome, Windows 11

Description of problem: I am trying to put in a gauge graph, where there is a yellow and red for to low and yellow and red for too high. The low part work fine but the high part, using the addition doesn't add properly.

If I set "input_number.probe4targettemp" to 250. Expected vars are:

vars[0] = 230 vars[1] = 210 vars[2] = 270 vars[3] = 290

What I am getting is this:

vars[0] = 230 vars[1] = 210 vars[2] = 250.020 vars[3] = 250.040

Why???? Addition is adding decimal places and not whole numbers

Here is the yaml.

Javascript errors shown in the web inspector (if applicable):

Additional information:

ildar170975 commented 1 year ago

Do not think this is a bug. Each variable is a STRING. Using β€œ+” causes concatenating β€œ250.0” and β€œ40” which gives β€œ250.040”. Using β€œ-β€œ causes converting both values to integers and gives β€œ210”. To avoid any issues I usually use something like: parseFloat(states['input_number.probe4targettemp'].state) - 20

ildar170975 commented 1 year ago

An answer was provided, no further remarks were added. Closing as solved.