|
|
@ -27,9 +27,12 @@ async def async_setup_entry(hass, config_entry, async_add_entities): # pylint: d
|
|
|
|
for coordoned_tracker in coordoned_trackers:
|
|
|
|
for coordoned_tracker in coordoned_trackers:
|
|
|
|
tracker_device = coordoned_tracker['tracker_device']
|
|
|
|
tracker_device = coordoned_tracker['tracker_device']
|
|
|
|
coordinator = coordoned_tracker['coordinator']
|
|
|
|
coordinator = coordoned_tracker['coordinator']
|
|
|
|
entity = GeoRideOdometerSensorEntity(coordinator, tracker_device, hass)
|
|
|
|
|
|
|
|
hass.data[GEORIDE_DOMAIN]["devices"][tracker_device.tracker.tracker_id] = coordinator
|
|
|
|
hass.data[GEORIDE_DOMAIN]["devices"][tracker_device.tracker.tracker_id] = coordinator
|
|
|
|
entities.append(entity)
|
|
|
|
entities.append(GeoRideOdometerSensorEntity(coordinator, tracker_device, hass))
|
|
|
|
|
|
|
|
entities.append(GeoRideOdometerKmSensorEntity(coordinator, tracker_device, hass))
|
|
|
|
|
|
|
|
entities.append(GeoRideInternalBatterySensorEntity(coordinator, tracker_device))
|
|
|
|
|
|
|
|
entities.append(GeoRideExternalBatterySensorEntity(coordinator, tracker_device))
|
|
|
|
|
|
|
|
entities.append(GeoRideFixtimeSensorEntity(coordinator, tracker_device))
|
|
|
|
|
|
|
|
|
|
|
|
async_add_entities(entities)
|
|
|
|
async_add_entities(entities)
|
|
|
|
|
|
|
|
|
|
|
@ -58,7 +61,8 @@ class GeoRideOdometerSensorEntity(CoordinatorEntity, SensorEntity):
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def state(self):
|
|
|
|
def state(self):
|
|
|
|
"""state property"""
|
|
|
|
"""state property"""
|
|
|
|
return self._tracker_device.tracker.odometer
|
|
|
|
odometer = self._tracker_device.tracker.odometer
|
|
|
|
|
|
|
|
return odometer
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def unit_of_measurement(self):
|
|
|
|
def unit_of_measurement(self):
|
|
|
@ -79,3 +83,176 @@ class GeoRideOdometerSensorEntity(CoordinatorEntity, SensorEntity):
|
|
|
|
def device_info(self):
|
|
|
|
def device_info(self):
|
|
|
|
"""Return the device info."""
|
|
|
|
"""Return the device info."""
|
|
|
|
return self._tracker_device.device_info
|
|
|
|
return self._tracker_device.device_info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeoRideOdometerKmSensorEntity(CoordinatorEntity, SensorEntity):
|
|
|
|
|
|
|
|
"""Represent a tracked device."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, coordinator: DataUpdateCoordinator[Mapping[str, Any]],
|
|
|
|
|
|
|
|
tracker_device:Device, hass):
|
|
|
|
|
|
|
|
"""Set up GeoRide entity."""
|
|
|
|
|
|
|
|
super().__init__(coordinator)
|
|
|
|
|
|
|
|
self._tracker_device = tracker_device
|
|
|
|
|
|
|
|
self._name = tracker_device.tracker.tracker_name
|
|
|
|
|
|
|
|
self._unit_of_measurement = "km"
|
|
|
|
|
|
|
|
self.entity_id = f"{ENTITY_ID_FORMAT.format('odometer_km')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._state = 0
|
|
|
|
|
|
|
|
self._hass = hass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def unique_id(self):
|
|
|
|
|
|
|
|
"""Return the unique ID."""
|
|
|
|
|
|
|
|
return f"odometer_km_{self._tracker_device.tracker.tracker_id}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def state(self):
|
|
|
|
|
|
|
|
"""state property"""
|
|
|
|
|
|
|
|
odometer = self._tracker_device.tracker.odometer // 1000
|
|
|
|
|
|
|
|
return odometer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def unit_of_measurement(self):
|
|
|
|
|
|
|
|
"""unit of mesurment property"""
|
|
|
|
|
|
|
|
return self._unit_of_measurement
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def name(self):
|
|
|
|
|
|
|
|
""" GeoRide odometer name """
|
|
|
|
|
|
|
|
return f"{self._name} odometer km"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def icon(self):
|
|
|
|
|
|
|
|
"""icon getter"""
|
|
|
|
|
|
|
|
return "mdi:counter"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def device_info(self):
|
|
|
|
|
|
|
|
"""Return the device info."""
|
|
|
|
|
|
|
|
return self._tracker_device.device_info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeoRideInternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
|
|
|
|
|
|
|
"""Represent a tracked device."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, coordinator: DataUpdateCoordinator[Mapping[str, Any]],
|
|
|
|
|
|
|
|
tracker_device:Device):
|
|
|
|
|
|
|
|
"""Set up GeoRide entity."""
|
|
|
|
|
|
|
|
super().__init__(coordinator)
|
|
|
|
|
|
|
|
self._tracker_device = tracker_device
|
|
|
|
|
|
|
|
self._name = tracker_device.tracker.tracker_name
|
|
|
|
|
|
|
|
self._unit_of_measurement = "V"
|
|
|
|
|
|
|
|
self.entity_id = f"{ENTITY_ID_FORMAT.format('internal_battery_voltage')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._state = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def unique_id(self):
|
|
|
|
|
|
|
|
"""Return the unique ID."""
|
|
|
|
|
|
|
|
return f"internal_battery_voltage_{self._tracker_device.tracker.tracker_id}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def state(self):
|
|
|
|
|
|
|
|
"""state property"""
|
|
|
|
|
|
|
|
return self._tracker_device.tracker.internal_battery_voltage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def unit_of_measurement(self):
|
|
|
|
|
|
|
|
"""unit of mesurment property"""
|
|
|
|
|
|
|
|
return self._unit_of_measurement
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def name(self):
|
|
|
|
|
|
|
|
""" GeoRide internal_battery_voltage name """
|
|
|
|
|
|
|
|
return f"{self._name} internal_battery_voltage"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def icon(self):
|
|
|
|
|
|
|
|
"""icon getter"""
|
|
|
|
|
|
|
|
return "mdi:battery"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def device_info(self):
|
|
|
|
|
|
|
|
"""Return the device info."""
|
|
|
|
|
|
|
|
return self._tracker_device.device_info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeoRideExternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
|
|
|
|
|
|
|
|
"""Represent a tracked device."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, coordinator: DataUpdateCoordinator[Mapping[str, Any]],
|
|
|
|
|
|
|
|
tracker_device:Device):
|
|
|
|
|
|
|
|
"""Set up GeoRide entity."""
|
|
|
|
|
|
|
|
super().__init__(coordinator)
|
|
|
|
|
|
|
|
self._tracker_device = tracker_device
|
|
|
|
|
|
|
|
self._name = tracker_device.tracker.tracker_name
|
|
|
|
|
|
|
|
self._unit_of_measurement = "V"
|
|
|
|
|
|
|
|
self.entity_id = f"{ENTITY_ID_FORMAT.format('external_battery_voltage')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._state = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def unique_id(self):
|
|
|
|
|
|
|
|
"""Return the unique ID."""
|
|
|
|
|
|
|
|
return f"external_battery_voltage_{self._tracker_device.tracker.tracker_id}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def state(self):
|
|
|
|
|
|
|
|
"""state property"""
|
|
|
|
|
|
|
|
return self._tracker_device.tracker.external_battery_voltage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def unit_of_measurement(self):
|
|
|
|
|
|
|
|
"""unit of mesurment property"""
|
|
|
|
|
|
|
|
return self._unit_of_measurement
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def name(self):
|
|
|
|
|
|
|
|
""" GeoRide internal_battery_voltage name """
|
|
|
|
|
|
|
|
return f"{self._name} external_battery_voltage"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def icon(self):
|
|
|
|
|
|
|
|
"""icon getter"""
|
|
|
|
|
|
|
|
return "mdi:battery"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def device_info(self):
|
|
|
|
|
|
|
|
"""Return the device info."""
|
|
|
|
|
|
|
|
return self._tracker_device.device_info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeoRideFixtimeSensorEntity(CoordinatorEntity, SensorEntity):
|
|
|
|
|
|
|
|
"""Represent a tracked device."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, coordinator: DataUpdateCoordinator[Mapping[str, Any]],
|
|
|
|
|
|
|
|
tracker_device:Device):
|
|
|
|
|
|
|
|
"""Set up GeoRide entity."""
|
|
|
|
|
|
|
|
super().__init__(coordinator)
|
|
|
|
|
|
|
|
self._tracker_device = tracker_device
|
|
|
|
|
|
|
|
self._name = tracker_device.tracker.tracker_name
|
|
|
|
|
|
|
|
self.entity_id = f"{ENTITY_ID_FORMAT.format('fixtime')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._state = 0
|
|
|
|
|
|
|
|
self._device_class = "timestamp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def unique_id(self):
|
|
|
|
|
|
|
|
"""Return the unique ID."""
|
|
|
|
|
|
|
|
return f"fixtime_{self._tracker_device.tracker.tracker_id}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def state(self):
|
|
|
|
|
|
|
|
"""state property"""
|
|
|
|
|
|
|
|
return self._tracker_device.tracker.fixtime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def name(self):
|
|
|
|
|
|
|
|
""" GeoRide fixtime name """
|
|
|
|
|
|
|
|
return f"{self._name} last fixed position"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def icon(self):
|
|
|
|
|
|
|
|
"""icon getter"""
|
|
|
|
|
|
|
|
return "mdi:map-clock"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
|
|
|
def device_info(self):
|
|
|
|
|
|
|
|
"""Return the device info."""
|
|
|
|
|
|
|
|
return self._tracker_device.device_info
|
|
|
|