Add WiZ occupancy sensor support (#66231)

This commit is contained in:
J. Nick Koston 2022-02-14 07:25:15 -06:00 committed by GitHub
parent b2ee7cebc9
commit 00d7fdd274
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 242 additions and 28 deletions

View file

@ -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."""