Add device info to lupusec (#108910)
* added device info and unique id * removed wrong attribute * added base entity * rename domain * added entity.py to coveragerc * added base entity for sensors and alarm panel * add generic type translation * rename functions * rename device name to device model * set _attr_name = None * pass in only the entry_id instead of the full config_entry * set unique id to device_id or entry id * use deviceinfo class * moved _attr_name = None to entities * Update homeassistant/components/lupusec/alarm_control_panel.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lupusec/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lupusec/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * remove DOMAIN from unique id * removed redundant function * Update homeassistant/components/lupusec/alarm_control_panel.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lupusec/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> --------- Co-authored-by: suaveolent <suaveolent@users.noreply.github.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
9413d15c25
commit
f2100f80c4
7 changed files with 107 additions and 28 deletions
|
@ -11,7 +11,8 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import DOMAIN, LupusecDevice
|
||||
from . import DOMAIN
|
||||
from .entity import LupusecBaseSensor
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=2)
|
||||
|
||||
|
@ -29,14 +30,16 @@ async def async_setup_entry(
|
|||
|
||||
switches = []
|
||||
for device in data.lupusec.get_devices(generic_type=device_types):
|
||||
switches.append(LupusecSwitch(data, device))
|
||||
switches.append(LupusecSwitch(data, device, config_entry.entry_id))
|
||||
|
||||
async_add_devices(switches)
|
||||
|
||||
|
||||
class LupusecSwitch(LupusecDevice, SwitchEntity):
|
||||
class LupusecSwitch(LupusecBaseSensor, SwitchEntity):
|
||||
"""Representation of a Lupusec switch."""
|
||||
|
||||
_attr_name = None
|
||||
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on the device."""
|
||||
self._device.switch_on()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue