Implement local discovery of Smappee legacy devices (#37812)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
bsmappeeandMartin Hjelmare authored and GitHub committed 2020-08-10 13:34:18 +02:00
1 parent 65f1e0c71a
commit 07de9deab6
14 files changed
+708 -60

No files matched your search

@@ -3,7 +3,7 @@ import logging
from homeassistant.components.binary_sensor import BinarySensorEntity
from .const import BASE, DOMAIN
from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
@@ -13,7 +13,7 @@ PRESENCE_PREFIX = "Presence"
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Smappee binary sensor."""
smappee_base = hass.data[DOMAIN][BASE]
smappee_base = hass.data[DOMAIN][config_entry.entry_id]
entities = []
for service_location in smappee_base.smappee.service_locations.values():
@@ -29,7 +29,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
)
)
entities.append(SmappeePresence(smappee_base, service_location))
if not smappee_base.smappee.local_polling:
# presence value only available in cloud env
entities.append(SmappeePresence(smappee_base, service_location))
async_add_entities(entities, True)