I would like to have a slider entity representing the temperature in a particular room (Celcius) that is synced with the HVACs modbus register (deci Kelvin). Note the transformation between Celcius and deci Kelvin.
Currently I have the following modbus configuration together with one input_number entity and sensor that are being synced with two automations. The current setup does the job, but I am hoping to find a more clever way without having to use automations.
Configuration:
modbus:
- name: hvac_modbus
type: tcp
host: 1.2.3.4
port: 502
input_number:
setpoint_room:
name: Setpoint Room
min: 18
max: 26
step: 1
unit_of_measurement: °C
icon: 'mdi:thermostat'
sensor:
- platform: modbus
scan_interval: 10
registers:
- name: setpoint_room
hub: hvac_modbus
unit_of_measurement: °C
slave: 1
register: 4014
scale: 0.1
offset: -273
To keep the slider entity and the modbus register in sync I have the following two automations (getter and setter):
- id: sliderSetSetpointTemperature
alias: Slider Set Setpoint Temperature
trigger:
platform: state
entity_id: input_number.setpoint_room
action:
- service: modbus.write_register
data_template:
hub: hvac_modbus
unit: 1
address: 4014
value: '{{ states.input_number.setpoint_room.state | int * 10 + 2730 }}'
- id: sliderGetSetpointTemperature
alias: Slider Get Setpoint Temperature
trigger:
platform: time_pattern
seconds: 10
action:
- service: input_number.set_value
data_template:
entity_id: input_number.setpoint_room
value: '{{ states.sensor.setpoint_room.state | int }}'