Currently we have “sum”, “maximum”, “media”, etc, in sensor groups, but why there isn’t subtract option to have the operation: Sensor A - Sensor B = Sensor C ?
Thank you!
Currently we have “sum”, “maximum”, “media”, etc, in sensor groups, but why there isn’t subtract option to have the operation: Sensor A - Sensor B = Sensor C ?
Thank you!
Are you aware that you can set that up easily with a template sensor?
If not, here’s an example:
- platform: template
sensors:
sensor_c:
friendly_name: "Sensor A - Sensor B = Sensor C"
value_template: >-
{{ ((states('sensor.sensor_a') | float(2))
- (states('sensor.sensor_b') | float(2))) | round(2) }}
unit_of_measurement: W
When suggesting templates it is best to use the modern format:
template:
- sensor:
- name: "Sensor A - Sensor B = Sensor C"
unit_of_measurement: W
state: >
{{ ( states('sensor.sensor_a') | float(0)
- states('sensor.sensor_b') | float(0) ) | round(2) }}
availability: >
{{ states('sensor.sensor_a') | is_number and
states('sensor.sensor_b') | is_number }}
The legacy format is still supported but will not have new features added.
Also I’m closing this as it has already been requested. Please vote and comment here: