I want to be able to get a message playing on Sonos (TTS):
- “Milk is added to your shopping list”.
But that seems impossible with the current API
I want to be able to get a message playing on Sonos (TTS):
But that seems impossible with the current API
That can be easily done using automation IF my feature request here comes true.
I’m trying to add items to the shopping list via telegram (text) and zanzito (voice).
Using automation, the message feedback can be added as additional service call under the action part of the automation. Will share with you the example later when I have access to my PC.
Anyway, please vote for this feature request. Thanks.
Seems I’m late to the party, but I found this thread while looking if it would be possible to integrate the 2D barcode scanner I impulse bought on an Amazon Lightning Deal.
I’d like to have a component that would allow us to check household inventory if we make a random grocery stop, or to check when the last time we bought some random spice.
I submitted a Pull Request which got released with version 0.71 of Home Assistant.
There are now two services which allow adding and removing items from the shopping list!
Cool! Half of my request is fulfilled. Now waiting for a sensor that will list down all items in the shopping list.
I want to support this request because I like the way the shopping list works and how it looks. However, I am struggling with working with the shopping list at the moment.
My intention is to send the filled shopping list via email and start a new one afterwards. At the moment, I am able to send it via email (using an external script reading the .shopping_list.json) but I have no idea how to clear the complete list to start a new one.
In the future, I also want to add voice control by snips. I guess the new services should help with that, so I already appreciate what has been done so far
great idea. appreciate if you can share on how you do that. thanks in advance.
Sure. It is just a little quick & dirty python code that I added as a shell command to homeassistant:
#!/usr/bin/python
# coding: utf8
import json, smtplib, datetime
sender='XXX'
reciever='YYY'
account='ZZZ'
password='BBB'
with open('PATHTOHOMEASSISTANT/.shopping_list.json') as data_file:
shoppingListData = json.load(data_file)
# build message
content = u"Shopping list:\n"
for entry in shoppingListData:
if not entry['complete']:
content += u"- %s\n" % entry['name']
content += u"\nThank you for shopping!"
mail=smtplib.SMTP('smtp.gmail.com',587)
mail.ehlo()
mail.starttls()
mail.login(account,password)
message = """From: %s\nTo: %s\nSubject: %s\n\n%s""" % (sender, reciever, "Shopping list", content)
mail.sendmail(sender,reciever,message.encode('utf-8'))
mail.close()
The code was tested using gmail. However it should work with other email providers by replacing the SMTP server accordingly. You need to enter the sender email address, the receiver email address and your mail account information that are hard coded (there certainly is room for improvements )
Why not make an command line sensor? This is working in docker also.
sensor:
- platform: command_line
name: shopping_list
command: /config/shopping_list.py
shopping_list.py:
#!/usr/local/bin/python
# coding: utf8
import json
with open('/config/.shopping_list.json') as data_file:
shoppingListData = json.load(data_file)
content = u"Boodschappen:\n"
for entry in shoppingListData:
if not entry['complete']:
content += u"- %s\n" % entry['name']
content += u"\n"
print(content)
Then this is possible:
trigger:
platform: zone
zone: zone.shop
event: enter
action:
service: notify.telegram
data_template:
message: '{{states.sensor.shopping_list.state}}'
I’m wondering if someone is working on recognize 2D Barcode (specific hardware device or using image processing ?).
There is an API for matching barcode and a specific product. It could be cool to scan a barcode to automatically add the product to the shopping list.
Thanks. Command line sensor works perfectly for me.
This is great. Thanks for the simple python script. At first the sensor reported a status of unknown for me. I had to set the sensor up slightly differently in Hassio by prefacing the command with python3.
- platform: command_line
name: shopping_list
command: python3 /config/shopping_list.py
Hello All and Flovie in particular.
New to Homeassistant and Linux
Im trying to use your python script above but i dont know how to execute it.
I have created a folder under the homeassistant folder called “python_scripts” and created a send.py file there with your script , ofcourse edited with my e-mail address and path
home/homeassistant/.homeassistant/python_scripts/shopping_list.json
I dont know how to activate or run the script, can i create a button “send email” to run this script or can i controll it with a simple voice command?
Any help appreciated.
#!/usr/bin/python
# coding: utf8
import json, smtplib, datetime
sender='[email protected]'
reciever='[email protected]'
account='[email protected]'
password='xxx'
with open(' home/homeassistant/.homeassistant/python_scripts/shopping_list.json') as data_file:
shoppingListData = json.load(data_file)
# build message
content = u"Shopping list:\n"
for entry in shoppingListData:
if not entry['complete']:
content += u"- %s\n" % entry['name']
content += u"\nThank you for shopping!"
mail=smtplib.SMTP('smtp.gmail.com',587)
mail.ehlo()
mail.starttls()
mail.login(account,password)
message = """From: %s\nTo: %s\nSubject: %s\n\n%s""" % (sender, reciever, "Shopping list", content)
mail.sendmail(sender,reciever,message.encode('utf-8'))
mail.close()
Hi,
if you are using homeassistant in an environment where you are free to place and run python scripts. Than you can go the way I went:
create a file with the pyhton code inside (for example sendshoppinglist.py)
create a shell_command component in your config.yaml. For example:
shell_command:
sendshoppinglist: /sendshoppinglist.py
I didn’t get the correct indentation working in this example, so be careful with copy&paste. This code will expose the python code as a service to your home assistant.
3. You are free to call this service how you like. May it be voice command or an automation.
If you are in a more restricted environment, then you should take a look at the code by Mark_Meijer and use a notification component of your choice.
I hope this helped you out and pointed in the right direction.
Thank you Flovie
Yes that helped me, i have it all working now.
Ran into more problems with gmail thoo, they have beefed up their security and default setting is Not to allow unsecure apps to e-mail. I logged into my gmail and under “security…” there was an option to turn off the setting for unsecure apps.
thanks again
Hi guys.
I would like to add an item to the shopping list with snips but i am getting errors.
addShoppingListItem:
action:
- service: shopping_list.add_item
data_template:
name: {{ shopping_item }}
This gives me this error:
Tue Jan 01 2019 15:19:43 GMT+0100 (Mitteleuropäische Normalzeit)
invalid key: "OrderedDict([('shopping_item', None)])"
in "/home/homeassistant/.homeassistant/intent_script.yaml", line 167, column 0
check line 167 in your file intent_script.yaml
There must be an error there.
Thank you for your answer. line 167 is
name: {{ shopping_item }}
Any ideas to integrate with the google shopping list (home)?