Skip to content

Commit

Permalink
Merge branch 'release/2024.4.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi committed Jun 27, 2024
2 parents 6153f23 + 05c8687 commit f0898fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion custom_components/xiaomi_miio_raw/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"construct==2.10.68",
"python-miio>=0.5.12"
],
"version": "2024.2.0.0"
"version": "2024.4.0.0"
}
15 changes: 5 additions & 10 deletions custom_components/xiaomi_miio_raw/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@

SUCCESS = ["ok"]


# pylint: disable=unused-argument
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
async def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the sensor from config."""

if DATA_KEY not in hass.data:
Expand All @@ -69,8 +67,8 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
_LOGGER.info("Initializing with host %s (token %s...)", host, token[:5])

try:
miio_device = Device(host, token)
device_info = miio_device.info()
miio_device = await hass.async_add_executor_job(Device, host, token)
device_info = await hass.async_add_executor_job(miio_device.info)
model = device_info.model
_LOGGER.info(
"%s %s %s detected",
Expand All @@ -86,7 +84,6 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
hass.data[DATA_KEY][host] = device
async_add_devices([device], update_before_add=True)


class XiaomiMiioGenericDevice(SwitchEntity):
"""Representation of a Xiaomi Miio Generic Device."""

Expand Down Expand Up @@ -159,10 +156,8 @@ def extra_state_attributes(self):
async def _try_command(self, mask_error, func, *args, **kwargs):
"""Call a device command handling error messages."""
try:
result = await self.hass.async_add_job(partial(func, *args, **kwargs))

result = await self.hass.async_add_executor_job(partial(func, *args, **kwargs))
_LOGGER.info("Response received from miio device: %s", result)

return result == SUCCESS
except DeviceException as exc:
_LOGGER.error(mask_error, exc)
Expand Down Expand Up @@ -202,7 +197,7 @@ async def async_update(self):
return

try:
state = await self.hass.async_add_job(
state = await self.hass.async_add_executor_job(
self._device.send, self._state_property_getter, [self._state_property]
)
state = state.pop()
Expand Down

0 comments on commit f0898fe

Please sign in to comment.