How to Reset POW R2 Total State?

Hello,

how can I get a POW r2 via openhab to reset the total state?

How must the item look like?

I would like to reset all pow’s at the end of the year and have them re-measured the next year.

greeting
Daniel

Hi Daniel

Some rough steps:

You can give the Sonoff Pow commands via the MQTT binding in openHAB. On the Tasmota wiki you can find the exact command to reset the Pow.

And then you setup a cron triggered rule to reset (=send MQTT message) every 31/12 of the year at 23:59.

1 Like

I know that I can reset the total state with the variable 0 via the command EnergyReset3. What would an item look like?

Number whz_wand “Reset Wohnzimmerwand” (gWhz) {mqtt=“>[broker:cmnd/sonoff_45E532/SENSOR:command:EnergyReset3:default]”} ???

Hi @Nognog, this is what worked for me:
Item file:

// ***********************************************************************************************************
// following definition resets the energy accumulator for today and total
Switch Sonoff_1_Reset_E
	{mqtt=">[broker:sonoff_1/cmnd/sonoff/EnergyReset1:command:*:0]"}

Rules file:

// ********************************************************
// Sonoff reset Energy information at beginning of month
// ********************************************************
rule "Sonoff Energy reset"
when
	Time cron "0 1 0 1 * ? *"	// every 1st day of every Month at 1 minute after midnight
then
	Sonoff_1_Reset_E.sendCommand(ON)
	Sonoff_1_Reset_E.sendCommand(OFF)

Note: The syntax of the MQTT command has changed over time with the evolution of the TASMOTA software. The above Item definition works with firmware 5.11.1

I have a more complex rule than that, since I do have multiple Sonoffs that are part of a group.
With a consistent naming convention for the Sonoff items it is relatively easy to do that for as many devices as you like. No rule file change required when you add/delete devices. You only need to touch the items file to add/delete the definitions.

Hope this helps…

1 Like

Thank you for sharing. Are you able to also show how this rule works in MQTT 2.4?

Sorry, but I am still using MQTT OH1 binding and don’t have any experience with the new binding…:frowning_face:

Something similiar to this here:

//
//  Basic rule demonstrating how we can push commands
//
rule "Tasmota Stuff Ask for Version"
when
    System started
then
    logInfo(filename, "Ask Tasmotas for Firmware Version")

    val brokerName = "mqtt:broker:internal"
    val actions = getActions("mqtt", brokerName)
    logInfo(filename, "Actions are: " + actions)

    actions.publishMQTT("tasmota/cmnd/sonoffs/status", "2")
end

I have changed my OH Version to 2.5 and have problems with the reset function.

Things:

    Thing topic wohnzimmer "Sonoff POW2 - Wohnzimmer" @ "Wohnzimmer" {
    Channels:
        Type string : reachable "Erreichbar"            [ stateTopic="tele/sonoff_CE02C4/LWT" ]
        Type number : powerload "Verbrauch"             [ stateTopic="tele/sonoff_CE02C4/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]
        Type number : total     "Gesamtverbrauch"     	[ stateTopic="tele/sonoff_CE02C4/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total"]
        Type number : rssi      "Empfang: RSSI"   		[ stateTopic="tele/sonoff_CE02C4/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
		Type switch	: reset		"Reset Energie"			[ commandTopic="cmnd/sonoff_CE0772/EnergyReset3:command:*:0" ]
    }
	    Thing topic esszimmer "Sonoff POW2 - Esszimmer" @ "Wohnzimmer" {
    Channels:
        Type string : reachable "Erreichbar"            [ stateTopic="tele/sonoff_CE0F32/LWT" ]
        Type number : powerload "Verbrauch"             [ stateTopic="tele/sonoff_CE0F32/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]
        Type number : total     "Gesamtverbrauch"     	[ stateTopic="tele/sonoff_CE0F32/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total"]
        Type number : rssi      "Empfang: RSSI"   		[ stateTopic="tele/sonoff_CE0F32/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
		Type switch	: reset		"Reset Energie"			[ commandTopic="cmnd/sonoff_CE0F32/EnergyReset3:command:*:0" ]
    }

Item:

Switch      whz_wohnwand_reset                                                          (gReset)	    {channel="mqtt:topic:broker:wohnzimmer:reset"}
Switch      whz_kamin_reset                                                             (gReset)	    {channel="mqtt:topic:broker:kamin:reset"}

What i do wrong?