diff --git a/atom.xml b/atom.xml index dbf6b5b4d4..66f52067e5 100644 --- a/atom.xml +++ b/atom.xml @@ -4,7 +4,7 @@
Device discovery for Home Assistant has been extracted into an external library called NetDisco. This library is integrated using the discovery
component and scans the network in intervals for uPnP and zeroconf/mDNS services.
To have your device be discovered, you will have to extend the NetDisco library to be able to find your device. This is done by adding a new discoverable. See the repository for examples of existing discoverable.
SERVICE_DISCOVERED
eventsFrom your component, you will have to set up the listening for specific services. Given below is an example how one would listen for discovered Chromecasts:
-from homeassistant.loader import get_component
+From your component, you will have to set up the listening for specific services. Given below is an example how one would listen for a discovered AwesomeDevice:
+from homeassistant.components.discovery import SERVICE_AWESOMEDEVICE
+from homeassistant.helpers import discovery
+
+DOMAIN = 'awesomedevice'
+
+DEPENDENCIES = ['http']
def setup(hass, config):
- discovery = get_component('discovery')
+ cfg = config.get(DOMAIN)
- def chromecast_discovered(service, info):
- """ Called when a Chromecast has been discovered. """
- print("Discovered a new Chromecast: {}".format(info))
+ def device_discovered(service, info):
+ """ Called when a Awesome device has been discovered. """
+ print("Discovered a new Awesome device: {}".format(info))
discovery.listen(
- hass, discovery.services.GOOGLE_CAST, chromecast_discovered)
+ hass, SERVICE_AWESOMEDEVICE, device_discovered)
+
+ return True
Auto-loading your component upon discovery
-The Discovery component is capable of setting up your components before firing the SERVICE_DISCOVERD
event. To do this you will have to update the SERVICE_HANDLERS
constant in the discovery
component.
+The discovery
component is capable of setting up your components before firing the EVENT_PLATFORM_DISCOVERED
event. To do this you will have to update the SERVICE_HANDLERS
constant in the discovery
component:
+```python
+SERVICE_AWESOMEDEVICE = ‘awesomedevice’
+SERVICE_HANDLERS = {
+ …
+ SERVICE_AWESOMEDEVICE: (‘awesomedevice’, None),
+}