diff --git a/TheengsGateway/__init__.py b/TheengsGateway/__init__.py index 2846a826..6ee1ee9c 100644 --- a/TheengsGateway/__init__.py +++ b/TheengsGateway/__init__.py @@ -59,18 +59,18 @@ def main() -> None: sys.exit("MQTT host is not specified") # Remove possible discovery filter remnants not required after the RMAC introduction - if "GAEN" in configuration["discovery_filter"]: - configuration["discovery_filter"].remove("GAEN") - if "MS-CDP" in configuration["discovery_filter"]: - configuration["discovery_filter"].remove("MS-CDP") - if "APPLE_CONT" in configuration["discovery_filter"]: - configuration["discovery_filter"].remove("APPLE_CONT") - if "APPLE_CONTAT" in configuration["discovery_filter"]: - configuration["discovery_filter"].remove("APPLE_CONTAT") - if "APPLEDEVICE" in configuration["discovery_filter"]: - configuration["discovery_filter"].remove("APPLEDEVICE") - if "APPLEWATCH" in configuration["discovery_filter"]: - configuration["discovery_filter"].remove("APPLEWATCH") + if "GAEN" in configuration["discovery_filter"]["model_id"]: + configuration["discovery_filter"]["model_id"].remove("GAEN") + if "MS-CDP" in configuration["discovery_filter"]["model_id"]: + configuration["discovery_filter"]["model_id"].remove("MS-CDP") + if "APPLE_CONT" in configuration["discovery_filter"]["model_id"]: + configuration["discovery_filter"]["model_id"].remove("APPLE_CONT") + if "APPLE_CONTAT" in configuration["discovery_filter"]["model_id"]: + configuration["discovery_filter"]["model_id"].remove("APPLE_CONTAT") + if "APPLEDEVICE" in configuration["discovery_filter"]["model_id"]: + configuration["discovery_filter"]["model_id"].remove("APPLEDEVICE") + if "APPLEWATCH" in configuration["discovery_filter"]["model_id"]: + configuration["discovery_filter"]["model_id"].remove("APPLEWATCH") write_configuration(configuration, config_path) run(configuration, config_path) diff --git a/TheengsGateway/config.py b/TheengsGateway/config.py index 6b8be82f..d0a222b0 100644 --- a/TheengsGateway/config.py +++ b/TheengsGateway/config.py @@ -33,9 +33,14 @@ "general_presence": 0, "discovery_topic": "homeassistant", "discovery_device_name": "TheengsGateway", - "discovery_filter": [ - "IBEACON", - ], + "discovery_filter": { + "brand": [], + "id": [], + "model": [], + "model_id": [ + "IBEACON" + ] + }, "adapter": "", "scanning_mode": "active", "time_sync": [], diff --git a/TheengsGateway/discovery.py b/TheengsGateway/discovery.py index cc045f58..3ea0369a 100644 --- a/TheengsGateway/discovery.py +++ b/TheengsGateway/discovery.py @@ -125,7 +125,10 @@ def publish_device_info(self, pub_device) -> None: # noqa: ANN001 device_data = json.dumps(pub_device_copy) if ( pub_device_uuid in self.discovered_entities - or pub_device["model_id"] in self.configuration["discovery_filter"] + or pub_device["model_id"] in self.configuration["discovery_filter"]["model_id"] + or pub_device["model"] in self.configuration["discovery_filter"]["model"] + or pub_device["id"] in self.configuration["discovery_filter"]["id"] + or pub_device["brand"] in self.configuration["discovery_filter"]["brand"] ): logger.debug("Already discovered or filtered: %s", pub_device_uuid) self.publish( diff --git a/docs/use/use.md b/docs/use/use.md index ec7af7f5..6704a1e1 100644 --- a/docs/use/use.md +++ b/docs/use/use.md @@ -198,7 +198,7 @@ docker run --rm \ -e DISCOVERY=true \ -e DISCOVERY_TOPIC=homeassistant \ -e DISCOVERY_DEVICE_NAME=TheengsGateway \ - -e DISCOVERY_FILTER="[IBEACON,GAEN,MS-CDP,APPLE_CONT,APPLE_CONTAT]" \ + -e DISCOVERY_FILTER="[\"model_id\":[IBEACON,GAEN,MS-CDP,APPLE_CONT,APPLE_CONTAT],\"id\":[],\"brand\":[],\"model\":[]]" \ -e SCANNING_MODE=active \ -e ADAPTER=hci0 \ -e IDENTITIES="{\"CC:AA:CC:DD:CC:CC\": \"keykeykeykeykeykey==\"}" \ @@ -253,7 +253,7 @@ If enabled (default), decoded devices publish their configuration to Home Assist - You can enable/disable this with the `-D` or `--discovery` command line argument with a value of 1 (enable) or 0 (disable). - You can set the discovery topic with the `-Dt` or `--discovery_topic` command line argument. - You can set the discovery name with the `-Dn` or `--discovery_device_name` command line argument. -- You can filter devices from discovery with the `-Df` or `--discovery_filter` argument which takes a list of device model ID to filter. +- You can filter devices from discovery with the `-Df` or `--discovery_filter` argument which takes a list of device model ID's, ID's, brands, and models to filter.