"Transform" state from "on/off" to "1/0"

Hi all,

Using the great esphome integration on my Hass installation.

I have sonoff basics integrated via esphome and the state is “on” or “off”.

Now, I also like to graph the state change in Grafana (via influxdb) and need this to be a numerical state.

(I overlay this on my beer fermentation temperature in Grafana as I like to see when the heater or cooling pump switch on or off).

Any suggestions how I could do this? Should I create a template sensor to do this.

I’m sure I have done this before but for the life of me can’t remember how.

I have Googled but not successfully…


Many thanks,

Roland

Yes, that’s a good way to do it.