# MQTT Counter reset in Tasmota

**URL:** <https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395>\
**Category:** General\
**Tags:** database\
**Created:** [10 January 2022 12:36 UTC](https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395 "2022-01-10T12:36:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigluc](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@bigluc](https://discourse.nodered.org/u/bigluc)\
**Post date:** [10 January 2022 12:36 UTC](https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395/1 "2022-01-10T12:36:43Z")

</div>

I have a question:  
I want to reset a counter in Tasmota via MQTT but I don't understand which topic I have to use or which command. Whenever I try it I always get  
{"Command": "Unknown"}  
...I hope someone can help me from the console I attach a picture to show the TOPIC. The counter C1 is the one it is about

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fbb12ab35c84e2b72ec16f9c311c9d8f99d9164b.jpeg)  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8ae0152d459b481db183da8e56c52016fe525e9e.jpeg)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [11 January 2022 08:53 UTC](https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395/2 "2022-01-11T08:53:18Z")

</div>

Could you try the following ?

```auto
msg.topic = "cmnd/testtopic/_luca/SENSOR"
msg.payload = {COUNTER:{C1:your_value}}

return msg

```

---

<div class="post-metadata">

**Author:** ![bigluc](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@bigluc](https://discourse.nodered.org/u/bigluc)\
**Post date:** [11 January 2022 09:00 UTC](https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395/3 "2022-01-11T09:00:30Z")

</div>

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/4/4443efec6e955421149105d9dc527e20e0b76587.png)  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/f/5f8f16f960c032ad8cb466d4dc83248892d58b34.png)  
No This does not work. I have made the setup like the pictures ? Or is the construction wrong thought

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [11 January 2022 09:17 UTC](https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395/4 "2022-01-11T09:17:48Z")

</div>

Instead of setting it to `msg`, set it to json (and note the double quotes):

 ![Screenshot 2022-01-11 at 10.17.00](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b8a94485afa72878775aa70709b599a2c236e21d.jpeg)

If this does not work, then try the topic:

`cmnd/testtopic/_luca`

with json:

```auto
{"SENSOR":{"COUNTER":{"C1":0}}}

```

Tasmota is not very clear on this cmnd structure

---

<div class="post-metadata">

**Author:** ![bigluc](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@bigluc](https://discourse.nodered.org/u/bigluc)\
**Post date:** [11 January 2022 14:15 UTC](https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395/5 "2022-01-11T14:15:41Z")

</div>

It doesn't work either. When I send the first idea, the deploy= The workspace contains some nodes that are not set properly.  
The second idea can send but in the console there is no message of an incoming MQTT command. I tried it once with

cmnd/testtopic/\_luca/SENSOR/COUNTER := 0000

then the console says

15:11:13.348 MQT: stat/testtopic/\_luca/RESULT = {"Command": "Unknown"}

I can't find any guidelines or commands that help.  
Do you have another solution?

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [11 January 2022 15:14 UTC](https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395/6 "2022-01-11T15:14:17Z")

</div>

Try this -

msg.topic = "cmnd/testtopic/\_luca/Counter1"  
msg.payload=0

---

<div class="post-metadata">

**Author:** ![bigluc](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@bigluc](https://discourse.nodered.org/u/bigluc)\
**Post date:** [11 January 2022 16:19 UTC](https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395/7 "2022-01-11T16:19:09Z")

</div>

![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/a/3aa745061d38aeb329bd598d9f0ef91be8d63a2e.png)  
How it works is you use a MQTT out brick and inject a 0 / the desired number you want to set for the counter. thanks @Sean-McG

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [11 January 2022 16:55 UTC](https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395/8 "2022-01-11T16:55:54Z")

</div>

Glad to help

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 January 2022 16:56 UTC](https://discourse.nodered.org/t/mqtt-counter-reset-in-tasmota/56395/9 "2022-01-25T16:56:39Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
