Implement local discovery of Smappee legacy devices (#37812)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
bsmappee 2020-08-10 13:34:18 +02:00 committed by GitHub
parent 65f1e0c71a
commit 07de9deab6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 708 additions and 60 deletions

View file

@ -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)