Add WiZ occupancy sensor support (#66231)
This commit is contained in:
parent
b2ee7cebc9
commit
00d7fdd274
7 changed files with 242 additions and 28 deletions
|
@ -1,23 +1,24 @@
|
|||
"""WiZ integration entities."""
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import abstractmethod
|
||||
from typing import Any
|
||||
|
||||
from pywizlight.bulblibrary import BulbType
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||
from homeassistant.helpers.entity import DeviceInfo, ToggleEntity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity, ToggleEntity
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .models import WizData
|
||||
|
||||
|
||||
class WizToggleEntity(CoordinatorEntity, ToggleEntity):
|
||||
"""Representation of WiZ toggle entity."""
|
||||
class WizEntity(CoordinatorEntity, Entity):
|
||||
"""Representation of WiZ entity."""
|
||||
|
||||
def __init__(self, wiz_data: WizData, name: str) -> None:
|
||||
"""Initialize an WiZ device."""
|
||||
"""Initialize a WiZ entity."""
|
||||
super().__init__(wiz_data.coordinator)
|
||||
self._device = wiz_data.bulb
|
||||
bulb_type: BulbType = self._device.bulbtype
|
||||
|
@ -41,6 +42,15 @@ class WizToggleEntity(CoordinatorEntity, ToggleEntity):
|
|||
self._async_update_attrs()
|
||||
super()._handle_coordinator_update()
|
||||
|
||||
@callback
|
||||
@abstractmethod
|
||||
def _async_update_attrs(self) -> None:
|
||||
"""Handle updating _attr values."""
|
||||
|
||||
|
||||
class WizToggleEntity(WizEntity, ToggleEntity):
|
||||
"""Representation of WiZ toggle entity."""
|
||||
|
||||
@callback
|
||||
def _async_update_attrs(self) -> None:
|
||||
"""Handle updating _attr values."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue