Modbus - reported number incorrect

Hi,
not sure how to describe this. I have a heat pump which uses the following yaml to change the set temperature in the controller. The set point requires it to be x2 +60 to be sent to the heat pump for use.
This works great. But now the modbus number returned is always x2+60 instead of just returning back “x” on its own without the mathematics being applied to it.

Is there a way to alter this reported number being stored, ideally i need to divide by 2 and subtract 60 for it to report the correct figure. If i set it to 60 deg, the reported figure back is always 180 instead of 60.

Thanks

number:
  - platform: modbus_controller
    modbus_controller_id: device_addr_1
    name: "Set Target Temperature"
    id: set_target_temp
    register_type: holding
    address: 1104
    value_type: U_WORD
    mode: BOX
    skip_updates: 0
    min_value: 10
    max_value: 60
    step: 1
    write_lambda: |-
      return (x*2) + 60;  

So if you set the number 60, your request would be 60x2+60=180.
What doesn’t match here?

Correct. But I’d like the return value from ESPhome to be 60. not 180, essentially have the calculation take part without the user even knowing it.

Try with lambda

lambda: |-
  return (x - 60) / 2;
write_lambda: |-
  return (x*2) + 60;
1 Like

Thanks I knew I was close with the lambda stuff. I just didnt know where to go. Fixed!

You’re welcome!