Skip to content

Commit

Permalink
Fix item_ and value_price (#100)
Browse files Browse the repository at this point in the history
* Update sensor.py

* Update sensor.py
  • Loading branch information
simphide committed Jan 5, 2024
1 parent 643be59 commit b2ad34f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions custom_components/tgtg/sensor.py
Expand Up @@ -138,45 +138,45 @@ def extra_state_attributes(self) -> dict | None:
data[ATTR_ITEM_URL] = "https://share.toogoodtogo.com/item/" + str(
self.tgtg_answer["item"]["item_id"]
)
if "price_including_taxes" in self.tgtg_answer["item"]:
if "item_price" in self.tgtg_answer["item"]:
data[ATTR_PRICE] = (
str(
int(
self.tgtg_answer["item"]["price_including_taxes"][
self.tgtg_answer["item"]["item_price"][
"minor_units"
]
)
/ pow(
10,
int(
self.tgtg_answer["item"]["price_including_taxes"][
self.tgtg_answer["item"]["item_price"][
"decimals"
]
),
)
)
+ " "
+ self.tgtg_answer["item"]["price_including_taxes"]["code"]
+ self.tgtg_answer["item"]["item_price"]["code"]
)
if "value_including_taxes" in self.tgtg_answer["item"]:
if "item_value" in self.tgtg_answer["item"]:
data[ATTR_VALUE] = (
str(
int(
self.tgtg_answer["item"]["value_including_taxes"][
self.tgtg_answer["item"]["item_value"][
"minor_units"
]
)
/ pow(
10,
int(
self.tgtg_answer["item"]["value_including_taxes"][
self.tgtg_answer["item"]["item_value"][
"decimals"
]
),
)
)
+ " "
+ self.tgtg_answer["item"]["value_including_taxes"]["code"]
+ self.tgtg_answer["item"]["item_value"]["code"]
)
if "pickup_interval" in self.tgtg_answer:
if "start" in self.tgtg_answer["pickup_interval"]:
Expand Down

0 comments on commit b2ad34f

Please sign in to comment.