diff --git a/.coveragerc b/.coveragerc index 6f382bcb780..ca2cce2719f 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1158,6 +1158,7 @@ omit = homeassistant/components/roborock/coordinator.py homeassistant/components/rocketchat/notify.py homeassistant/components/romy/__init__.py + homeassistant/components/romy/binary_sensor.py homeassistant/components/romy/coordinator.py homeassistant/components/romy/entity.py homeassistant/components/romy/vacuum.py diff --git a/homeassistant/components/romy/binary_sensor.py b/homeassistant/components/romy/binary_sensor.py new file mode 100644 index 00000000000..263c5840e5f --- /dev/null +++ b/homeassistant/components/romy/binary_sensor.py @@ -0,0 +1,73 @@ +"""Checking binary status values from your ROMY.""" + +from homeassistant.components.binary_sensor import ( + BinarySensorDeviceClass, + BinarySensorEntity, + BinarySensorEntityDescription, +) +from homeassistant.config_entries import ConfigEntry +from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity_platform import AddEntitiesCallback + +from .const import DOMAIN +from .coordinator import RomyVacuumCoordinator +from .entity import RomyEntity + +BINARY_SENSORS: list[BinarySensorEntityDescription] = [ + BinarySensorEntityDescription( + key="dustbin", + translation_key="dustbin_present", + ), + BinarySensorEntityDescription( + key="dock", + translation_key="docked", + device_class=BinarySensorDeviceClass.PLUG, + ), + BinarySensorEntityDescription( + key="water_tank", + translation_key="water_tank_present", + device_class=BinarySensorDeviceClass.MOISTURE, + ), + BinarySensorEntityDescription( + key="water_tank_empty", + translation_key="water_tank_empty", + device_class=BinarySensorDeviceClass.PROBLEM, + ), +] + + +async def async_setup_entry( + hass: HomeAssistant, + config_entry: ConfigEntry, + async_add_entities: AddEntitiesCallback, +) -> None: + """Set up ROMY vacuum cleaner.""" + + coordinator: RomyVacuumCoordinator = hass.data[DOMAIN][config_entry.entry_id] + + async_add_entities( + RomyBinarySensor(coordinator, entity_description) + for entity_description in BINARY_SENSORS + if entity_description.key in coordinator.romy.binary_sensors + ) + + +class RomyBinarySensor(RomyEntity, BinarySensorEntity): + """RomyBinarySensor Class.""" + + entity_description: BinarySensorEntityDescription + + def __init__( + self, + coordinator: RomyVacuumCoordinator, + entity_description: BinarySensorEntityDescription, + ) -> None: + """Initialize ROMYs StatusSensor.""" + super().__init__(coordinator) + self._attr_unique_id = f"{entity_description.key}_{self.romy.unique_id}" + self.entity_description = entity_description + + @property + def is_on(self) -> bool: + """Return the value of the sensor.""" + return bool(self.romy.binary_sensors[self.entity_description.key]) diff --git a/homeassistant/components/romy/const.py b/homeassistant/components/romy/const.py index 5d42380902b..0fa039e8d1b 100644 --- a/homeassistant/components/romy/const.py +++ b/homeassistant/components/romy/const.py @@ -6,6 +6,6 @@ import logging from homeassistant.const import Platform DOMAIN = "romy" -PLATFORMS = [Platform.VACUUM] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.VACUUM] UPDATE_INTERVAL = timedelta(seconds=5) LOGGER = logging.getLogger(__package__) diff --git a/homeassistant/components/romy/icons.json b/homeassistant/components/romy/icons.json new file mode 100644 index 00000000000..c27b36af64c --- /dev/null +++ b/homeassistant/components/romy/icons.json @@ -0,0 +1,20 @@ +{ + "entity": { + "binary_sensor": { + "water_tank_empty": { + "default": "mdi:cup-outline", + "state": { + "off": "mdi:cup-water", + "on": "mdi:cup-outline" + } + }, + "dustbin_present": { + "default": "mdi:basket-check", + "state": { + "off": "mdi:basket-remove", + "on": "mdi:basket-check" + } + } + } + } +} diff --git a/homeassistant/components/romy/strings.json b/homeassistant/components/romy/strings.json index 26dc60a2e84..f4bc4d191ff 100644 --- a/homeassistant/components/romy/strings.json +++ b/homeassistant/components/romy/strings.json @@ -46,6 +46,20 @@ } } } + }, + "binary_sensor": { + "dustbin_present": { + "name": "Dustbin present" + }, + "docked": { + "name": "Robot docked" + }, + "water_tank_present": { + "name": "Watertank present" + }, + "water_tank_empty": { + "name": "Watertank empty" + } } } }