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
|
@ -762,6 +762,7 @@ omit =
|
||||||
homeassistant/components/motion_blinds/entity.py
|
homeassistant/components/motion_blinds/entity.py
|
||||||
homeassistant/components/motion_blinds/sensor.py
|
homeassistant/components/motion_blinds/sensor.py
|
||||||
homeassistant/components/motionmount/__init__.py
|
homeassistant/components/motionmount/__init__.py
|
||||||
|
homeassistant/components/motionmount/binary_sensor.py
|
||||||
homeassistant/components/motionmount/entity.py
|
homeassistant/components/motionmount/entity.py
|
||||||
homeassistant/components/motionmount/number.py
|
homeassistant/components/motionmount/number.py
|
||||||
homeassistant/components/motionmount/select.py
|
homeassistant/components/motionmount/select.py
|
||||||
|
|
|
@ -13,10 +13,7 @@ from homeassistant.helpers.device_registry import format_mac
|
||||||
|
|
||||||
from .const import DOMAIN, EMPTY_MAC
|
from .const import DOMAIN, EMPTY_MAC
|
||||||
|
|
||||||
PLATFORMS: list[Platform] = [
|
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.NUMBER, Platform.SELECT]
|
||||||
Platform.NUMBER,
|
|
||||||
Platform.SELECT,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
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
|
|
@ -25,6 +25,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
|
"binary_sensor": {
|
||||||
|
"motionmount_is_moving": {
|
||||||
|
"name": "Moving"
|
||||||
|
}
|
||||||
|
},
|
||||||
"number": {
|
"number": {
|
||||||
"motionmount_extension": {
|
"motionmount_extension": {
|
||||||
"name": "Extension"
|
"name": "Extension"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue