I have created a multiline-if template sensor that combines few other sensor values and generates a human friendly ouput for the status of my heat pump.
The template sensor is defined like this:
template:
- sensor:
- name: "Nilan_CompactP"
state: >
{% if is_state('binary_sensor.nilan_compactp_compressorstate', 'off') %}
off
{% elif is_state('binary_sensor.nilan_compactp_deicingheatexchanger', 'on') or is_state('binary_sensor.nilan_compactp_deicingheatpump', 'on') %}
defrosting
{% elif is_state('binary_sensor.nilan_compactp_heatvalve', 'on') and is_state('binary_sensor.nilan_compactp_fourwayvalve', 'off') %}
heating
{% elif is_state('binary_sensor.nilan_compactp_heatvalve', 'on') and is_state('binary_sensor.nilan_compactp_fourwayvalve', 'on') %}
cooling
{% elif is_state('binary_sensor.nilan_compactp_hotwatervalve', 'on') and is_state('binary_sensor.nilan_compactp_fourwayvalve', 'off') %}
hot water production
{% else %}
unknown
{% endif %}
state_class: measurement
The sensor itself works OK, meaning that it outputs the correct string value. The issue is with the history card in the GUI - it wants to plot a chart, but obviously fails since there are no numeric values.
I would like to have a discrete history chart, similar to the weather integration:
Question: How can I define a custom “enum” for my sensor?