Compare commits

..

12 Commits

Author SHA1 Message Date
22047ff6be Shipping v0.9.0 2022-04-06 17:37:16 +02:00
7d809c2105 Shipping v0.8.2 2022-03-03 20:40:02 +01:00
e59c8cb195 Shipping v0.8.1 2021-10-10 13:09:57 +02:00
5af8e7dc5d Shipping v0.8.0, thx to @Inervo 2021-08-30 20:14:56 +02:00
9053f95bc1 Shipping v0.7.2 2021-07-13 20:37:32 +02:00
fc383ff373 Shipping v0.7.1 2021-07-05 18:42:57 +02:00
57abb51b13 Shipping 0.7.0 2021-07-01 11:54:45 +02:00
24180c9345 Shipping v0.6.2 2021-05-05 22:56:38 +02:00
a83bae6d3e Shipping v0.6.1 2021-04-11 18:01:27 +02:00
b84a4cfd7f Shipping v0.6.0 2021-04-11 17:27:23 +02:00
02e1656aab Merge branch 'develop' 2020-12-01 19:24:26 +01:00
9b651f933e Shipping v0.5.0 2020-05-23 15:07:27 +02:00
9 changed files with 56 additions and 149 deletions

View File

@@ -4,7 +4,6 @@
⚠️ This is not an official implementation ⚠️ This is not an official implementation
[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](https://github.com/custom-components/hacs) [![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](https://github.com/custom-components/hacs)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg?style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg?style=for-the-badge)](https://www.gnu.org/licenses/gpl-3.0)
[![install_badge](https://img.shields.io/badge/dynamic/json?color=41BDF5&logo=home-assistant&label=integration%20usage&suffix=%20installs&cacheSeconds=15600&url=https://analytics.home-assistant.io/custom_integrations.json&query=$.georide.total)](https://analytics.home-assistant.io/)
Official GeoRide website: https://georide.fr/ Official GeoRide website: https://georide.fr/

View File

@@ -25,6 +25,7 @@ import homeassistant.helpers.config_validation as cv
import homeassistant.helpers.event as ha_event import homeassistant.helpers.event as ha_event
from homeassistant.setup import async_when_setup from homeassistant.setup import async_when_setup
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
@@ -43,8 +44,11 @@ from .const import (
SIREN_ACTIVATION_DELAY SIREN_ACTIVATION_DELAY
) )
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = vol.Schema( CONFIG_SCHEMA = vol.Schema(
{ {
vol.Required(DOMAIN, default={}): { vol.Required(DOMAIN, default={}): {
@@ -55,6 +59,7 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA, extra=vol.ALLOW_EXTRA,
) )
async def async_setup(hass, config): async def async_setup(hass, config):
"""Setup GeoRide component.""" """Setup GeoRide component."""
hass.data[DOMAIN] = {"config": config[DOMAIN], "devices": {}, "unsub": None} hass.data[DOMAIN] = {"config": config[DOMAIN], "devices": {}, "unsub": None}
@@ -71,6 +76,7 @@ async def async_setup(hass, config):
# Return boolean to indicate that initialization was successful. # Return boolean to indicate that initialization was successful.
return True return True
async def async_setup_entry(hass, entry): async def async_setup_entry(hass, entry):
"""Set up GeoRide entry.""" """Set up GeoRide entry."""
config = hass.data[DOMAIN]["config"] config = hass.data[DOMAIN]["config"]
@@ -92,7 +98,16 @@ async def async_setup_entry(hass, entry):
# We add trackers to the context # We add trackers to the context
await context.init_context(hass) await context.init_context(hass)
await hass.config_entries.async_forward_entry_setups(entry, ["device_tracker", "switch", "sensor", "binary_sensor", "siren"]) hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "device_tracker"))
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "switch"))
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "sensor"))
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "binary_sensor"))
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "siren"))
return True return True
@@ -105,15 +120,12 @@ async def async_unload_entry(hass, entry):
await hass.config_entries.async_forward_entry_unload(entry, "binary_sensor") await hass.config_entries.async_forward_entry_unload(entry, "binary_sensor")
await hass.config_entries.async_forward_entry_unload(entry, "siren") await hass.config_entries.async_forward_entry_unload(entry, "siren")
context = hass.data[DOMAIN]["context"] context = hass.data[DOMAIN]["context"]
context.socket.disconnect() # Disconnect only if all devices is disabled context.socket.disconnect()
return True return True
async def async_remove_config_entry_device(hass, config_entry, device_entry) -> bool:
"""Remove an GeoRide device entry."""
return True
class GeoRideContext: class GeoRideContext:
@@ -296,7 +308,7 @@ class GeoRideContext:
"tracker_device": Device(tracker), "tracker_device": Device(tracker),
"coordinator": coordinator "coordinator": coordinator
} }
if tracker.has_beacon: if tracker.version > 2:
tracker_beacons = await self.get_tracker_beacons_by_tracker_id(tracker.tracker_id) tracker_beacons = await self.get_tracker_beacons_by_tracker_id(tracker.tracker_id)
for tracker_beacon in tracker_beacons: for tracker_beacon in tracker_beacons:
beacon_coordinator = DataUpdateCoordinator[Mapping[str, Any]]( beacon_coordinator = DataUpdateCoordinator[Mapping[str, Any]](

View File

@@ -6,7 +6,8 @@ from typing import Any, Mapping
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity import DeviceInfo, EntityCategory
from homeassistant.components.binary_sensor import BinarySensorEntity, BinarySensorDeviceClass, ENTITY_ID_FORMAT from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.components.binary_sensor import ENTITY_ID_FORMAT
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator DataUpdateCoordinator
@@ -32,7 +33,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities): # pylint: d
entities.append(GeoRideActiveSubscriptionBinarySensorEntity(coordinator, tracker_device)) entities.append(GeoRideActiveSubscriptionBinarySensorEntity(coordinator, tracker_device))
entities.append(GeoRideNetworkBinarySensorEntity(coordinator, tracker_device)) entities.append(GeoRideNetworkBinarySensorEntity(coordinator, tracker_device))
entities.append(GeoRideMovingBinarySensorEntity(coordinator, tracker_device)) entities.append(GeoRideMovingBinarySensorEntity(coordinator, tracker_device))
entities.append(GeoRideUpdatedBinarySensorEntity(coordinator, tracker_device))
hass.data[GEORIDE_DOMAIN]["devices"][tracker_device.tracker.tracker_id] = coordinator hass.data[GEORIDE_DOMAIN]["devices"][tracker_device.tracker.tracker_id] = coordinator
@@ -102,7 +102,7 @@ class GeoRideStolenBinarySensorEntity(GeoRideBinarySensorEntity):
@property @property
def device_class(self): def device_class(self):
"""Return the device class.""" """Return the device class."""
return BinarySensorDeviceClass.PROBLEM return "problem"
@property @property
def is_on(self): def is_on(self):
@@ -132,7 +132,7 @@ class GeoRideCrashedBinarySensorEntity(GeoRideBinarySensorEntity):
@property @property
def device_class(self): def device_class(self):
"""Return the device class.""" """Return the device class."""
return BinarySensorDeviceClass.PROBLEM return "problem"
@property @property
def is_on(self): def is_on(self):
@@ -236,11 +236,6 @@ class GeoRideNetworkBinarySensorEntity(GeoRideBinarySensorEntity):
return True return True
return False return False
@property
def device_class(self) -> str:
"""device class"""
return BinarySensorDeviceClass.CONNECTIVITY
@property @property
def name(self): def name(self):
""" GeoRide name """ """ GeoRide name """
@@ -273,49 +268,12 @@ class GeoRideMovingBinarySensorEntity(GeoRideBinarySensorEntity):
def is_on(self): def is_on(self):
"""state value property""" """state value property"""
return self._tracker_device.tracker.moving return self._tracker_device.tracker.moving
@property
def device_class(self) -> str:
"""device class"""
return BinarySensorDeviceClass.MOVING
@property @property
def name(self): def name(self):
""" GeoRide name """ """ GeoRide name """
return f"{self._name} is moving" return f"{self._name} is moving"
class GeoRideUpdatedBinarySensorEntity(GeoRideBinarySensorEntity):
"""Represent a tracked device."""
@property
def entity_category(self):
return EntityCategory.DIAGNOSTIC
def __init__(self, coordinator: DataUpdateCoordinator[Mapping[str, Any]],
tracker_device: Device):
"""Set up Georide entity."""
super().__init__(coordinator, tracker_device)
self.entity_id = f"{ENTITY_ID_FORMAT.format('update')}.{tracker_device.tracker.tracker_id}"# pylint: disable=C0301
@property
def unique_id(self):
"""Return the unique ID."""
return f"update_{self._tracker_device.tracker.tracker_id}"
@property
def is_on(self):
"""state value property"""
return not self._tracker_device.tracker.is_up_to_date
@property
def device_class(self) -> str:
"""device class"""
return BinarySensorDeviceClass.UPDATE
@property
def name(self):
""" GeoRide name """
return f"{self._name} have an update"
class GeoRideBeaconUpdatedBinarySensorEntity(GeoRideBeaconBinarySensorEntity): class GeoRideBeaconUpdatedBinarySensorEntity(GeoRideBeaconBinarySensorEntity):
"""Represent a tracked device.""" """Represent a tracked device."""
@property @property
@@ -333,15 +291,15 @@ class GeoRideBeaconUpdatedBinarySensorEntity(GeoRideBeaconBinarySensorEntity):
"""Return the unique ID.""" """Return the unique ID."""
return f"update_{self._tracker_device_beacon.beacon.beacon_id}" return f"update_{self._tracker_device_beacon.beacon.beacon_id}"
@property
def device_class(self):
"""Return the device class."""
return "update"
@property @property
def is_on(self): def is_on(self):
"""state value property""" """state value property"""
return not self._tracker_device_beacon.beacon.is_updated return not self._tracker_device_beacon.beacon.is_updated
@property
def device_class(self) -> str:
"""device class"""
return BinarySensorDeviceClass.UPDATE
@property @property
def name(self): def name(self):

View File

@@ -12,7 +12,7 @@ from .const import CONF_EMAIL, CONF_PASSWORD, CONF_TOKEN, DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@config_entries.HANDLERS.register(DOMAIN) @config_entries.HANDLERS.register("georide")
class GeoRideConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class GeoRideConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""GeoRide config flow """ """GeoRide config flow """
@@ -37,6 +37,8 @@ class GeoRideConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
vol.Required(CONF_PASSWORD): vol.All(str) vol.Required(CONF_PASSWORD): vol.All(str)
})) }))
async def async_step_georide_login(self, user_input): async def async_step_georide_login(self, user_input):
""" try to seupt GeoRide Account """ """ try to seupt GeoRide Account """

View File

@@ -9,7 +9,6 @@ class Device:
def __init__(self, tracker): def __init__(self, tracker):
"""Initialize GeoRideTracker device.""" """Initialize GeoRideTracker device."""
self._tracker: GeoRideTracker = tracker self._tracker: GeoRideTracker = tracker
@property @property
def tracker(self): def tracker(self):
@@ -21,26 +20,11 @@ class Device:
"""Get the name.""" """Get the name."""
return self._tracker.tracker_name return self._tracker.tracker_name
@property
def default_manufacturer(self) -> str:
"""Get the default_manufacturer."""
return "GeoRide"
@property @property
def manufacturer(self) -> str: def manufacturer(self) -> str:
"""Get the manufacturer.""" """Get the manufacturer."""
return "GeoRide" return "GeoRide"
@property
def default_model(self) -> str:
"""Get the default model."""
return "GeoRide 1"
@property
def suggested_area(self) -> str:
"""Get the suggested_area."""
return "Garage"
@property @property
def model_name(self) -> str: def model_name(self) -> str:
"""Get the model name.""" """Get the model name."""
@@ -50,28 +34,10 @@ class Device:
elif self._tracker.version == 2: elif self._tracker.version == 2:
name = "GeoRide 2" name = "GeoRide 2"
elif self._tracker.version == 3: elif self._tracker.version == 3:
if self._tracker.model == 'georide-3': name = "GeoRide 3"
name = "GeoRide 3"
else:
name = "GeoRide Mini"
else: else:
name = "Prototype / Unknown" name = "Prototype / Unknown"
return name return name
@property
def sw_version(self) -> str:
"""Get the software version."""
return str(self._tracker.software_version)
@property
def hw_version(self) -> str:
"""Get the hardware version."""
return str(self._tracker.version)
@property
def unique_id(self) -> str:
"""Get the unique id."""
return {(GEORIDE_DOMAIN, self._tracker.tracker_id)}
@property @property
def device_info(self): def device_info(self):
@@ -79,13 +45,17 @@ class Device:
return { return {
"name": self.name, "name": self.name,
"identifiers": self.unique_id, "identifiers": self.unique_id,
"manufacturer": self.manufacturer, "manufacturer": "GeoRide",
"model": self.model_name, "model": self.model_name,
"suggested_area": self.suggested_area, "suggested_area": "Garage"
"sw_version" : self.sw_version,
"hw_version": self.hw_version
} }
@property
def unique_id(self) -> str:
"""Get the unique id."""
return {(GEORIDE_DOMAIN, self._tracker.tracker_id)}
def __str__(self) -> str: def __str__(self) -> str:
"""Get string representation.""" """Get string representation."""
return f"GeoRide Device: {self.name}::{self.model_name}::{self.unique_id}" return f"GeoRide Device: {self.name}::{self.model_name}::{self.unique_id}"
@@ -107,25 +77,10 @@ class DeviceBeacon:
"""Get the name.""" """Get the name."""
return self._beacon.name return self._beacon.name
@property
def default_manufacturer(self) -> str:
"""Get the default_manufacturer."""
return "GeoRide"
@property @property
def manufacturer(self) -> str: def manufacturer(self) -> str:
"""Get the manufacturer.""" """Get the manufacturer."""
return "GeoRide" return "GeoRide"
@property
def default_model(self) -> str:
"""Get the default model."""
return "GeoRide Beacon"
@property
def suggested_area(self) -> str:
"""Get the suggested_area."""
return "Garage"
@property @property
def model_name(self) -> str: def model_name(self) -> str:
@@ -133,28 +88,23 @@ class DeviceBeacon:
name = "GeoRide Beacon" name = "GeoRide Beacon"
return name return name
@property
def unique_id(self) -> str:
"""Get the unique id."""
return {(GEORIDE_DOMAIN, self._beacon.beacon_id)}
@property
def via_device(self) -> str:
"""Get the unique id."""
return (GEORIDE_DOMAIN, self._beacon.linked_tracker_id )
@property @property
def device_info(self): def device_info(self):
"""Return the device info.""" """Return the device info."""
return { return {
"name": self.name, "name": self.name,
"identifiers": self.unique_id, "identifiers": self.unique_id,
"manufacturer": self.manufacturer, "manufacturer": "GeoRide",
"model": self.model_name, "model": self.model_name,
"suggested_area": self.suggested_area, "suggested_area": "Garage"
"via_device": self.via_device
} }
@property
def unique_id(self) -> str:
"""Get the unique id."""
return {(GEORIDE_DOMAIN, self._beacon.beacon_id)}
def __str__(self) -> str: def __str__(self) -> str:
"""Get string representation.""" """Get string representation."""
return f"GeoRide Device: {self.name}::{self.model_name}::{self.unique_id}" return f"GeoRide Device: {self.name}::{self.model_name}::{self.unique_id}"

View File

@@ -3,7 +3,7 @@
import logging import logging
from typing import Any, Mapping from typing import Any, Mapping
from homeassistant.components.device_tracker.const import DOMAIN, SourceType from homeassistant.components.device_tracker.const import DOMAIN, SOURCE_TYPE_GPS
from homeassistant.components.device_tracker.config_entry import TrackerEntity from homeassistant.components.device_tracker.config_entry import TrackerEntity
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
@@ -78,7 +78,7 @@ class GeoRideTrackerEntity(CoordinatorEntity, TrackerEntity):
@property @property
def source_type(self): def source_type(self):
"""Return the source type, eg gps or router, of the device.""" """Return the source type, eg gps or router, of the device."""
return SourceType.GPS return SOURCE_TYPE_GPS
@property @property
def location_accuracy(self): def location_accuracy(self):

View File

@@ -6,10 +6,10 @@
"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>=1.0.0", "georideapilib>=0.8.4",
"pyjwt>=2.2.0" "pyjwt==2.1.0"
], ],
"dependencies": [], "dependencies": [],
"codeowners": ["ptimatth"], "codeowners": ["ptimatth"],
"version": "1.1.0" "version": "0.9.0"
} }

View File

@@ -5,7 +5,8 @@ from typing import Any, Mapping
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity import DeviceInfo, EntityCategory
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass, ENTITY_ID_FORMAT from homeassistant.components.sensor import SensorEntity
from homeassistant.components.sensor import ENTITY_ID_FORMAT
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
@@ -244,11 +245,6 @@ class GeoRideInternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
"""icon getter""" """icon getter"""
return "mdi:battery" return "mdi:battery"
@property
def device_class(self) -> str:
"""device class"""
return SensorDeviceClass.VOLTAGE
@property @property
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return the device info.""" """Return the device info."""
@@ -306,11 +302,6 @@ class GeoRideExternalBatterySensorEntity(CoordinatorEntity, SensorEntity):
"""icon getter""" """icon getter"""
return "mdi:battery" return "mdi:battery"
@property
def device_class(self) -> str:
"""device class"""
return SensorDeviceClass.VOLTAGE
@property @property
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return the device info.""" """Return the device info."""
@@ -400,11 +391,6 @@ class GeoRideBeaconBatterySensorEntity(CoordinatorEntity, SensorEntity):
"""icon getter""" """icon getter"""
return "mdi:battery" return "mdi:battery"
@property
def device_class(self) -> str:
"""device class"""
return SensorDeviceClass.BATTERY
@property @property
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return the device info.""" """Return the device info."""

View File

@@ -4,5 +4,5 @@
"render_readme": true, "render_readme": true,
"domains": ["devices_tracker", "sensor"], "domains": ["devices_tracker", "sensor"],
"country": ["FR"], "country": ["FR"],
"homeassistant": "2024.11.0" "homeassistant": "2022.2.0"
} }