Interesting. Well, following the link that @Burningstone supplied would seem to imply the information is saved in some file in JSON format. No idea how it’s supposed to be used. I have no familiarity with this “integration”, and the doc page seems sparse at best.
I copied “Купить:” (“to buy” in russian) from states. But when I looked to .py file I found that there is “/n” after “купить”. So I tried “Купить:\n” and that did not help. I even tried to write “купить” and then tap enter. That did not help too, I am still getting the message.
Will try it out too when I will figure out the syntax
Can I delete “to buy” from .py at all? So Just will have a list of items or nothing. And then I will use length.
In that case I can use shopping list not only for shopping. Maybe I will write there what I have to do after leaving work.
Isn’t this correct?
#!/usr/local/bin/python
# coding: utf8
import json
with open('/config/.shopping_list.json') as data_file:
shoppingListData = json.load(data_file)
content = u
for entry in shoppingListData:
if not entry['complete']:
content += u"- %s\n" % entry['name']
content += u"\n"
print(content)
This script will not work because of this content = u
The prefix ‘u’ is used to tell python that the string that follows it will be formatted in unicode.
Try this:
#!/usr/local/bin/python
# coding: utf8
import json
with open('/config/.shopping_list.json') as data_file:
shoppingListData = json.load(data_file)
content = ""
for entry in shoppingListData:
if not entry['complete']:
content += u"- %s\n" % entry['name']
print(content)
I’m a little confused. If it’s working, fine, but I don’t see in the Python script where it’s outputting a first line of 'To buy:'. Also in the picture of the States page you showed sensor.shopping_list and it had something in a completely different alphabet.
Sorry, I am just constantly changing “to buy” to russian word and trying different things. In the end, as I understand Issue was only in me, because I was triggering automation manually and that is why condition was ignored