I have a MQTT sensor reporting the temperature to home assistant. The sensor is off by a few degrees so I would like to adjust it in HA. I can’t seem to be able to figure out the template that would do that. I want to subtract x number of degrees from the sensor value before displaying it. How could I make this work? It seems like I can’t do a subtract or add in a template, only a multiply. I tried that but it gave a very strange number. or a different error.
Current Configuration:
mqtt:
broker: 127.0.0.1
port: 1883
client_id: home-assistant-1
username: pi
password: raspberry
sensor:
- platform: mqtt
state_topic: 'sensor/mbc/1/it/nasa_library/temperature'
name: 'Library NASA Temp'
unit_of_measurement: '°F'
- platform: mqtt
state_topic: 'sensor/mbc/1/it/nasa_library/humidity'
name: 'Library NASA Humidity'
unit_of_measurement: '%'
- platform: mqtt
state_topic: 'sensor/mbc/1/it/nasa_library/barometer/inchHg'
name: 'Library NASA Pressure'
unit_of_measurement: 'inHg'
- platform: mqtt
state_topic: 'climate/library_nasa_fan/status'
name: 'NASA Fan Status'
- platform: template
sensors:
library_nasa_temp:
value_template: "{{ states.sensor.library_nasa_temp.state | minus(5) }}"
friendly_name: "NASA Temp Adjusted"
unit_of_measurement: "°F"
switch:
- platform: mqtt
name: Library NASA Ventilation Fan
command_topic: "climate/library_nasa_fan/control"
state_topic: "climate/library_nasa_fan/status"
payload_on: "1"
payload_off: "0"
retain: true
- platform: mqtt
name: Library LED Lights
command_topic: "lighting/library/led_strips/control"
state_topic: "lighting/library/led_strips/status"
payload_on: "1"
payload_off: "0"