Skip to content

Commit

Permalink
Update shopping list update phrase
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Apr 8, 2024
1 parent 87d8570 commit d544666
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/yandex_station/hass/shopping_list.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import logging
import re
import uuid
Expand Down Expand Up @@ -51,22 +50,23 @@ async def shopping_sync(hass: HomeAssistant, glagol: YandexGlagol):
return

try:
card = await glagol.send({"command": "sendText", "text": "Список покупок"})
payload = {"command": "sendText", "text": "Что в списке покупок"}
card = await glagol.send(payload)

while for_remove := shopping_for_remove(hass, card["text"]):
# не удаляет больше 5 элементов за раз
text = "Удали " + ", ".join(for_remove[:5])
await glagol.send({"command": "sendText", "text": text})
# обновим после изменений
card = await glagol.send({"command": "sendText", "text": "Список покупок"})
card = await glagol.send(payload)

if for_add := shopping_for_add(hass, card["text"]):
for item in for_add:
# плохо работает, если добавлять всё сразу через запятую
text = f"Добавь в список покупок {item}"
await glagol.send({"command": "sendText", "text": text})
# обновим после изменений
card = await glagol.send({"command": "sendText", "text": "Список покупок"})
card = await glagol.send(payload)

shopping_save(hass, card["text"])
except Exception as e:
Expand Down

0 comments on commit d544666

Please sign in to comment.