Virtual sensors (or: How to model a derived attribute)

Hello,

I am heaving the same use case over and over again.

I derive new information from my real sensors. Let’s say from measuring the power of my washing machine I derive it’s operation_mode (is it idle, tumbling or heating).
So now my naive thought is: In addition to the measured dimensions current, voltage and power I now also have it’s “operation_mode”. Voltage, current and power are modeled as sensors that are connected to the same device “washing_machine” So “operation_mode” should be a sensor too because that way all the washing machines dimensions are accessible the same way.

I got it that this is (sadly) not how you do it in Home Assistant. But what is the most natural way to publish a derived value like my washing machines “operation mode”?

With a template sensor, though you can also use automations and an input text or input select.

1 Like

I am using a custom component which allows me to create template sensors on the fly, rather than playing with yaml (laziness).

1 Like

Thanks to both of you!

I did it with a template sensor that listens to events.