Fix switch response

develop
Matthieu DUVAL 4 years ago
parent 0113102a7f
commit 660aaa0180

@ -49,7 +49,7 @@ class GeoRideTrackerEntity(CoordinatorEntity, TrackerEntity):
@property
def unique_id(self):
"""Return the unique ID."""
return self._tracker_id
return self._tracker.tracker_id
@property
def name(self):
@ -59,14 +59,14 @@ class GeoRideTrackerEntity(CoordinatorEntity, TrackerEntity):
@property
def latitude(self):
"""Return latitude value of the device."""
if self._data.latitude:
if self._tracker.latitude:
return self._tracker.latitude
return None
@property
def longitude(self):
"""Return longitude value of the device."""
if self._data.longitude:
if self._tracker.longitude:
return self._tracker.longitude
return None
@ -86,6 +86,9 @@ class GeoRideTrackerEntity(CoordinatorEntity, TrackerEntity):
"""return the entity icon"""
return "mdi:map-marker"
async def async_update(self):
""" update the current tracker"""
_LOGGER.debug('update')
@property
def device_info(self):

@ -50,7 +50,6 @@ class GeoRideLockSwitchEntity(CoordinatorEntity, SwitchEntity):
super().__init__(coordinator)
self._tracker = tracker
self._name = tracker.tracker_name
self._is_on = tracker.is_locked
self.entity_id = ENTITY_ID_FORMAT.format("lock") +"." + str(tracker.tracker_id)
self._hass = hass
@ -64,7 +63,6 @@ class GeoRideLockSwitchEntity(CoordinatorEntity, SwitchEntity):
token, self._tracker_id)
if success:
self._tracker.is_locked = True
self._is_on = True
async def async_turn_off(self, **kwargs):
""" unlock the GeoRide tracker """
@ -75,7 +73,6 @@ class GeoRideLockSwitchEntity(CoordinatorEntity, SwitchEntity):
token, self._tracker_id)
if success:
self._tracker.is_locked = False
self._is_on = False
async def async_toggle(self, **kwargs):
""" 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,
token, self._tracker_id)
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
def unique_id(self):
@ -106,12 +96,12 @@ class GeoRideLockSwitchEntity(CoordinatorEntity, SwitchEntity):
@property
def is_on(self):
""" GeoRide switch status """
return self._is_on
return self._tracker.is_locked
@property
def icon(self):
"""return the entity icon"""
if self._is_on:
if self._tracker.tracker_id:
return "mdi:lock"
return "mdi:lock-open"

Loading…
Cancel
Save