Various enhancements for WeMo component/platforms (#19419)
* WeMo - Various fixes and improvements Various fixes & improvements to the WeMo components, including: -- Fixes to rediscovery -- New reset filter service for the WeMo Humidifier -- Switched the remainder of the WeMo components to async IO -- Removed any remaining IO in entity properties and moved them to the polling/subscription update process * WeMo - Fix pywemo version and remove test code from WeMo fan component * WeMo Humidifier - Add services.yaml entry for reset filter life service * WeMo - Update binary_sensor component to use asyncio * WeMo - Add available property to binary_sensor component * WeMo - Fixed line length issue * WeMo - Fix issue with discovering the same device multiple times * WeMo - Fix for the fix for discovering devices multiple times * WeMo - Fix long lines * WeMo - Fixes from code review * WeMo - Breaking Change - entity_ids is now required on wemo_set_humidity * WeMo - Code review fixes * WeMo - Code review fixes * WeMo - Code review fixes
This commit is contained in:
1 parent
ef6c39f911
commit
7f0dd442fd
6 files changed
+256
-100
No files matched your search
@@ -64,10 +64,12 @@ class WemoSwitch(SwitchDevice):
|
||||
self.maker_params = None
|
||||
self.coffeemaker_mode = None
|
||||
self._state = None
|
||||
self._mode_string = None
|
||||
self._available = True
|
||||
self._update_lock = None
|
||||
# look up model name once as it incurs network traffic
|
||||
self._model_name = self.wemo.model_name
|
||||
self._name = self.wemo.name
|
||||
self._serialnumber = self.wemo.serialnumber
|
||||
|
||||
def _subscription_callback(self, _device, _type, _params):
|
||||
"""Update the state by the Wemo device."""
|
||||
@@ -85,24 +87,15 @@ class WemoSwitch(SwitchDevice):
|
||||
await self._async_locked_update(force_update)
|
||||
self.async_schedule_update_ha_state()
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""Device should poll.
|
||||
|
||||
Subscriptions push the state, however it won't detect if a device
|
||||
is no longer available. Use polling to detect if a device is available.
|
||||
"""
|
||||
return True
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the ID of this WeMo switch."""
|
||||
return self.wemo.serialnumber
|
||||
return self._serialnumber
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the switch if any."""
|
||||
return self.wemo.name
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
@@ -169,7 +162,7 @@ class WemoSwitch(SwitchDevice):
|
||||
def detail_state(self):
|
||||
"""Return the state of the device."""
|
||||
if self.coffeemaker_mode is not None:
|
||||
return self.wemo.mode_string
|
||||
return self._mode_string
|
||||
if self.insight_params:
|
||||
standby_state = int(self.insight_params['state'])
|
||||
if standby_state == WEMO_ON:
|
||||
@@ -242,6 +235,7 @@ class WemoSwitch(SwitchDevice):
|
||||
"""Update the device state."""
|
||||
try:
|
||||
self._state = self.wemo.get_state(force_update)
|
||||
|
||||
if self._model_name == 'Insight':
|
||||
self.insight_params = self.wemo.insight_params
|
||||
self.insight_params['standby_state'] = (
|
||||
@@ -250,6 +244,7 @@ class WemoSwitch(SwitchDevice):
|
||||
self.maker_params = self.wemo.maker_params
|
||||
elif self._model_name == 'CoffeeMaker':
|
||||
self.coffeemaker_mode = self.wemo.mode
|
||||
self._mode_string = self.wemo.mode_string
|
||||
|
||||
if not self._available:
|
||||
_LOGGER.info('Reconnected to %s', self.name)
|
||||
|
||||
Reference in new issue
Block a user