Change Insteon backend module to pyinsteon from insteonplm (#35198)
* Migrate to pyinsteon from insteonplm * Rename devices entities * Print ALDB even if not loaded * Add relay to name map * Change insteonplm to pyinsteon * Update requirements_all correctly * Code review updates * async_set_speed receive std speed value * default speed to std medium value * Call async methods for fan on/off * Comment await required in loop * Remove emtpy and add codeowner * Make services async and remove async_add_job call * Remove extra logging * New device as async task and aldb load in loop * Place lock in context bloxk * Limiting lock to min * Remove .env file
This commit is contained in:
1 parent
47801e7350
commit
dbd821a564
15 files changed
+617
-514
No files matched your search
@@ -1,66 +1,33 @@
|
||||
"""Support for INSTEON dimmers via PowerLinc Modem."""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.components.switch import DOMAIN, SwitchEntity
|
||||
|
||||
from .insteon_entity import InsteonEntity
|
||||
from .utils import async_add_insteon_entities
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the INSTEON device class for the hass platform."""
|
||||
insteon_modem = hass.data["insteon"].get("modem")
|
||||
|
||||
address = discovery_info["address"]
|
||||
device = insteon_modem.devices[address]
|
||||
state_key = discovery_info["state_key"]
|
||||
|
||||
state_name = device.states[state_key].name
|
||||
|
||||
_LOGGER.debug(
|
||||
"Adding device %s entity %s to Switch platform", device.address.hex, state_name,
|
||||
"""Set up the INSTEON entity class for the hass platform."""
|
||||
async_add_insteon_entities(
|
||||
hass, DOMAIN, InsteonSwitchEntity, async_add_entities, discovery_info
|
||||
)
|
||||
|
||||
new_entity = None
|
||||
if state_name == "openClosedRelay":
|
||||
new_entity = InsteonOpenClosedDevice(device, state_key)
|
||||
else:
|
||||
new_entity = InsteonSwitchDevice(device, state_key)
|
||||
|
||||
if new_entity is not None:
|
||||
async_add_entities([new_entity])
|
||||
|
||||
|
||||
class InsteonSwitchDevice(InsteonEntity, SwitchEntity):
|
||||
"""A Class for an Insteon device."""
|
||||
class InsteonSwitchEntity(InsteonEntity, SwitchEntity):
|
||||
"""A Class for an Insteon switch entity."""
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return the boolean response if the node is on."""
|
||||
return bool(self._insteon_device_state.value)
|
||||
return bool(self._insteon_device_group.value)
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
"""Turn device on."""
|
||||
self._insteon_device_state.on()
|
||||
"""Turn switch on."""
|
||||
await self._insteon_device.async_on(group=self._insteon_device_group.group)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn device off."""
|
||||
self._insteon_device_state.off()
|
||||
|
||||
|
||||
class InsteonOpenClosedDevice(InsteonEntity, SwitchEntity):
|
||||
"""A Class for an Insteon device."""
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return the boolean response if the node is on."""
|
||||
return bool(self._insteon_device_state.value)
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
"""Turn device on."""
|
||||
self._insteon_device_state.open()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
"""Turn device off."""
|
||||
self._insteon_device_state.close()
|
||||
"""Turn switch off."""
|
||||
await self._insteon_device.async_off(group=self._insteon_device_group.group)
|
||||
Reference in new issue
Block a user