1 """Support for Neato sensors."""
3 from __future__
import annotations
5 from datetime
import timedelta
9 from pybotvac.exceptions
import NeatoRobotException
10 from pybotvac.robot
import Robot
18 from .const
import NEATO_LOGIN, NEATO_ROBOTS, SCAN_INTERVAL_MINUTES
19 from .entity
import NeatoEntity
20 from .hub
import NeatoHub
22 _LOGGER = logging.getLogger(__name__)
24 SCAN_INTERVAL =
timedelta(minutes=SCAN_INTERVAL_MINUTES)
30 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
32 """Set up the Neato sensor using config entry."""
33 neato: NeatoHub = hass.data[NEATO_LOGIN]
34 dev = [
NeatoSensor(neato, robot)
for robot
in hass.data[NEATO_ROBOTS]]
39 _LOGGER.debug(
"Adding robots for sensors %s", dev)
46 _attr_device_class = SensorDeviceClass.BATTERY
47 _attr_entity_category = EntityCategory.DIAGNOSTIC
48 _attr_native_unit_of_measurement = PERCENTAGE
49 _attr_available: bool =
False
51 def __init__(self, neato: NeatoHub, robot: Robot) ->
None:
52 """Initialize Neato sensor."""
54 self._robot_serial: str = self.
robotrobot.serial
56 self.
_state_state: dict[str, Any] |
None =
None
59 """Update Neato Sensor."""
62 except NeatoRobotException
as ex:
65 "Neato sensor connection error for '%s': %s", self.
entity_identity_id, ex
72 _LOGGER.debug(
"self._state=%s", self.
_state_state)
76 """Return the state."""
77 if self.
_state_state
is not None:
78 return str(self.
_state_state[
"details"][
"charge"])
None __init__(self, NeatoHub neato, Robot robot)
str|None native_value(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)