Compare commits
4 Commits
0.9.0-snap
...
0.9.0-snap
| Author | SHA1 | Date | |
|---|---|---|---|
| 4dcf642260 | |||
| 80de671649 | |||
| 9f5b09dc4c | |||
| 09231c4fc0 |
@@ -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."""
|
||||
@@ -158,7 +167,7 @@ class GeoRideActiveSubscriptionBinarySensorEntity(GeoRideBinarySensorEntity):
|
||||
"""state value property"""
|
||||
tracker = self._tracker_device.tracker
|
||||
if tracker.is_oldsubscription:
|
||||
if .tracker.subscription_id is not None:
|
||||
if tracker.subscription_id is not None:
|
||||
return True
|
||||
return False
|
||||
else:
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class Device:
|
||||
"""Return the device info."""
|
||||
return {
|
||||
"name": self.name,
|
||||
"identifiers": {(GEORIDE_DOMAIN, self._tracker.tracker_id)},
|
||||
"identifiers": self.unique_id,
|
||||
"manufacturer": "GeoRide",
|
||||
"model": self.model_name,
|
||||
"suggested_area": "Garage"
|
||||
@@ -54,7 +54,7 @@ class Device:
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Get the unique id."""
|
||||
return {(GEORIDE_DOMAIN, self._tracker.tracker_id)}
|
||||
return f"{GEORIDE_DOMAIN}_{self._tracker.tracker_id}"
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Get string representation."""
|
||||
@@ -93,17 +93,17 @@ class DeviceBeacon:
|
||||
"""Return the device info."""
|
||||
return {
|
||||
"name": self.name,
|
||||
"identifiers": {(GEORIDE_DOMAIN, self._beacon.beacon_id)},
|
||||
"identifiers": self.unique_id,
|
||||
"manufacturer": "GeoRide",
|
||||
"model": self.model_name,
|
||||
"suggested_area": "Garage"
|
||||
}
|
||||
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Get the unique id."""
|
||||
return {(GEORIDE_DOMAIN, "beacon", self._beacon.beacon_id)}
|
||||
|
||||
return f"{GEORIDE_DOMAIN}_beacon_{self._tracker.tracker_id}"
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Get string representation."""
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"issue_tracker": "https://github.com/ptimatth/GeorideHA/issues",
|
||||
"iot_class": "cloud_polling",
|
||||
"requirements": [
|
||||
"georideapilib>=0.8.0",
|
||||
"georideapilib==0.8.1",
|
||||
"pyjwt==2.1.0"
|
||||
],
|
||||
"dependencies": [],
|
||||
|
||||
@@ -4,6 +4,7 @@ import logging
|
||||
from typing import Any, Mapping
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import DeviceInfo, EntityCategory
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.components.sensor import ENTITY_ID_FORMAT
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
@@ -12,7 +13,7 @@ from homeassistant.helpers.update_coordinator import (
|
||||
)
|
||||
|
||||
from .const import DOMAIN as GEORIDE_DOMAIN
|
||||
from .device import Device
|
||||
from .device import Device, DeviceBeacon
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -61,6 +62,10 @@ class GeoRideOdometerSensorEntity(CoordinatorEntity, SensorEntity):
|
||||
self._state = 0
|
||||
self._hass = hass
|
||||
|
||||
@property
|
||||
def entity_category(self):
|
||||
return None
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID."""
|
||||
@@ -88,7 +93,7 @@ class GeoRideOdometerSensorEntity(CoordinatorEntity, SensorEntity):
|
||||
return "mdi:counter"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return self._tracker_device.device_info
|
||||
|
||||
@@ -107,6 +112,10 @@ class GeoRideOdometerKmSensorEntity(CoordinatorEntity, SensorEntity):
|
||||
self._state = 0
|
||||
self._hass = hass
|
||||
|
||||
@property
|
||||
def entity_category(self):
|
||||
return EntityCategory.DIAGNOSTIC
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID."""
|
||||
@@ -134,12 +143,13 @@ class GeoRideOdometerKmSensorEntity(CoordinatorEntity, SensorEntity):
|
||||
return "mdi:counter"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return self._tracker_device.device_info
|
||||
|
||||
class GeoRideInternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
||||
"""Represent a tracked device."""
|
||||
entity_category = EntityCategory.DIAGNOSTIC
|
||||
|
||||
def __init__(self, coordinator: DataUpdateCoordinator[Mapping[str, Any]],
|
||||
tracker_device:Device):
|
||||
@@ -152,6 +162,10 @@ class GeoRideInternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
||||
|
||||
self._state = 0
|
||||
|
||||
@property
|
||||
def entity_category(self):
|
||||
return EntityCategory.DIAGNOSTIC
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID."""
|
||||
@@ -178,7 +192,7 @@ class GeoRideInternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
||||
return "mdi:battery"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the 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._state = 0
|
||||
|
||||
@property
|
||||
def entity_category(self):
|
||||
return EntityCategory.DIAGNOSTIC
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID."""
|
||||
@@ -221,7 +239,7 @@ class GeoRideExternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
||||
return "mdi:battery"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return self._tracker_device.device_info
|
||||
|
||||
@@ -239,6 +257,10 @@ class GeoRideFixtimeSensorEntity(CoordinatorEntity, SensorEntity):
|
||||
self._state = 0
|
||||
self._device_class = "timestamp"
|
||||
|
||||
@property
|
||||
def entity_category(self):
|
||||
return EntityCategory.DIAGNOSTIC
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID."""
|
||||
@@ -260,7 +282,7 @@ class GeoRideFixtimeSensorEntity(CoordinatorEntity, SensorEntity):
|
||||
return "mdi:map-clock"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the 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._state = 0
|
||||
|
||||
@property
|
||||
def entity_category(self):
|
||||
return EntityCategory.DIAGNOSTIC
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID."""
|
||||
@@ -303,6 +329,6 @@ class GeoRideBeaconBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
||||
return "mdi:battery"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return self._tracker_device.device_info
|
||||
@@ -6,7 +6,6 @@ import logging
|
||||
from typing import Any, Mapping
|
||||
|
||||
from homeassistant.components.siren import SirenEntity
|
||||
from homeassistant.components.siren import ENTITY_ID_FORMAT
|
||||
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
@@ -17,6 +16,7 @@ import georideapilib.api as GeoRideApi
|
||||
|
||||
from .const import DOMAIN as GEORIDE_DOMAIN
|
||||
from .device import Device
|
||||
ENTITY_ID_FORMAT: Final = DOMAIN + ".{}"
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user