Electronics Home Automation

Sonoff POW R2 Smart Switch power consumption modification

Modifying a Sonoff POWR2 Smart Switch with energy monitoring to reduce its power consumption when being used to monitor a devices energy usage

Time for another addition to our ongoing home automation project which is powered by Home Assistant on our small Linux server

I decided it would be interesting to monitor the power consumption of our Miele washing machine and found the Sonoff POWR2 Smart Switch which is rated for 15 amps. This should be more than enough for the power consumption of the washing machine during a washing cycle.

Case
The Sonoff Case

Our washing machine has a built-in timer to allow scheduled wash cycles which we normally set at night to run early in the morning, so we didn’t need the Sonoff POWR2 to power the washing machine down. The easiest way to do this was to remove the relay and bridge across the contacts with a thick wire while still retaining the power measuring functionality.

I also wanted to be able to generate a notification when the wash cycle was complete based on the power consumption data.

I have done this with the Kasa Smart Plug by TP-Link model HS10 modification to reduce its power consumption when monitoring the network cupboard.

Installing the Tasmota firmware

Before modifying the Sonoff POW R2, I first had to install the Tasmota firmware using the excellent guide from notenoughtech.com and the Tasmotizer software.

installing the firmware
Installing the custom firmware

The device was then connected to our Wi-Fi network and the MQTT settings updated to send and receive data from our MQTT server.

Using our Hopi power meter, we measured the power consumption of the Sonoff POW R2 and found that the average consumption was 0.6 watts with the relay turned off and 0.9 watts with the relay active.

Top of the Sonoff
Top of the PCB

Using the console on the devices web page I set the initial power on state to be powered on using:

PowerOnState 1

The default period of the Tasmota firmware is to send the data every 300 seconds to the MQTT server but as I wanted more frequent updates this was changed with the following command:

TelePeriod 10
        

This set the data period to be every 10 seconds allowing our Home Assistant software to show much more detailed data for the energy usage of the washing machine.

The full list of available Tasmota commands is on their website at tasmota.github.io/docs/Commands/

Removing the Relay

Base of the PCB
Base of the PCB

With the PCB removed from the plastic case for the firmware flashing, the relay was unsoldered using a pair of soldering irons and a flat blade to prise it away from the PCB.

A short length of 2mm copper wire was then soldered across the relay contact pins to bridge the circuit alongside the R10 current sense resistor.

Link wire added
Link wire added

The unit was then reassembled, and a short power cable was connected to the input side and a single trailing socket was fitted to the output to allow the washing machine to be connected.

Setting up Home Assistant

In the sensor.yaml file the following lines were added to access the washing machine data within Home Assistant:

- platform: mqtt
  state_topic: "/home/devices/washingmachine/SENSOR"
  name: 'Washing Machine Reactive Power'
  unit_of_measurement: 'VA'
  value_template: "{{ value_json.ENERGY.ReactivePower }}"
- platform: mqtt
  state_topic: "/home/devices/washingmachine/SENSOR"
  name: 'Washing Machine Total Power'
  unit_of_measurement: 'kwh'
  value_template: "{{ value_json.ENERGY.Total }}"
- platform: mqtt
  state_topic: "/home/devices/washingmachine/SENSOR"
  name: 'Washing Machine Today Power'
  unit_of_measurement: 'kwh'
  value_template: "{{ value_json.ENERGY.Today }}"
- platform: mqtt
  state_topic: "/home/devices/washingmachine/SENSOR"
  name: 'Washing Machine Power'
  value_template: "{{ value_json.ENERGY.Power }}"
- platform: mqtt
  state_topic: "/home/devices/washingmachine/SENSOR"
  name: 'Washing Machine Current'
  unit_of_measurement: 'A'
  value_template: "{{ value_json.ENERGY.Current }}"

To be able to record daily usage within the new Energy tab within Home Assistant a template sensor was added with the last_reset, state_class and device_class attributes with the following:

- platform: template
  sensors:  
    main_washingmachine_energy:
      device_class: energy
      friendly_name: "Energy Washing Machine"
      attribute_templates:
        last_reset: '1970-01-01T00:00:00+00:00'
        state_class: measurement
        device_class: energy
      unit_of_measurement: 'kWh'
      value_template: "{{ states('sensor.washing_machine_total_power') }}"
      icon_template: mdi:mdi-current-ac

The screen shot below shows the new washing machine page I have added into Home Assistant showing the different sensor readings and a daily usage graph.

Home assistant washing machine page
Home assistant washing machine page

The Energy page now has the washing machine added into the Monitor individual devices section and the screen shot below shows the usage after 3 wash cycles today.

Energy Page
Energy Page

Permalink


comments

Leave a reply

Your email address will not be published. Required fields are marked *

Share this post

Support the blog

AB Electronics Raspberry Pi shop