Add binary sensor to MotionMount integration (#107659)
* Add binary sensor for `isMoving` * Sort platforms alphabetically * Update doc strings
This commit is contained in:
parent
4a0b6af8c1
commit
298b0d1105
4 changed files with 46 additions and 4 deletions
39
homeassistant/components/motionmount/binary_sensor.py
Normal file
39
homeassistant/components/motionmount/binary_sensor.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
"""Support for MotionMount binary sensors."""
|
||||
import motionmount
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DOMAIN
|
||||
from .entity import MotionMountEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||
) -> None:
|
||||
"""Set up Vogel's MotionMount from a config entry."""
|
||||
mm = hass.data[DOMAIN][entry.entry_id]
|
||||
|
||||
async_add_entities([MotionMountMovingSensor(mm, entry)])
|
||||
|
||||
|
||||
class MotionMountMovingSensor(MotionMountEntity, BinarySensorEntity):
|
||||
"""The moving sensor of a MotionMount."""
|
||||
|
||||
_attr_device_class = BinarySensorDeviceClass.MOVING
|
||||
_attr_translation_key = "motionmount_is_moving"
|
||||
|
||||
def __init__(self, mm: motionmount.MotionMount, config_entry: ConfigEntry) -> None:
|
||||
"""Initialize moving binary sensor entity."""
|
||||
super().__init__(mm, config_entry)
|
||||
self._attr_unique_id = f"{self._base_unique_id}-moving"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Get on status."""
|
||||
return self.mm.is_moving or False
|
Loading…
Add table
Add a link
Reference in a new issue