MQTT Tasmota reset energy meter

Hey guys,

openhabian openHAB 3.3.0-SNAPSHOT - Build #2695
Gosund Plug Sp1-C v24
Tasmota 10.1.0

currently i’m struggling a bit with how to get a command working to reset f.e. the todays energy meter…
I’ve searched this forum and try to find the answer for myself… but didnt find a solution…
MQTT / Mosquitto is set up and running… i can control normal switches… this all works fine…
I also can successfully call this command in the Tasmota console (both of them work)
accourding to the tasmota command doc the EnergyReset command has been replaced by 3 single commands for Total, Today, Yesterday

working

EnergyToday 1000
cmd/MQTTPlug80/EnergyToday 2000

Not working (without the space)

EnergyToday2000
cmd/MQTTPlug80/EnergyToday2000

How do i need to setup my config in the MainUI to get this space (or the right command) sent?

this is my channel of the thing

  - id: sensor_energyTodayReset
    channelTypeUID: mqtt:switch
    label: Sensor Energy Today Reset
    description: null
    configuration:
      commandTopic: cmd/MQTTPlug80/EnergyToday 0

I’ve also tried other commands and configs:

  - id: sensor_energyTodayReset
    channelTypeUID: mqtt:switch
    label: Sensor Energy Today Reset
    description: null
    configuration:
      commandTopic: cmd/MQTTPlug80/EnergyToday
      postCommand: true
      qos: 0
      on: "0"
  - id: sensor_energyTodayReset
    channelTypeUID: mqtt:switch
    label: Sensor Energy Today Reset
    description: null
    configuration:
      commandTopic: cmd/MQTTPlug80/EnergyToday
      postCommand: true
      qos: 0
      on: "EnergyToday 0"
  - id: sensor_energyTodayReset
    channelTypeUID: mqtt:switch
    label: Sensor Energy Today Reset
    description: null
    configuration:
      commandTopic: cmd/MQTTPlug80/EnergyToday
      postCommand: true
      qos: 0
      on: "EnergyToday\ 0"

My EnergyTodayReset item of type switch is linked to this channel… and autoupdate set to false (also tried without this metadata)

So what I’m doing wrong here and can someone help my with an example how to configure my thing and item properly?

Thanks
/Holger

Not relevant without a stateTopic

      commandTopic: cmd/MQTTPlug80/EnergyToday
      off: "0"
      on: "0"

should post
cmd/MQTTPlug80/EnergyToday 0
every time you command your linked Switch Item.

After making edits to your channel, you may need to restart MQTT binding (or openHAB) to make sure new settings take effect.

1 Like

thanks for you quit help @rossko57

but your suggestion is not working…

here is my updated thing config:

  - id: sensor_energyTodayReset
    channelTypeUID: mqtt:switch
    label: Sensor Energy Today Reset
    description: null
    configuration:
      commandTopic: cmd/MQTTPlug80/EnergyToday
      off: "0"
      on: "0"

and here is the log

2022-01-18 00:10:12.497 [DEBUG] [qtt.generic.AbstractMQTTThingHandler] - Successfully published value ON to topic cmd/MQTTPlug80/EnergyToday
==> /var/log/openhab/events.log <==
2022-01-18 00:10:12.481 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'MQTTPlug80_WM_SensorEnergyTodayReset' received command ON

The command seems to be sent… but the value in that topic doesnt reset… I’va also restarted my openhabian twice to be sure all mqtt bindings are picking up the changes…

any other suggestions please?

EDIT:

I also tried with

      off: " 0"
      on: " 0"
      off: "\ 0"
      on: "\ 0"

With restarts after every change

It should be as simple as that. You certainly do not want to be adding extra spaces and backslashes.
I couldn’t say why it is not working for you. Have you used Mqtt explorer or similar to see what is actually published?

I’m feeling so stupid right now…

2022-01-18 02_38_02-Window

it was the wrong command -.- :see_no_evil:

i changed
cmd/MQTTPlug80/EnergyToday
to
cmnd/MQTTPlug80/EnergyToday

I’ve missed the “n” … dont know why the “wrong” command was working in Tasmota console… maybe thats why i assumed that something in OH is wrong wih my config…

Its now working… Thanks for your help Rossko!

EDIT:
I’ve now removed the “0” value from the OFF command to not get the energy measurement deleted by accident if the switch receives the OFF command…

  - id: sensor_energyTodayReset
    channelTypeUID: mqtt:switch
    label: Sensor Energy Today Reset
    description: null
    configuration:
      commandTopic: cmd/MQTTPlug80/EnergyToday
      off: ""
      on: "0"
1 Like