Recently my R5 got automatically discovered/added to my HA. It was added as a binary sensor & their was no state change in the HA UI when I pressed any buttons on my R5. I had a similar situation with Sonoff ZigBee Wireless Switch (SONOFF SNZB-01). I got solution from the HA community to use “Listen to events” located under Developer Tools > Events. So I did the same with my R5. I listened to “state_changed” events & noted down all the 18 actions of my R5. This is what I came up with; Every buttons’ action was associated with an Outlet & Key Number. “Outlet” Number 0, 1, 2, 3, 4 & 5 cooresponds to the BUTTON ONE, TWO, THREE, FOUR, FIVE & SIX respectively. And “Key” Number 0, 1 & 2 cooresponds to CLICKED, DOUBLED-CLICKED & LONG-PRESSED respectively.
So now I want to use this in my HA Automation, but I don’t know how I can do that. Can someone please help me with this?
Below is an event that I got when I CLICKED the BUTTON ONE on my R5;
{
"event_type": "state_changed",
"data": {
"entity_id": "binary_sensor.sonoff_b5c1117524",
"old_state": {
"entity_id": "binary_sensor.sonoff_b5c1117524",
"state": "unknown",
"attributes": {
"bindInfos": "{\"alexa\": [\"d2fdc9fb-9f70-557d-cc89-d77c0207d7e6_37db2007b31f9ce74728bc383e5fffef2e3e9f43\"], \"gaction\": [\"d2fdc9fb-9f70-557d-cc89-d77c0207d7e6_ewelinkGoogleHome\"], \"scene\": 15}",
"subDevId": "\"9229cf00\"",
"parentid": "\"21126d2dgd\"",
"bleAddr": "\"9229cf00\"",
"outlet": "0",
"key": "0",
"count": "797",
"actionTime": "\"2022-04-12T02:23:20.295Z\"",
"cloud": "\"online\"",
"friendly_name": "Living Room 1 R5"
},
"last_changed": "2022-04-11T18:12:28.511412+00:00",
"last_updated": "2022-04-12T02:23:20.346455+00:00",
"context": {
"id": "21b026eb288d48c6b91c44f493c99c1c",
"parent_id": null,
"user_id": null
}
},
"new_state": {
"entity_id": "binary_sensor.sonoff_b5c1117524",
"state": "unknown",
"attributes": {
"bindInfos": "{\"alexa\": [\"d2fdc9fb-9f70-557d-cc89-d77c0207d7e6_37db2007b31f9ce74728bc383e5fffef2e3e9f43\"], \"gaction\": [\"d2fdc9fb-9f70-557d-cc89-d77c0207d7e6_ewelinkGoogleHome\"], \"scene\": 15}",
"subDevId": "\"9229cf00\"",
"parentid": "\"21126d2dgd\"",
"bleAddr": "\"9229cf00\"",
"outlet": "0",
"key": "0",
"count": "798",
"actionTime": "\"2022-04-12T02:25:07.998Z\"",
"cloud": "\"online\"",
"friendly_name": "Living Room 1 R5"
},
"last_changed": "2022-04-11T18:12:28.511412+00:00",
"last_updated": "2022-04-12T02:25:08.050200+00:00",
"context": {
"id": "dd77de109f03175d807b015b946fc455",
"parent_id": null,
"user_id": null
}
}
},
"origin": "LOCAL",
"time_fired": "2022-04-12T02:25:08.050200+00:00",
"context": {
"id": "dd77de109f03175d807b015b946fc455",
"parent_id": null,
"user_id": null
}
}
BTW I have changed some of the sensitive information like entity_id, bindInfos, subDevId, parentid, bleAddr, id, etc. But the rest are the same. When I click, double-click & long-press any of the buttons on my R5; the outlet, key & id are the things that change. The outlet & key cooresponds to the above mentioned things in my original post.
I want to use this in my HA Automation. I have tried several ways to do that i.e. using State as Trigger; this didn’t work at all. I also tried to use Event (copied the new_state section) as Trigger & this kept rapidly triggering the automation even when I did press any buttons on my R5.
Hello there. I’ve just figured out how to properly use my sonoff R5 buttons within HA. I watched the behaviour of R5 sensor in the dashboard while I’ve clicked a random button on the R5 switch. And just like a SNZB-01 button I have, when clicked, the sensor showed a status change: “button_2_single” in the dashboard.
To test it, I created an automation triggered by State, selected the R5 sensor as the entity, and included “button_2_single” on the “To” field.
Bingo! I’ve managed to toggle a light with a single click on the R5 Button 2!
Similar to the Zigbee Button, the R5 sensor has 3 states for each of the 6 buttons. For button1, for exaple: “button_1_single”; “button_1_double”; “button_1_hold”. And so on for the remaining buttons.
Try that and see if it works for you.
Cheers!
How did you connect R5 to HA?
I just connected the R5 as a remote to an M5 switchman device I have using the regular sonoff eWelink app. Since I’m using the AlexxIT/SonoffLAN integration, after the reboot both the M5 entities and the R5 sensor are automaticlly added to HA
Hi,
Could you please clarify this: Once you add 6 button R5 via M5 (which apparently works as hub), can You use R5 buttons to trigger other things on your HomeAssistant or are you just limited to controlling the Switchman M5 hub device that it connects to?
Thanks!
Recently my R5 got automatically discovered/added to my HA
how can i add them to home assistant?
i installed the HACS Sonoff integration for my shellys but the SwitchMan does not appear .
edit: ok got it , that is not the r5 smart scene wall switch
Thanks. It worked for me. button_1_single, button_1_double & button_1_hold. All six of the buttons are working fine for me.
Hi, I can confirm that the contol by status works. I’m not sure if there is any newer / better way to use the R5, for me it continues to stop working after a coople of minutes/usages. In this case when I reload the HACS Sonoff integration, starts working again. Using HA in Win Docker Desktop. Anyone maybe some idea?
Goodday,
I’m quite new in the big world of Home-Assistant and tried setting up some of my stuff. to integrate and automate some of my lights and curtains i was planning to use a Sonoff R5. I found out how to use my Sonoff Zigbee Dongle, however not how i can integrate the R5. I’m i correct if i say a can not use only the R5 switchman schene controller and also need some sort of a HUB like the M5?
Yes, you are correct. As far as I can tell, the R5 transmits in a proprietary wireless format that can only be received by the M5 or the MINI R3. You can not use the Sonoff R5 scene controller without these other devices (M5 or R3) in your system.
Thank a lot! Works perfect for me!
Ok so i understand that the NS Panel PRO can act as a hub to the R5. But what if I want to use the Nspanel pro in local mode and side load apps? How to align then with R5?
Can you please tell how you added the R5 to HA?
Install HACS
Then install below from HACS.
I’ve just created an account to say thank you! Since I’ve started with IoT world I’ve always wanted to use these cheap R5 remotes with other thinks that are no Sonoff. With the power of HA and your straight help it was possible. It was mindblowing for me. Thank you!
For this solution we enter into automations.yaml or do it in Automation and scenes:
# Sonoff R5 Automation Configuration
- alias: Control Lighting with Sonoff R5 Button
description: 'Toggles light, double click activates another device, and hold turns on yet another device'
trigger:
- platform: state
entity_id: sensor.sonoff_xxxxxxxxx
to:
- 'button_1_single'
- 'button_1_double'
- 'button_1_hold'
- 'button_2_single'
- 'button_2_double'
- 'button_2_hold'
- 'button_3_single'
- 'button_3_double'
- 'button_3_hold'
- 'button_4_single'
- 'button_4_double'
- 'button_4_hold'
- 'button_5_single'
- 'button_5_double'
- 'button_5_hold'
- 'button_6_single'
- 'button_6_double'
- 'button_6_hold'
action:
- choose:
# Button 1 Actions
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_1_single'
sequence:
- service: light.toggle
target:
entity_id: light.wejscie
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_1_double'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_klima
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_1_hold'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_sciana
# Button 2 Actions
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_2_single'
sequence:
- service: light.toggle
target:
entity_id: light.wejscie # Same as button 1
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_2_double'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_klima # Same as button 1
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_2_hold'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_sciana # Same as button 1
# Button 3 Actions
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_3_single'
sequence:
- service: light.toggle
target:
entity_id: light.wejscie # Same as button 1
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_3_double'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_klima # Same as button 1
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_3_hold'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_sciana # Same as button 1
# Button 4 Actions
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_4_single'
sequence:
- service: light.toggle
target:
entity_id: light.wejscie # Same as button 1
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_4_double'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_klima # Same as button 1
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_4_hold'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_sciana # Same as button 1
# Button 5 Actions
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_5_single'
sequence:
- service: light.toggle
target:
entity_id: light.wejscie # Same as button 1
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_5_double'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_klima # Same as button 1
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_5_hold'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_sciana # Same as button 1
# Button 6 Actions
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_6_single'
sequence:
- service: light.toggle
target:
entity_id: light.wejscie # Same as button 1
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_6_double'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_klima # Same as button 1
- conditions:
- condition: state
entity_id: sensor.sonoff_xxxxxxxxx
state: 'button_6_hold'
sequence:
- service: switch.toggle
target:
entity_id: switch.salon_oczka_sciana # Same as button 1
mode: single
Of course, set your and the target ID.
Here is the optimized automation for Sonoff R5 buttons from button_1 to button_6. Each button supports three types of events (single click, double click and hold), and each event has a corresponding action. By using repeatable structures, the setup is clearer and easier to manage.