I picked up a couple of Sonoff S31 switches, intending to flash them with Tasmota. The S31 has a built-in energy sensor, and it looks like Tasmota supports the sensor. But I can’t find if HA supports the sensors, and, if it does, how to set them up.
If another firmware also supports the sensor and works better with HA, that’s fine too, I’m not set on Tasmota, that just seems the most commonly recommended one here.
Tasmota can read the information from an S31 just fine. See this screenshot of a S31’s web page with Tasmota installed.
As for integration with Home assistant, all of that data (and much more) is all sent over MQTT, so there’s no issue with HA picking it up. You can bring them in as attributes, or individual sensors if you would like.
There’s also MQTT auto-discovery in Tasmota, so if that is enabled HA will be able to add all of the information automatically.
Personally I have the switch and the 4 real-time power measurement data points manually added as sensors. I can share the configuration if you would like, but it’s not all that complicated.
Sure, here are the switch and sensor configurations for one of my S31s.
Most of my topics are “S31WaterHeater/stat/POWER” or similar (devicename/stat/type) and that’s because I have the configuration in tasmota changed.
The default will not be like this, if you don’t change yours it will probably be stat/devicename/type (“stat/S31WaterHeater/POWER”).
Also, you should look into what all of the retain settings do on Tasmota. Personally I use “PowerRetain 1” on the tasmota, and no retain in HomeAssistant.
This video gives a rundown of the power retain options in tasmota.
Not 100% relevant to this question, however a word of warning for anyone hoping to use the S31 for power monitoring.
There is a S31 Lite version that is just like the S31 except without the power monitoring. I just wasted 2 hours trying to calibrate, debug, and troubleshoot before realizing I’d ordered the Lite model. Doh!
So if your S31 reports zero volts, current, watts, kWh, etc. That may be why.