Fix switch response
This commit is contained in:
@@ -49,7 +49,7 @@ class GeoRideTrackerEntity(CoordinatorEntity, TrackerEntity):
|
|||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the unique ID."""
|
"""Return the unique ID."""
|
||||||
return self._tracker_id
|
return self._tracker.tracker_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@@ -59,14 +59,14 @@ class GeoRideTrackerEntity(CoordinatorEntity, TrackerEntity):
|
|||||||
@property
|
@property
|
||||||
def latitude(self):
|
def latitude(self):
|
||||||
"""Return latitude value of the device."""
|
"""Return latitude value of the device."""
|
||||||
if self._data.latitude:
|
if self._tracker.latitude:
|
||||||
return self._tracker.latitude
|
return self._tracker.latitude
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def longitude(self):
|
def longitude(self):
|
||||||
"""Return longitude value of the device."""
|
"""Return longitude value of the device."""
|
||||||
if self._data.longitude:
|
if self._tracker.longitude:
|
||||||
return self._tracker.longitude
|
return self._tracker.longitude
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@@ -86,6 +86,9 @@ class GeoRideTrackerEntity(CoordinatorEntity, TrackerEntity):
|
|||||||
"""return the entity icon"""
|
"""return the entity icon"""
|
||||||
return "mdi:map-marker"
|
return "mdi:map-marker"
|
||||||
|
|
||||||
|
async def async_update(self):
|
||||||
|
""" update the current tracker"""
|
||||||
|
_LOGGER.debug('update')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ class GeoRideLockSwitchEntity(CoordinatorEntity, SwitchEntity):
|
|||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._tracker = tracker
|
self._tracker = tracker
|
||||||
self._name = tracker.tracker_name
|
self._name = tracker.tracker_name
|
||||||
self._is_on = tracker.is_locked
|
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format("lock") +"." + str(tracker.tracker_id)
|
self.entity_id = ENTITY_ID_FORMAT.format("lock") +"." + str(tracker.tracker_id)
|
||||||
self._hass = hass
|
self._hass = hass
|
||||||
|
|
||||||
@@ -64,7 +63,6 @@ class GeoRideLockSwitchEntity(CoordinatorEntity, SwitchEntity):
|
|||||||
token, self._tracker_id)
|
token, self._tracker_id)
|
||||||
if success:
|
if success:
|
||||||
self._tracker.is_locked = True
|
self._tracker.is_locked = True
|
||||||
self._is_on = True
|
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs):
|
async def async_turn_off(self, **kwargs):
|
||||||
""" unlock the GeoRide tracker """
|
""" unlock the GeoRide tracker """
|
||||||
@@ -75,7 +73,6 @@ class GeoRideLockSwitchEntity(CoordinatorEntity, SwitchEntity):
|
|||||||
token, self._tracker_id)
|
token, self._tracker_id)
|
||||||
if success:
|
if success:
|
||||||
self._tracker.is_locked = False
|
self._tracker.is_locked = False
|
||||||
self._is_on = False
|
|
||||||
|
|
||||||
async def async_toggle(self, **kwargs):
|
async def async_toggle(self, **kwargs):
|
||||||
""" toggle lock the georide tracker """
|
""" toggle lock the georide tracker """
|
||||||
@@ -85,13 +82,6 @@ class GeoRideLockSwitchEntity(CoordinatorEntity, SwitchEntity):
|
|||||||
result = await self._hass.async_add_executor_job(GeoRideApi.toogle_lock_tracker,
|
result = await self._hass.async_add_executor_job(GeoRideApi.toogle_lock_tracker,
|
||||||
token, self._tracker_id)
|
token, self._tracker_id)
|
||||||
self._tracker.is_locked = result
|
self._tracker.is_locked = result
|
||||||
self._is_on = result
|
|
||||||
|
|
||||||
async def async_update(self):
|
|
||||||
""" update the current tracker"""
|
|
||||||
_LOGGER.debug('update')
|
|
||||||
self._name = self._tracker.tracker_name
|
|
||||||
self._is_on = self._tracker.is_lockedtracker
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
@@ -106,12 +96,12 @@ class GeoRideLockSwitchEntity(CoordinatorEntity, SwitchEntity):
|
|||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
""" GeoRide switch status """
|
""" GeoRide switch status """
|
||||||
return self._is_on
|
return self._tracker.is_locked
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
"""return the entity icon"""
|
"""return the entity icon"""
|
||||||
if self._is_on:
|
if self._tracker.tracker_id:
|
||||||
return "mdi:lock"
|
return "mdi:lock"
|
||||||
return "mdi:lock-open"
|
return "mdi:lock-open"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user