Skip to content

Commit ec06d82

Browse files
committed
Add RTL_433 whitelist support
1 parent 9e93e37 commit ec06d82

8 files changed

Lines changed: 322 additions & 12 deletions

File tree

docs/integrate/home_assistant.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ mqtt:
7474

7575
Alternatively the rssi signal could be used also.
7676

77+
The gateway device also exposes an `RTL_433: Whitelist` switch through MQTT discovery. When the whitelist switch is enabled, only matching RTL_433 devices are published to MQTT and discovered as Home Assistant entities. The whitelist entries can be edited from the OpenMQTTGateway WebUI RF configuration page or with MQTT commands.
78+
7779
### RF (RCSwitch based gateway) Auto discovery specificity
7880
With OpenMQTTGateway [configured to receive RF signals](../setitup/rf.html) messages are transmitted accordingly.
7981

docs/use/rf.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,45 @@ This feature is only available on a ESP32 based device with a supported transcei
7272

7373
For the most recent support decoder list please check the [rtl_433_esp](https://github.com/NorthernMan54/rtl_433_ESP?tab=readme-ov-file#ook-signal-device-decoders) repository.
7474

75+
### RTL_433 device whitelist
76+
77+
The RTL_433 gateway can filter received devices with a whitelist. When the whitelist is enabled, only devices matching one of the configured RTL_433 device identifiers are published to MQTT. Other received RTL_433 messages are ignored.
78+
79+
The device identifier is built from the RTL_433 decoded fields in this order:
80+
81+
`type/model/subtype/channel/id`
82+
83+
Depending on the protocol, some parts may be absent. The WebUI shows the identifiers detected during the current runtime, making it easier to select devices without typing them manually.
84+
85+
The whitelist can be configured from:
86+
87+
- the WebUI RF configuration page
88+
- MQTT commands to the SYS command topic
89+
- Home Assistant, when MQTT discovery is enabled
90+
91+
The whitelist supports up to 5 device identifiers.
92+
93+
Enable or disable the whitelist:
94+
95+
```bash
96+
mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"rtl433wle":true,"save":true}'
97+
mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"rtl433wle":false,"save":true}'
98+
```
99+
100+
Set whitelist entries:
101+
102+
```bash
103+
mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"rtl433wl1":"OOK/Acurite-Tower/1/12345","rtl433wl2":"OOK/Prologue-TH/9/1/215","save":true}'
104+
```
105+
106+
Clear one whitelist entry by sending an empty string:
107+
108+
```bash
109+
mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"rtl433wl2":"","save":true}'
110+
```
111+
112+
The current whitelist state is published in the SYS state topic with the keys `rtl433wle` and `rtl433wl1` to `rtl433wl5`.
113+
75114
### Change Signal RSSI Threshold Delta
76115

77116
Delta applied to RSSI floor noise level to determine start and end of signal, defaults to 9db.

main/config_RF.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ extern int getRTLMessageCount();
6161
extern int getRTLAverageRSSI();
6262
extern int getOOKThresh();
6363

64+
# define uniqueIdSize 60 // longest model + longest key
65+
# define modelNameSize 31 // longest model
66+
# define typeSize 10 // longest type
67+
6468
# ifdef ZmqttDiscovery
6569
extern void launchRTL_433Discovery(bool overrideDiscovery);
6670
// This structure stores the entities of the RTL 433 devices and is they have been discovered or not
6771
// The uniqueId is composed of the device id + the key
68-
69-
# define uniqueIdSize 60 // longest model + longest key
70-
# define modelNameSize 31 // longest model
71-
# define typeSize 10 // longest type
72-
7372
struct RTL_433device {
7473
char uniqueId[uniqueIdSize];
74+
char deviceId[uniqueIdSize];
7575
char modelName[modelNameSize];
7676
char type[typeSize];
7777
bool isDisc;
@@ -131,6 +131,15 @@ const char parameters[51][4][24] = {
131131
{"wind_speed_km_h", "Wind speed", "km/h", "wind_speed"},
132132
{"wind_speed_m_s", "Wind speed", "m/s", "wind_speed"}};
133133
# endif
134+
extern void RTL_433Config_addState(JsonObject& data);
135+
extern bool RTL_433Config_fromJson(JsonObject& data);
136+
extern bool RTL_433Config_save();
137+
extern bool RTL_433Config_load();
138+
extern void RTL_433Config_setWhitelistEnabled(bool enabled);
139+
extern bool RTL_433Config_isWhitelistEnabled();
140+
extern void RTL_433Config_clearWhitelist();
141+
extern bool RTL_433Config_addWhitelistId(const char* id);
142+
extern String RTL_433Config_webWhitelist();
134143
# ifdef RTL_433_DISCOVERY_LOGGING
135144
# define DISCOVERY_TRACE_LOG(...) THEENGS_LOG_TRACE(__VA_ARGS__)
136145
# else

main/config_WebContent.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ const char config_rf_body[] = body_header
153153
"<p><b>Active library</b><br>"
154154
"<select id='ar' name='ar'>%s</select></p>"
155155

156+
"%s"
157+
156158
/* // Need testing
157159
"<p><b>OOK Threshold</b><br>"
158160
"<input type='number' id='oo' name='oo' step='any' value='%d'></p>"

0 commit comments

Comments
 (0)