Skip to content

Commit

Permalink
Catch if no price is set, references #24
Browse files Browse the repository at this point in the history
  • Loading branch information
geertmeersman committed Apr 21, 2023
1 parent a97a022 commit 62c21cd
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions custom_components/nexxtmove/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,18 +423,20 @@ def fetch_data(self):
key = format_entity_name(
f"{self.username} charging point {id} price"
)
price_info = charging_point.get("price").split(" ")
data[key] = NexxtmoveItem(
name=f"{charging_point.get('name')} price",
key=key,
type="price",
sensor_type="sensor",
device_key=device_key,
device_name=device_name,
device_model=device_model,
state=price_info[0],
native_unit_of_measurement=price_info[1],
)
price = charging_point.get("price")
if price is not None and len(price) != 0:
price_info = price.split(" ")
data[key] = NexxtmoveItem(
name=f"{charging_point.get('name')} price",
key=key,
type="price",
sensor_type="sensor",
device_key=device_key,
device_name=device_name,
device_model=device_model,
state=price_info[0],
native_unit_of_measurement=price_info[1],
)
events = self.charging_point_events(id)
if events.get("events") and len(events.get("events")):
key = format_entity_name(
Expand Down

0 comments on commit 62c21cd

Please sign in to comment.