Add sense guard clause (#22014)
This commit is contained in:
parent
6381242eca
commit
abf2e763b1
3 changed files with 6 additions and 2 deletions
|
@ -44,7 +44,7 @@ async def async_setup(hass, config):
|
||||||
_LOGGER.error("Could not authenticate with sense server")
|
_LOGGER.error("Could not authenticate with sense server")
|
||||||
return False
|
return False
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(hass, 'sensor', DOMAIN, None, config))
|
async_load_platform(hass, 'sensor', DOMAIN, {}, config))
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(hass, 'binary_sensor', DOMAIN, None, config))
|
async_load_platform(hass, 'binary_sensor', DOMAIN, {}, config))
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -52,6 +52,8 @@ MDI_ICONS = {
|
||||||
async def async_setup_platform(hass, config, async_add_entities,
|
async def async_setup_platform(hass, config, async_add_entities,
|
||||||
discovery_info=None):
|
discovery_info=None):
|
||||||
"""Set up the Sense binary sensor."""
|
"""Set up the Sense binary sensor."""
|
||||||
|
if discovery_info is None:
|
||||||
|
return
|
||||||
data = hass.data[SENSE_DATA]
|
data = hass.data[SENSE_DATA]
|
||||||
|
|
||||||
sense_devices = await data.get_discovered_device_data()
|
sense_devices = await data.get_discovered_device_data()
|
||||||
|
|
|
@ -48,6 +48,8 @@ SENSOR_VARIANTS = [PRODUCTION_NAME.lower(), CONSUMPTION_NAME.lower()]
|
||||||
async def async_setup_platform(hass, config, async_add_entities,
|
async def async_setup_platform(hass, config, async_add_entities,
|
||||||
discovery_info=None):
|
discovery_info=None):
|
||||||
"""Set up the Sense sensor."""
|
"""Set up the Sense sensor."""
|
||||||
|
if discovery_info is None:
|
||||||
|
return
|
||||||
data = hass.data[SENSE_DATA]
|
data = hass.data[SENSE_DATA]
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_DAILY_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_DAILY_UPDATES)
|
||||||
|
|
Loading…
Add table
Reference in a new issue