How to clear/change mqtt sensor data

Hi, hope someone can help me out.

I have a template sensor so when someone hits my doorbell, a code comes up in the sensor and when the code appears, my phone rings. So, pressing the bell sents a code (like aa112233) which I can see in the template sensor I made. My problem is that the code is allways the same and I need to ‘clear’ the sensor. Otherwise my automation (if sensor is ‘aa112233’ ring phone) does not work because the sensor is allready aa112233.

Hope it is clean and hope someone can help me.

Thanks.

post your template sensor…

  - platform: mqtt
    name: "Doorbell"
    state_topic: "tele/sonoff/RESULT"
    value_template: '{{ value_json["RfRaw"]["Data"] }}''

That’s not a template sensor, that’s an mqtt sensor. What does the json look like when you ring the bell vrs leave the bell alone?

Ah, ok. Sorry. This is when i ring the doorbell

13:42:48 MQT: tele/sonoff/RESULT = {"RfRaw":{"Data":"AAA60507970C966455"}}
13:42:49 MQT: tele/sonoff/RESULT = {"RfRaw":{"Data":"AAA60507970C966455"}}
13:42:50 MQT: tele/sonoff/RESULT = {"RfRaw":{"Data":"AAA60507970C966455"}}
13:42:51 MQT: tele/sonoff/RESULT = {"RfRaw":{"Data":"AAA60507970C966455"}}

In rest there is nothing else. Only periodic status updates from Tasmota:

13:45:15 MQT: tele/sonoff/STATE = {"Time":"2019-09-03T13:45:15","Uptime":"6T21:39:52","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"VFNL-C9D1E0_ub","BSSId":"80:2A:A8:94:69:1E","Channel":8,"RSSI":100,"LinkCount":10,"Downtime":"0T00:03:15"}}

so the result looks like this?

tele/sonoff/RESULT = {}

when nothing is pressed?

This is the console data:

13:42:48 MQT: tele/sonoff/RESULT = {"RfRaw":{"Data":"AAA60507970C966455"}}
13:42:49 MQT: tele/sonoff/RESULT = {"RfRaw":{"Data":"AAA60507970C966455"}}
13:42:50 MQT: tele/sonoff/RESULT = {"RfRaw":{"Data":"AAA60507970C966455"}}
13:42:51 MQT: tele/sonoff/RESULT = {"RfRaw":{"Data":"AAA60507970C966455"}}
13:45:15 MQT: tele/sonoff/STATE = {"Time":"2019-09-03T13:45:15","Uptime":"6T21:39:52","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"VFNL-C9D1E0_ub","BSSId":"80:2A:A8:94:69:1E","Channel":8,"RSSI":100,"LinkCount":10,"Downtime":"0T00:03:15"}}
13:50:15 MQT: tele/sonoff/STATE = {"Time":"2019-09-03T13:50:15","Uptime":"6T21:44:52","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"VFNL-C9D1E0_ub","BSSId":"80:2A:A8:94:69:1E","Channel":8,"RSSI":100,"LinkCount":10,"Downtime":"0T00:03:15"}}
13:55:15 MQT: tele/sonoff/STATE = {"Time":"2019-09-03T13:55:15","Uptime":"6T21:49:52","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"VFNL-C9D1E0_ub","BSSId":"80:2A:A8:94:69:1E","Channel":8,"RSSI":100,"LinkCount":10,"Downtime":"0T00:03:15"}}
14:00:15 MQT: tele/sonoff/STATE = {"Time":"2019-09-03T14:00:15","Uptime":"6T21:54:52","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"VFNL-C9D1E0_ub","BSSId":"80:2A:A8:94:69:1E","Channel":8,"RSSI":100,"LinkCount":10,"Downtime":"0T00:03:15"}}
14:05:15 MQT: tele/sonoff/STATE = {"Time":"2019-09-03T14:05:15","Uptime":"6T21:59:52","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"VFNL-C9D1E0_ub","BSSId":"80:2A:A8:94:69:1E","Channel":8,"RSSI":100,"LinkCount":10,"Downtime":"0T00:03:15"}}
14:10:15 MQT: tele/sonoff/STATE = {"Time":"2019-09-03T14:10:15","Uptime":"6T22:04:52","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"VFNL-C9D1E0_ub","BSSId":"80:2A:A8:94:69:1E","Channel":8,"RSSI":100,"LinkCount":10,"Downtime":"0T00:03:15"}}
14:15:15 MQT: tele/sonoff/STATE = {"Time":"2019-09-03T14:15:15","Uptime":"6T22:09:52","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"VFNL-C9D1E0_ub","BSSId":"80:2A:A8:94:69:1E","Channel":8,"RSSI":100,"LinkCount":10,"Downtime":"0T00:03:15"}}
14:20:15 MQT: tele/sonoff/STATE = {"Time":"2019-09-03T14:20:15","Uptime":"6T22:14:52","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"VFNL-C9D1E0_ub","BSSId":"80:2A:A8:94:69:1E","Channel":8,"RSSI":100,"LinkCount":10,"Downtime":"0T00:03:15"}}
14:25:15 MQT: tele/sonoff/STATE = {"Time":"2019-09-03T14:25:15","Uptime":"6T22:19:52","Heap":14,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"Wifi":{"AP":1,"SSId":"VFNL-C9D1E0_ub","BSSId":"80:2A:A8:94:69:1E","Channel":8,"RSSI":100,"LinkCount":10,"Downtime":"0T00:03:15"}}

First lines are from one doorbell press, the rest is when idle. I now sent a code after the automation started (so a different code appears) and wantend to know if there is an option to empty the mqtt sensor data.

Dude, I would like to know the state of this topic when nothing is pressed. I don’t care about tele/sonoff/STATE topic.

What does tele/sonoff/RESULT contain when the button is not being pressed.

Ah, sorry mate, I understand now. I Will look it up later

I would model this as an MQTT Binary Sensor and set off_delay to 10 seconds.

off_delay

For sensors that only sends On state updates, this variable sets a delay in seconds after which the sensor state will be updated back to Off.

1 Like

That’s great but gave an error when check config. It refered to https://www.home-assistant.io/components/sensor.mqtt/, is the ‘expire after’ option the same?

Edit: Yes it is and works now, thanks for the help!