From 9f5b09dc4c7016615fda960ba914cec58754ba6a Mon Sep 17 00:00:00 2001 From: Matthieu Date: Fri, 4 Mar 2022 16:50:34 +0100 Subject: [PATCH] Add entity category on All entities --- custom_components/georide/binary_sensor.py | 16 ++++++++++++++++ custom_components/georide/device.py | 2 +- custom_components/georide/device_tracker.py | 4 ++++ custom_components/georide/manifest.json | 2 +- custom_components/georide/siren.py | 4 ++++ custom_components/georide/switch.py | 8 ++++++++ 6 files changed, 34 insertions(+), 2 deletions(-) diff --git a/custom_components/georide/binary_sensor.py b/custom_components/georide/binary_sensor.py index 623bd4c..2bdf912 100644 --- a/custom_components/georide/binary_sensor.py +++ b/custom_components/georide/binary_sensor.py @@ -5,6 +5,7 @@ import logging from typing import Any, Mapping from homeassistant.core import callback +from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.components.binary_sensor import BinarySensorEntity from homeassistant.components.binary_sensor import ENTITY_ID_FORMAT from homeassistant.helpers.update_coordinator import ( @@ -76,6 +77,10 @@ class GeoRideBeaconBinarySensorEntity(CoordinatorEntity, BinarySensorEntity): self.entity_id = f"{ENTITY_ID_FORMAT.format('binary_sensor')}.{tracker_device.beacon.beacon_id}"# pylint: disable=C0301 self._is_on = False + @property + def entity_category(self): + return None + @property def device_info(self): """Return the device info.""" @@ -148,6 +153,10 @@ class GeoRideActiveSubscriptionBinarySensorEntity(GeoRideBinarySensorEntity): super().__init__(coordinator, tracker_device) self.entity_id = f"{ENTITY_ID_FORMAT.format('is_active_subscription_')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301 + @property + def entity_category(self): + return EntityCategory.DIAGNOSTIC + @property def unique_id(self): """Return the unique ID.""" @@ -206,6 +215,10 @@ class GeoRideNetworkBinarySensorEntity(GeoRideBinarySensorEntity): super().__init__(coordinator, tracker_device) self.entity_id = f"{ENTITY_ID_FORMAT.format('have_network')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301 + @property + def entity_category(self): + return EntityCategory.DIAGNOSTIC + @property def unique_id(self): """Return the unique ID.""" @@ -259,6 +272,9 @@ class GeoRideMovingBinarySensorEntity(GeoRideBinarySensorEntity): class GeoRideBeaconUpdatedBinarySensorEntity(GeoRideBeaconBinarySensorEntity): """Represent a tracked device.""" + @property + def entity_category(self): + return EntityCategory.DIAGNOSTIC def __init__(self, coordinator: DataUpdateCoordinator[Mapping[str, Any]], tracker_beacon_device: DeviceBeacon): diff --git a/custom_components/georide/device.py b/custom_components/georide/device.py index cc3821b..67110f1 100644 --- a/custom_components/georide/device.py +++ b/custom_components/georide/device.py @@ -1,5 +1,5 @@ """Home Assistant representation of an GeoRide Tracker device.""" -import georideapilib.objects as GeoRideTracker, GeoRideTrackerBeacon +from georideapilib.objects import GeoRideTracker, GeoRideTrackerBeacon from .const import DOMAIN as GEORIDE_DOMAIN diff --git a/custom_components/georide/device_tracker.py b/custom_components/georide/device_tracker.py index 73ac313..8bfb1b6 100644 --- a/custom_components/georide/device_tracker.py +++ b/custom_components/georide/device_tracker.py @@ -47,6 +47,10 @@ class GeoRideTrackerEntity(CoordinatorEntity, TrackerEntity): self.entity_id = DOMAIN + ".{}".format(tracker_device.tracker.tracker_id) self._hass = hass + @property + def entity_category(self): + return None + @property def unique_id(self): """Return the unique ID.""" diff --git a/custom_components/georide/manifest.json b/custom_components/georide/manifest.json index 999d7f7..9a8d45a 100644 --- a/custom_components/georide/manifest.json +++ b/custom_components/georide/manifest.json @@ -6,7 +6,7 @@ "issue_tracker": "https://github.com/ptimatth/GeorideHA/issues", "iot_class": "cloud_polling", "requirements": [ - "georideapilib>=0.8.1", + "georideapilib==0.8.1", "pyjwt==2.1.0" ], "dependencies": [], diff --git a/custom_components/georide/siren.py b/custom_components/georide/siren.py index 16c23fd..7ef489f 100644 --- a/custom_components/georide/siren.py +++ b/custom_components/georide/siren.py @@ -50,6 +50,10 @@ class GeoRideSirenEntity(CoordinatorEntity, SirenEntity): self.entity_id = f"{ENTITY_ID_FORMAT.format('eco_mode')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301 self._hass = hass + @property + def entity_category(self): + return None + async def async_turn_on(self, **kwargs): """ lock the GeoRide tracker """ _LOGGER.info('async_turn_on eco %s', kwargs) diff --git a/custom_components/georide/switch.py b/custom_components/georide/switch.py index 191cafd..01a5329 100644 --- a/custom_components/georide/switch.py +++ b/custom_components/georide/switch.py @@ -51,6 +51,10 @@ class GeoRideLockSwitchEntity(CoordinatorEntity, SwitchEntity): self.entity_id = f"{ENTITY_ID_FORMAT.format('lock')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301 self._hass = hass + @property + def entity_category(self): + return None + async def async_turn_on(self, **kwargs): """ lock the GeoRide tracker """ _LOGGER.info('async_turn_on %s', kwargs) @@ -119,6 +123,10 @@ class GeoRideEcoModeSwitchEntity(CoordinatorEntity, SwitchEntity): self.entity_id = f"{ENTITY_ID_FORMAT.format('eco_mode')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301 self._hass = hass + @property + def entity_category(self): + return None + async def async_turn_on(self, **kwargs): """ lock the GeoRide tracker """ _LOGGER.info('async_turn_on eco %s', kwargs)