mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Refactor lyft sensor update (#7233)
This commit is contained in:
parent
7b3cc9fe1f
commit
b6a4a0d9af
@ -159,13 +159,14 @@ class LyftSensor(Entity):
|
|||||||
self._product = self.data.products[self._product_id]
|
self._product = self.data.products[self._product_id]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
return
|
||||||
|
self._state = None
|
||||||
if self._sensortype == 'time':
|
if self._sensortype == 'time':
|
||||||
eta = self._product['eta']
|
eta = self._product['eta']
|
||||||
if (eta is not None) and (eta.get('is_valid_estimate')):
|
if (eta is not None) and (eta.get('is_valid_estimate')):
|
||||||
time_estimate = eta.get('eta_seconds', 0)
|
time_estimate = eta.get('eta_seconds')
|
||||||
|
if time_estimate is None:
|
||||||
|
return
|
||||||
self._state = int(time_estimate / 60)
|
self._state = int(time_estimate / 60)
|
||||||
else:
|
|
||||||
self._state = 0
|
|
||||||
elif self._sensortype == 'price':
|
elif self._sensortype == 'price':
|
||||||
estimate = self._product['estimate']
|
estimate = self._product['estimate']
|
||||||
if (estimate is not None) and \
|
if (estimate is not None) and \
|
||||||
@ -173,8 +174,6 @@ class LyftSensor(Entity):
|
|||||||
self._state = (int(
|
self._state = (int(
|
||||||
(estimate.get('estimated_cost_cents_min', 0) +
|
(estimate.get('estimated_cost_cents_min', 0) +
|
||||||
estimate.get('estimated_cost_cents_max', 0)) / 2) / 100)
|
estimate.get('estimated_cost_cents_max', 0)) / 2) / 100)
|
||||||
else:
|
|
||||||
self._state = 0
|
|
||||||
|
|
||||||
|
|
||||||
class LyftEstimate(object):
|
class LyftEstimate(object):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user