Skip to content

Commit

Permalink
feat: display versions (requires sw 1.0.0+)
Browse files Browse the repository at this point in the history
  • Loading branch information
vermut committed May 25, 2024
1 parent cc29613 commit 4b29cc9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions custom_components/openmower/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
UnitOfLength,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .entity import OpenMowerMqttEntity
Expand Down Expand Up @@ -55,6 +56,7 @@ async def async_setup_entry(
OpenMowerCurrentStateEntity(
"Current State", prefix, "robot_state/json", "current_state"
),
OpenMowerVersionEntity("Version", prefix, "version", "version"),
OpenMowerCurrentSensor(
"Charge Current", prefix, "sensors/om_charge_current/data", None
),
Expand Down Expand Up @@ -156,3 +158,14 @@ def _process_update(self, value):
super()._process_update(value)
if self._attr_native_value == 999:
self._attr_native_value = None


class OpenMowerVersionEntity(OpenMowerMqttSensorEntity):
_attr_entity_category = EntityCategory.DIAGNOSTIC
_attr_icon = "mdi:timeline-check-outline"

def _process_update(self, value):
super()._process_update(value)

device_registry = dr.async_get(self.hass)
device_registry.async_update_device(self.device_entry.id, sw_version=value)

0 comments on commit 4b29cc9

Please sign in to comment.