Skip to content

Commit c9507fe

Browse files
committed
Expose RTL_433 whitelist slots in Home Assistant
1 parent ec06d82 commit c9507fe

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

docs/integrate/home_assistant.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ 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.
77+
The gateway device also exposes RTL_433 whitelist controls through MQTT discovery:
78+
79+
- `RTL_433: Whitelist`, a switch to enable or disable the filter
80+
- `RTL_433: Whitelist 1` to `RTL_433: Whitelist 5`, text fields containing accepted device identifiers
81+
82+
When the whitelist switch is enabled, only matching RTL_433 devices are published to MQTT and discovered as Home Assistant entities. The same whitelist can also be edited from the OpenMQTTGateway WebUI RF configuration page. Changes made from either Home Assistant or the WebUI are saved on the gateway and published back in the SYS state topic.
7883

7984
### RF (RCSwitch based gateway) Auto discovery specificity
8085
With OpenMQTTGateway [configured to receive RF signals](../setitup/rf.html) messages are transmitted accordingly.

main/config_mqttDiscovery.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ extern char discovery_prefix[];
277277
#define HASS_TYPE_SWITCH "switch"
278278
#define HASS_TYPE_BUTTON "button"
279279
#define HASS_TYPE_NUMBER "number"
280+
#define HASS_TYPE_TEXT "text"
280281
#define HASS_TYPE_UPDATE "update"
281282
#define HASS_TYPE_COVER "cover"
282283
#define HASS_TYPE_DEVICE_TRACKER "device_tracker"

main/mqttDiscovery.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,24 @@ void pubMqttDiscovery() {
739739
createDiscoveryFromList(nullptr, systemEntities, entityCount, nullptr, nullptr, nullptr,
740740
true, subjectSYStoMQTT, will_Topic, nullptr);
741741

742+
# ifdef ZgatewayRTL_433
743+
for (uint8_t i = 1; i <= 5; i++) {
744+
String slotKey = "rtl433wl" + String(i);
745+
String slotName = "RTL_433: Whitelist " + String(i);
746+
String valueTemplate = "{{ value_json." + slotKey + " | default('') }}";
747+
String commandTemplate = "{\"" + slotKey + "\":\"{{ value }}\",\"save\":true}";
748+
createDiscovery(HASS_TYPE_TEXT,
749+
subjectSYStoMQTT, slotName.c_str(), (char*)getUniqueId(slotKey, "").c_str(),
750+
will_Topic, "", valueTemplate.c_str(),
751+
"", "", "",
752+
0,
753+
Gateway_AnnouncementMsg, will_Message, true, subjectMQTTtoSYSset,
754+
"", "", "", "", false,
755+
stateClassNone, nullptr, nullptr, nullptr,
756+
commandTemplate.c_str());
757+
}
758+
# endif
759+
742760
# ifdef SecondaryModule
743761
// Secondary module system sensors - dynamic string handling required
744762
String secondaryPrefix = String(SecondaryModule);

0 commit comments

Comments
 (0)