I have been trying to figure this out but I think I am missing a key piece of knowlege here. This question has been asked a number of time and ppl seem to get it to work but I keep ending up in a dead end. I have to assume this may have to do with different versions of HA or different ways of configureing sensors. So here is the configuration of the 2 sensors I like to multiply the values of. These two sensors are working in HA and I get a nice read out as a graphs or number. As MQTT server I am using the HA Mosquitto broker add-on.
My voltage sensor as configured in “config/configuration.yaml”
Both are among other sensors under the “sensor:” heading in configuration.yaml
My configuration.yaml is the default that came with HA, I have added only a bunch of MQTT and SNMP sensors as well as MQTT and SNMP switches. All of that if functional. Here the output of the 2 sensors I like to multiply as shown on “Developer Tools → States”
HasQT, the math is not hard, thats true but the format and where to put in the configuration. Its obviously not a physical sensor like a mqtt or snmp data source but a “virtual” sensor derrived from the values of 2 actual physical sensors. So with my old config would there be something like:
platform: virtual ?
or with the new config instead of
mqtt:
sensor:
virtual:
sensor:
I seem to not get the basic logic I suspect, a working example would be great.
Thank you
Jan P.
Hmmm… that yields no results. What I noticed, for what ever reason vi on the HA system is configured to no wrap lines when they go over the end of the field of view. That cause me to miss some characters when copy and pasting, very odd way to have it as default. Never mind, thats another issue for another time. Once I had that found out I no longer had errors stating up but I still get no results. Here the config I am using now:
I did remove the rounding of the Ampere reading in that senstor setting cause I thoiugh that causes issues but still no good. It states to be unavailable and if I add the virtual sensor to the overview its greyed out.
Here screen shots of the sensors from the dev tools view.
Thank you HasQT, that was it. I have to come up with a naming schema that is better. That template testing thing is pretty cool, thanks for pointing that out PeteRage. With that I was able to get it rounding the output to only 1 decimal.
Here is now what seems to work for my application: