From 2f3023eff9ae958434f811bc209c693c39114bee Mon Sep 17 00:00:00 2001 From: Howdy Pierce Date: Mon, 8 Jan 2024 14:49:52 -0700 Subject: [PATCH] Add support for fauxmo devices to be discovered by HomeAssistant Makes two changes needed for HomeAssistant to discover and manage fauxmo devices: * HomeAssistant relies on pywemo for device discovery. The pywemo.discover_devices() function sends an ssdp probe of the string "urn:Belkin:service:basicevent:1". This change causes fauxmo to respond to that probe so that pywemo.discover_devices will find fauxmo devices. * As mentioned in https://github.com/n8henrie/fauxmo/issues/88, HomeAssistant uses the serial number returned by a "real" Wemo to disambiguate devices, if more than one device shares an IP address. This changes causes fauxmo to respond to a setup message with the serial number, so that multiple fauxmo devices will be seen from HomeAssistant. --- src/fauxmo/protocols.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fauxmo/protocols.py b/src/fauxmo/protocols.py index 05b563a..e5c3ff3 100644 --- a/src/fauxmo/protocols.py +++ b/src/fauxmo/protocols.py @@ -81,6 +81,7 @@ def handle_setup(self) -> None: "Belkin International Inc." "Emulated Socket" "3.1415" + f"{self.serial}" f"uuid:Socket-1_0-{self.serial}" "" "" @@ -362,6 +363,7 @@ def datagram_received( discover_patterns = [ "ST: urn:Belkin:device:**", + "ST: urn:Belkin:service:basicevent:1", "ST: upnp:rootdevice", "ST: ssdp:all", ]