Use constants in Picnic service functions (#109170)

Co-authored-by: Franck Nijhof <git@frenck.dev>
pull/109195/head
Noah Groß 2024-01-31 09:01:17 +01:00 committed by GitHub
parent 01df5f9cab
commit db0486c5e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -61,17 +61,17 @@ async def handle_add_product(
hass: HomeAssistant, api_client: PicnicAPI, call: ServiceCall
) -> None:
"""Handle the call for the add_product service."""
product_id = call.data.get("product_id")
product_id = call.data.get(ATTR_PRODUCT_ID)
if not product_id:
product_id = await hass.async_add_executor_job(
product_search, api_client, cast(str, call.data["product_name"])
product_search, api_client, cast(str, call.data[ATTR_PRODUCT_NAME])
)
if not product_id:
raise PicnicServiceException("No product found or no product ID given!")
await hass.async_add_executor_job(
api_client.add_product, product_id, call.data.get("amount", 1)
api_client.add_product, product_id, call.data.get(ATTR_AMOUNT, 1)
)