I just updated my home assistant and now it appears to not like my Modbus math templates. The file check works but in HA the test fails showing it doesn’t like my data type. I did try adding int32 instead of int to everything and it did work but the result was in the thousands or millions. What do I need to do to correct this issue?

I don’t know how those ever worked. If that sensor output is hex, then the int conversion has been incorrect from the beginning. Can you post what the values of the input sensors?

They were values from a PLC. I’m not sure I think the value was say for 32.53 degrees would originally read 3253. Someone helped me come up with the template to get 32.53 degrees

Ok, but what doesn’t make sense is that you’re using ‘%0x’ as a format converter. That takes base 10 integers and converts them to base 16. For example, if your sensor.*temphex output 11, the value of your template would be b, which is not a number. So the template never worked. You were lead down the wrong path initially. So, you need to figure out what the temperature should be so we can make a correct equation.

It was to move the decimal places from what I remember. The output from the PLC to HA was 542200 or something so I assume the math was to move the decimal over to make 54.22.

Moving the decimal place is a simple division of 1000. 52000/1000 = 52. But again, your template is using `’%0x’ which changes base 10 integers to base 16.

Let me explain because it seems you still don’t follow.

Your hex sensor is: sensor.outside_temphex

Your template sensor is: sensor.outside_temp

The template for sensor.outside_temp is giving you 542000 from 88539136. That template is using %0x, which converts base 10 numbers to base 16. So if your sensor.outside_temphex were to read 11, your sensor.outside_temp would read b. is b a valid temperature? No.

So, your template is incorrect. Stop looking at sensor.outside_temp, we now need to figure out how to take the value from sensor.outside_temphex and get the correct temperature in ºF. Only you know this information.

There’s a number of ways to figure this out. Does your device output a temperature on screen (not in home assistant, on the actual device)? If yes, what is the value of sensor.outside_temphex and what is the value on screen?

Ok. I am starting to see what your saying. It has been a long while. I am not able to get to the controller now. But From what I remember it was taking an int from the controller and by the time HA received the data over LAN it was in HEX. when it was received in HEX it was then converted to an decimal again. When that happened it was 54200. Then some dude gave me a template to convert it all. All this info can be found in our discussion. This might help get caught up with what happened.

Alirght, but notice how all those posts have int(base=16) and notice how yours doesn’t? It seems you were focusing on the wrong part of the template when you were experimenting and came up with your solution.

I suggest we start over as it seems like you just tried some things and got a close answer without knowing if the answer was correct.