First steps of entity category
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
"issue_tracker": "https://github.com/ptimatth/GeorideHA/issues",
|
"issue_tracker": "https://github.com/ptimatth/GeorideHA/issues",
|
||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"georideapilib>=0.8.0",
|
"georideapilib>=0.8.1",
|
||||||
"pyjwt==2.1.0"
|
"pyjwt==2.1.0"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import logging
|
|||||||
from typing import Any, Mapping
|
from typing import Any, Mapping
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.components.sensor import ENTITY_ID_FORMAT
|
from homeassistant.components.sensor import ENTITY_ID_FORMAT
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
@@ -61,6 +62,10 @@ class GeoRideOdometerSensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
self._state = 0
|
self._state = 0
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entity_category(self):
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
@@ -88,7 +93,7 @@ class GeoRideOdometerSensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
return "mdi:counter"
|
return "mdi:counter"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return self._tracker_device.device_info
|
return self._tracker_device.device_info
|
||||||
|
|
||||||
@@ -107,6 +112,10 @@ class GeoRideOdometerKmSensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
self._state = 0
|
self._state = 0
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entity_category(self):
|
||||||
|
return EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
@@ -134,12 +143,13 @@ class GeoRideOdometerKmSensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
return "mdi:counter"
|
return "mdi:counter"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return self._tracker_device.device_info
|
return self._tracker_device.device_info
|
||||||
|
|
||||||
class GeoRideInternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
class GeoRideInternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
||||||
"""Represent a tracked device."""
|
"""Represent a tracked device."""
|
||||||
|
entity_category = EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
def __init__(self, coordinator: DataUpdateCoordinator[Mapping[str, Any]],
|
def __init__(self, coordinator: DataUpdateCoordinator[Mapping[str, Any]],
|
||||||
tracker_device:Device):
|
tracker_device:Device):
|
||||||
@@ -152,6 +162,10 @@ class GeoRideInternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
|
|
||||||
self._state = 0
|
self._state = 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entity_category(self):
|
||||||
|
return EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
@@ -178,7 +192,7 @@ class GeoRideInternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
return "mdi:battery"
|
return "mdi:battery"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return self._tracker_device.device_info
|
return self._tracker_device.device_info
|
||||||
|
|
||||||
@@ -195,6 +209,10 @@ class GeoRideExternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
self.entity_id = f"{ENTITY_ID_FORMAT.format('external_battery_voltage')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301
|
self.entity_id = f"{ENTITY_ID_FORMAT.format('external_battery_voltage')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301
|
||||||
self._state = 0
|
self._state = 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entity_category(self):
|
||||||
|
return EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
@@ -221,7 +239,7 @@ class GeoRideExternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
return "mdi:battery"
|
return "mdi:battery"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return self._tracker_device.device_info
|
return self._tracker_device.device_info
|
||||||
|
|
||||||
@@ -239,6 +257,10 @@ class GeoRideFixtimeSensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
self._state = 0
|
self._state = 0
|
||||||
self._device_class = "timestamp"
|
self._device_class = "timestamp"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entity_category(self):
|
||||||
|
return EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
@@ -260,7 +282,7 @@ class GeoRideFixtimeSensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
return "mdi:map-clock"
|
return "mdi:map-clock"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return self._tracker_device.device_info
|
return self._tracker_device.device_info
|
||||||
|
|
||||||
@@ -277,6 +299,10 @@ class GeoRideBeaconBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
self.entity_id = f"{ENTITY_ID_FORMAT.format('battery_percent')}.{tracker_beacon.beacon.beacon_id}"# pylint: disable=C0301
|
self.entity_id = f"{ENTITY_ID_FORMAT.format('battery_percent')}.{tracker_beacon.beacon.beacon_id}"# pylint: disable=C0301
|
||||||
self._state = 0
|
self._state = 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entity_category(self):
|
||||||
|
return EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
@@ -303,6 +329,6 @@ class GeoRideBeaconBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
|||||||
return "mdi:battery"
|
return "mdi:battery"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return self._tracker_device.device_info
|
return self._tracker_device.device_info
|
||||||
Reference in New Issue
Block a user