Integration for cheap wall 433MHz switches. 15 triggers by 4$. Help needed

Hi! I’m trying to make gate from rtl-sdr to HA using this project as a base. The logic is quite simple - I’ve got cheap usb rtl-sdr dongle (about 10$), make binaries from rtl_433 and getting json with codes from output of rtl_433 process. I’ve made few async coroutines that filters blacklist actions, aggregates multiply clicks and sending result to the mqtt topics. It’s fully automatic at the moment with few rf433 switches that I have at home. So, I can bye another one cheap wall switch for approximately 4$ and by the single/double/triple/quadruple/quituple clicks got the triggers for automations directly inside HA. Quck and simple. But I have one problem: for example I have 3 button switch and I’ve got actions with the same names in Device -> Automation interface. Now I have three “single click” triggers, “three double click” triggers and so on.

That’s what I have in HA log during clicks:

2020-07-03 19:39:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: device_automation rtl433_Smoke-GS558_10807 unit_0_4546e0_single                      
2020-07-03 19:39:33 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: device_automation rtl433_Smoke-GS558_10807 unit_0_4546e0_double                      
2020-07-03 19:39:46 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: device_automation rtl433_Smoke-GS558_10807 unit_0_4546e0_triple                      
2020-07-03 19:39:49 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: device_automation rtl433_Smoke-GS558_10807 unit_0_4546e0_quadruple                   
2020-07-03 19:39:53 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: device_automation rtl433_Smoke-GS558_10807 unit_0_4546e0_many                        
2020-07-03 19:39:58 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: device_automation rtl433_Smoke-GS558_10807 unit_0_2546e0_single
2020-07-03 19:40:00 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: device_automation rtl433_Smoke-GS558_10807 unit_0_2546e0_double                      
2020-07-03 19:40:03 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: device_automation rtl433_Smoke-GS558_10807 unit_0_2546e0_triple                      
2020-07-03 19:40:06 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: device_automation rtl433_Smoke-GS558_10807 unit_0_2546e0_quadruple 

I want actions will named like “unit_0_4546e0_single” but not just “single click”

And that’s what I see in HA device automations:

The example of json topic/message for button is:

homeassistant/device_automation/rtl433_Smoke-GS558_10807/action_unit_0_4546e0_double/config
{
  "automation_type": "trigger","type": "click",
  "subtype": "double", "payload": "2","topic": "/rtl433/Smoke-GS558/10807/unit_0_4546e0",
  "device": {
    "identifiers": ["rtl433_Smoke-GS558_10807"],
    "name": "Smoke-GS558_10807", "model": "Smoke-GS558"
  }
}

Tell me please what I’m doing wrong?

I don’t know what your doing wrong, but I’m very interested in how you detect double, triple and so clicks.

It’s rather simple - I’ve just made the buffer for events. When I get new event, I send it to the buffer with timestamp (including milliseconds) and repeat count = 1. If I get the same event again and record for this event already exists in buffer the count will be increaced and timestamp will be updated. At the same time another coroutine every 0.05 seconds checks the buffer’s records timestamps and if difference between current datetime and timestamp more than constant from config file (by default 1 second), it makes payload for mqtt and sends it to mqtt server. All the script is less than 200 lines at the moment and I’m planning to pubilsh it on github, but at the moment it’s not polished yet.

Does anyone knows something about that?

MQTT Device automations is a relative new thing. I don’t think many have experience already with it.
A wild guess :

"device": {
    "identifiers": ["rtl433_Smoke-GS558_10807"],

Try to split up your device by unit.

Thank you! But it meance if I would have for example 7 switches with 3 buttons, it shold be look as 21 device. But it’s simpliest way.

Hi, which switches are you using? Can you share the model?

You can easily find it on aliexpress by request like “qiachip wall switch”.