Sonoff POW / Sonoff-MQTT-OTA-Arduino

I’ve add a few Sonoff POW switches and flashed them with https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/wiki/Sonoff-Pow . I can switch them on and off with HA using MQTT. I can’t get the current power usage in HA. See config. I’m getting “unknown”. Any suggestions ?

  - platform: mqtt
    name: "Wasmachine verbruik huidig"
    state_topic: "cmnd/sonoff_wasmachine/status 8"
    qos: 1
    unit_of_measurement: "W"
    value_template: "{{ value_json.CURRENT_POWER }}"

I’m using the “Next Generation” of that firmware, which can be found at GitHub - arendst/Tasmota: Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at

I think there are a few things wrong here, but it may be slight differences in the Firmware. If I publish a topic like:

cmnd/deskpow/status 8

then my firmware responds with

stat/deskpow/RESULT {“StatusPWR”:{“Voltage”:228, “Current”:“0.054”, “Power”:3, “Today”:“0.079”, “Factor”:“0.30”}}

This means that the answer is coming under stat/deskpow/RESULT and not the cmnd/deskpow/status, so the state_topic needs to reflect this. Additionally, the value is nested in the JSON so it needs to be picked out from StatusPWR.Power.

 - platform: mqtt
   name: "Workbench"
   state_topic: "stat/deskpow/RESULT"
   qos: 1
   unit_of_measurement: "W"
   value_template: "{{ value_json.StatusPWR.Power }}"

I’m still trying to solve the following:

  1. Get Home Assistant to “ask” for the power – currently it just waits for the result to be sent and doesn’t ask (needs like a command_topic)
  2. Pull all values out in one request
1 Like

Ok, I think I understand. But how/where do I publish the topic “cmnd/deskpow/status 8” ?

When I do:

pi@HomeAssistant:~$ mosquitto_sub -h 192.168.178.123 -p 8883 -t 'cmnd/sonoff_droger/status 8' -v -u ha -P ha

I get:

pi@HomeAssistant:/var/www/html$ mosquitto_sub -h 192.168.178.123 -p 8883 -t stat/sonoff_droger/RESULT -v -u ha -P ha
stat/sonoff_droger/RESULT PWR: Voltage 228 V, Current 0.000 A, Power 0 W, Today 0.005 kWh, Factor 0.00

I still can’t figure out how to do this in HA config.

I flashed a https://www.itead.cc/wiki/Sonoff_4CH with https://github.com/arendst/Sonoff-Tasmota I have been trying to make it work with Home Assistant without success. If anyone can help with the setup of both the Sonoff firmware and Home Assistant I would appreciate it immensely!!

@mitchese : can’t you use the telemetry option from the firmware to make the Sonoff push the data every 1/5/10min and then use that data as needed?
The Tasmota Sonoff POW wiki show such feature https://github.com/arendst/Sonoff-Tasmota/wiki/Sonoff-Pow
I don’t have any POW device (ordered a few last week, still waiting for them to arrive) so can’t test this, but seems like a a good idea.

Can someone please share their settings here for the Sonoff POW switch.

EDIT: Sorted, if anyone needs help just ask in the thread.

{“Voltage”:228, “Current”:“0.054”, “Power”:3, “Today”:“0.079”, “Factor”:“0.30”}

In regards to the above, how would I find the unit of measurement for Today, Factor and Current?

Anyone has a Sonoff POW script that the washing machine sent notification to your phone as a reminder to hang up laundry?

1 Like

Anyone able to help me with the other sensors of the sonoff POW?

Here is the result of the following code in HA:

sensor:

  - platform: mqtt    
    name: "Fridge Draw"
    state_topic: "home/sonoff/server_room/1/power"
    qos: 0
    unit_of_measurement: "W"
    value_template: "{{ value_json.Power }}"

  - platform: mqtt    
    name: "Fridge Voltage"
    state_topic: "home/sonoff/server_room/1/power"
    qos: 0
    unit_of_measurement: "V"
    value_template: "{{ value_json.Voltage }}"

  - platform: mqtt    
    name: "Fridge Today"
    state_topic: "home/sonoff/server_room/1/power"
    qos: 0
    unit_of_measurement: "kWh"
    value_template: "{{ value_json.Today }}"

  - platform: mqtt    
    name: "Fridge Current"
    state_topic: "home/sonoff/server_room/1/power"
    qos: 0
    unit_of_measurement: "A"
    value_template: "{{ value_json.Current }}"

  - platform: mqtt    
    name: "Fridge Yesterday"
    state_topic: "home/sonoff/server_room/1/power"
    qos: 0
    unit_of_measurement: "kWh"
    value_template: "{{ value_json.Yesterday }}"

1 Like

I’m using only the sensors listed in the Tasmota wiki

sensor:
  - platform: mqtt
    name: "Energy"
    state_topic: "tele/pow1/ENERGY"
    value_template: "{{ value_json.Today }}"
    unit_of_measurement: "kWh"

Take note I’m using the Tasmota version of the firmware by Theo Arendst which is still developed.

1 Like

is it measuring the energy consumption (kwh)?

I guess I’ll try that Tasmota firmware because I feel I can definitely get more data out of it, ideally I’d love to have the total kWh usage for the day that you’re telling me it provides :slight_smile:

From Tasmota wiki

The Sonoff Pow can provide Energy, Power, Voltage and Current information in different ways.

Message   | Unit | Description
----------|------|-----------------------------------------------------
Yesterday | kWh  | Total Energy usage between 00:00 and 24:00 yesterday
Today     | kWh  | Total Energy usage today from 00:00 until now
Period    | Wh   | Energy usage between previous message and now
Power     | W    | Current power load
Factor    |      | The ratio of the real power flowing to the load to
          |      |   the apparent power in the circuit 
Voltage   | V    | Current line voltage
Current   | A    | Current line current

Sorry to bump this thread but how is it working lately?
Just want to confirm - to set the update period just send once TelePeriod = 300 and it is stored in flash? Afterwards POW will report the measurments and they are easily picked up via the following config? Any bugs or problems?

  - platform: mqtt
    name: "Energy"
    state_topic: "tele/pow1/ENERGY"
    value_template: "{{ value_json.Today }}"
    unit_of_measurement: "kWh"
  - platform: mqtt
    name: "Power"
    state_topic: "tele/pow1/ENERGY"
    value_template: "{{ value_json.Power }}"
    unit_of_measurement: "W"
  - platform: mqtt
    name: "Voltage"
    state_topic: "tele/pow1/ENERGY"
    value_template: "{{ value_json.Voltage }}"
    unit_of_measurement: "V"

I too am curious about how well this is working. It seems to me that the Sonoff products are underappreciated at their price point. Why are they getting so little attention by the community? I can’t image paying double for a zwave device for the same (or maybe even less) functionality.

Am I missing something?

Any way to keep the state across restarts? Problem is that for the switch it publishes to the following topic every update.

state_topic: "stat/convec/POWER"

But also publishes state every 5 minutes via

tele/convec/STATE {"Time":"2017-12-12T08:34:50","Uptime":37,"Vcc":3.178,"POWER":"ON","Wifi":{"AP":1,"SSId":"","RSSI":68,"APMac":""}}

So wonder if there is a way to combine those

Bump. Anyone getting this to work? I can make the switch part work but not the power monitoring. I am using the tasmota firmware and instructions. Power monitoring works on the sonoff web interface but I can’t get it to translate to home assistant.

My works with this in sensors:

 - platform: mqtt
   state_topic: "tele/sonoff_pow1/ENERGY"
   name: "Wash"
   value_template: "{{ value_json.Power }}"
   unit_of_measurement: "W"

Thanks. I tried this and it still is not working. Here are my config files. Switch part works, power sensor does not. The POW project name in the tasmota firmware is “sonoff1”. I am using hass.io w/ the mosquitto add-on for my MQTT broker. Feels like I am just one small setting away from making this work. Appreciate the help!

mqtt:
broker: localhost
port: 1883
client_id: home-assistant-1
keepalive: 60
protocol: 3.1
birth_message:
topic: “tele/hass1/LWT”
payload: “Online”
qos: 1
retain: true
will_message:
topic: “tele/hass1/LWT”
payload: “Offline”
qos: 1
retain: true

switch:

  • platform: mqtt
    name: “Washer”
    command_topic: “cmnd/sonoff1/power”
    state_topic: “stat/sonoff1/POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true

sensor:

  • platform: mqtt
    state_topic: “tele/sonoff1/ENERGY”
    name: “Wash”
    value_template: “{{ value_json.Power }}”
    unit_of_measurement: “W”
1 Like