mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Add binary_sensor platform to SenseME (#63660)
This commit is contained in:
parent
34a967c48a
commit
8e0b124875
@ -951,6 +951,7 @@ omit =
|
|||||||
homeassistant/components/sensehat/light.py
|
homeassistant/components/sensehat/light.py
|
||||||
homeassistant/components/sensehat/sensor.py
|
homeassistant/components/sensehat/sensor.py
|
||||||
homeassistant/components/senseme/__init__.py
|
homeassistant/components/senseme/__init__.py
|
||||||
|
homeassistant/components/senseme/binary_sensor.py
|
||||||
homeassistant/components/senseme/discovery.py
|
homeassistant/components/senseme/discovery.py
|
||||||
homeassistant/components/senseme/entity.py
|
homeassistant/components/senseme/entity.py
|
||||||
homeassistant/components/senseme/fan.py
|
homeassistant/components/senseme/fan.py
|
||||||
|
41
homeassistant/components/senseme/binary_sensor.py
Normal file
41
homeassistant/components/senseme/binary_sensor.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
"""Support for Big Ass Fans SenseME occupancy sensor."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from aiosenseme import SensemeDevice
|
||||||
|
|
||||||
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components.binary_sensor import (
|
||||||
|
BinarySensorDeviceClass,
|
||||||
|
BinarySensorEntity,
|
||||||
|
)
|
||||||
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
from .entity import SensemeEntity
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup_entry(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
entry: config_entries.ConfigEntry,
|
||||||
|
async_add_entities: AddEntitiesCallback,
|
||||||
|
) -> None:
|
||||||
|
"""Set up SenseME occupancy sensors."""
|
||||||
|
device = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
if device.has_sensor:
|
||||||
|
async_add_entities([HASensemeOccupancySensor(device)])
|
||||||
|
|
||||||
|
|
||||||
|
class HASensemeOccupancySensor(SensemeEntity, BinarySensorEntity):
|
||||||
|
"""Representation of a Big Ass Fans SenseME occupancy sensor."""
|
||||||
|
|
||||||
|
def __init__(self, device: SensemeDevice) -> None:
|
||||||
|
"""Initialize the entity."""
|
||||||
|
super().__init__(device, f"{device.name} Occupancy")
|
||||||
|
self._attr_unique_id = f"{self._device.uuid}-SENSOR"
|
||||||
|
self._attr_device_class = BinarySensorDeviceClass.OCCUPANCY
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def _async_update_attrs(self) -> None:
|
||||||
|
"""Update attrs from device."""
|
||||||
|
self._attr_is_on = bool(self._device.motion_detected)
|
@ -20,4 +20,4 @@ PRESET_MODE_WHOOSH = "Whoosh"
|
|||||||
SENSEME_DIRECTION_FORWARD = "FWD"
|
SENSEME_DIRECTION_FORWARD = "FWD"
|
||||||
SENSEME_DIRECTION_REVERSE = "REV"
|
SENSEME_DIRECTION_REVERSE = "REV"
|
||||||
|
|
||||||
PLATFORMS = [Platform.FAN]
|
PLATFORMS = [Platform.BINARY_SENSOR, Platform.FAN]
|
||||||
|
@ -25,6 +25,7 @@ class SensemeEntity(Entity):
|
|||||||
sw_version=self._device.fw_version,
|
sw_version=self._device.fw_version,
|
||||||
suggested_area=self._device.room_name,
|
suggested_area=self._device.room_name,
|
||||||
)
|
)
|
||||||
|
self._async_update_attrs()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict:
|
def extra_state_attributes(self) -> dict:
|
||||||
|
@ -58,7 +58,6 @@ class HASensemeFan(SensemeEntity, FanEntity):
|
|||||||
super().__init__(device, device.name)
|
super().__init__(device, device.name)
|
||||||
self._attr_speed_count = self._device.fan_speed_max
|
self._attr_speed_count = self._device.fan_speed_max
|
||||||
self._attr_unique_id = f"{self._device.uuid}-FAN" # for legacy compat
|
self._attr_unique_id = f"{self._device.uuid}-FAN" # for legacy compat
|
||||||
self._async_update_attrs()
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_update_attrs(self) -> None:
|
def _async_update_attrs(self) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user