Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voice Command #172

Open
pihome-shc opened this issue Mar 15, 2020 · 127 comments
Open

Voice Command #172

pihome-shc opened this issue Mar 15, 2020 · 127 comments

Comments

@pihome-shc
Copy link
Owner

Recently bought Amazon Echo for kids to give me option to interact with voice control for some learning, so far kids happy asking questions but it got me thinking to what it takes to implement voice commands for PiHome. any one have any experience in voice command with Google Home and Amazon Echo?

@scottagecheeseandcrackers

I rarely use my phone to interact with pihome. Day to day usage is almost entirely through google assistant...here is my method Link to pihome google voice setup

@pihome-shc
Copy link
Owner Author

@scottagecheeseandcrackers almost forgot about that post, does same apply to Amazon Echo? can all the setup be done on Raspberry pi without external dependency ?

@scottagecheeseandcrackers

Yep...it should. My voice control runs on my pihome raspberry pi - very low CPU usage. I don't have an Amazon echo, but it looks like you would just need to add the following plugin to node-red to get it to work - node-red-contrib-alexa-remote2

@twa127
Copy link
Contributor

twa127 commented Mar 23, 2020

Added basic BOOST control using Belkin WeMo emulation. Amazon echo need to be on the same network as PiHome. Install using 'sh install_echo.sh'. Tell Echo 'discover devices' then if it finds the zone names, you can tell Echo 'zone name on' or 'zone name off'

@dvdcut
Copy link
Contributor

dvdcut commented Mar 23, 2020

@twa127
you are a legend, one small question, your pull request have any external dependency? i m not home yet but i can not wait to try this.

ps: i wish you can see excitement on my face

@twa127
Copy link
Contributor

twa127 commented Mar 23, 2020

:-) yep only 'pip install requests' and I've put that in the 'install_echo.sh'

@twa127
Copy link
Contributor

twa127 commented Mar 23, 2020

By the way I've set it up as a service called 'pihome_amazon_echo.service' which gets configured by install

pihome-shc added a commit that referenced this issue Mar 23, 2020
Amazon Echo Boost Basic Control #172
@pihome-shc
Copy link
Owner Author

@twa127 on my default img,

root@pihome:/var/www# cd amazon_echo/
root@pihome:/var/www/amazon_echo# sh install_echo.sh
sudo: pip: command not found
Created symlink /etc/systemd/system/multi-user.target.wants/pihome_amazon_echo.service → /lib/systemd/system/p                                                                                                                               ihome_amazon_echo.service.

i had to install
sudo apt-get install python-pip

here is the service status

`Installing collected packages: idna, urllib3, certifi, chardet, requests
Successfully installed certifi-2019.11.28 chardet-3.0.4 idna-2.9 requests-2.23.0 urllib3-1.25.8
Failed to start pihome_amazon_echo.service: Unit pihome_amazon_echo.service has a bad unit file setting.
See system logs and 'systemctl status pihome_amazon_echo.service' for details.
root@pihome:/var/www/amazon_echo# systemctl status pihome_amazon_echo.service
● pihome_amazon_echo.service - Echo
Loaded: bad-setting (Reason: Unit pihome_amazon_echo.service has a bad unit file setting.)
Active: failed (Result: exit-code) since Mon 2020-03-23 17:46:44 GMT; 3min 2s ago
Main PID: 1378 (code=exited, status=1/FAILURE)

Mar 23 17:46:44 pihome python[1378]: import requests
Mar 23 17:46:44 pihome python[1378]: ImportError: No module named requests
Mar 23 17:46:44 pihome systemd[1]: pihome_amazon_echo.service: Main process exited, code=exited, status=1/FAILURE
Mar 23 17:46:44 pihome systemd[1]: pihome_amazon_echo.service: Failed with result 'exit-code'.
Mar 23 17:49:16 pihome systemd[1]: /lib/systemd/system/pihome_amazon_echo.service:10: Unknown lvalue '' in section 'Install', ignoring
Mar 23 17:49:16 pihome systemd[1]: /lib/systemd/system/pihome_amazon_echo.service:20: Unknown lvalue '' in section 'Install', ignoring
Mar 23 17:49:16 pihome systemd[1]: pihome_amazon_echo.service: Service has more than one ExecStart= setting, which is only allowed for Ty
Mar 23 17:49:17 pihome systemd[1]: /lib/systemd/system/pihome_amazon_echo.service:10: Unknown lvalue '' in section 'Install', ignoring
Mar 23 17:49:17 pihome systemd[1]: /lib/systemd/system/pihome_amazon_echo.service:20: Unknown lvalue '' in section 'Install', ignoring
Mar 23 17:49:17 pihome systemd[1]: pihome_amazon_echo.service: Service has more than one ExecStart= setting, which is only allowed for Ty
`

anything missing or i m doing something wrong?

@twa127
Copy link
Contributor

twa127 commented Mar 23, 2020

Hi,

to create the unit file manually

sudo nano /lib/systemd/system/pihome_amazon_echo.service

enter the following text and save

[Unit]
Description=Echo
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/python /var/www/amazon_echo/echo_pihome.py
Restart=on-abort

[Install]
WantedBy=multi-user.target

to enable the service -

sudo systemctl daemon-reload
sudo systemctl enable pihome_amazon_echo.service
sudo systemctl start pihome_amazon_echo.service

@pihome-shc
Copy link
Owner Author

@twa127 my bad,
i ran script few times and end up multiple entries in /lib/systemd/system/pihome_amazon_echo.service now i have service up and running but echo can not find any device.
do i have to add any skills to echo?

@twa127
Copy link
Contributor

twa127 commented Mar 23, 2020

hi,

I did not add any skills.

The Pi and Echo need to be on the same network.

You can run in debug mode by stopping the service with 'systemctl stop pihome_amazon_echo.service' then run from the 'amazon_echo' directory issue the command 'python echo_pihome.py'

@twa127
Copy link
Contributor

twa127 commented Mar 23, 2020

running in DEBUG mode

image

@pihome-shc
Copy link
Owner Author

my echo and pi are on same network only difference is pi is wired and echo is wifi but same rounter same ip range, here is output

root@pihome:/var/www/amazon_echo# python echo_pihome.py DEBUG:root:Listening for UPnP broadcasts DEBUG:root:got local address of 192.168.99.2 DEBUG:root:UPnP broadcast listener: new device registered DEBUG:root:FauxMo device 'First Floor' ready on 192.168.99.2:52001 DEBUG:root:UPnP broadcast listener: new device registered DEBUG:root:FauxMo device 'Hot Water' ready on 192.168.99.2:52002 DEBUG:root:UPnP broadcast listener: new device registered DEBUG:root:FauxMo device 'Ground Floor' ready on 192.168.99.2:52000 DEBUG:root:Entering fauxmo polling loop

@pihome-shc
Copy link
Owner Author

as far as i know there is no firewall on my rpi, and not iptables either (the usual suspect)

@twa127
Copy link
Contributor

twa127 commented Mar 23, 2020

looks okay to me - what happens when you tell echo 'find my devices'

@pihome-shc
Copy link
Owner Author

echo can not find any device, "i couldn't find smart home device"
it isn't firewall as i just did port scan and 52000 to 52002 are open, if i stop service all three ports are not responding so it mean script is working its my echo have some issues. :(

@twa127
Copy link
Contributor

twa127 commented Mar 23, 2020

strange

@twa127
Copy link
Contributor

twa127 commented Mar 23, 2020

we could do with someone else to give it a try, it ran okay on both my RPi and Beaglebone

@pihome-shc
Copy link
Owner Author

little help from raspberry pi forum link
if i have python echo_pihome.py running, and from second pi i run following command (dont ask me what is is doing i think it simulate an alexa request)
echo -e "M-SEARCH\r\nurn:Belkin:device:**" | nc.traditional -u 239.255.255.250 1900
on my rpi i can see its working so something is wrong with my echo.

DEBUG:root:Responding to search for First Floor
DEBUG:root:Responding to search for Hot Water
DEBUG:root:Responding to search for Ground Floor

@pihome-shc
Copy link
Owner Author

did bit more digging and my echo is looking for response on port 5353 or 1900, even if i change port in python script echo still unable to find pihome.

ssdp
mdns

@twa127
Copy link
Contributor

twa127 commented Mar 24, 2020 via email

@twa127
Copy link
Contributor

twa127 commented Mar 24, 2020 via email

@dvdcut
Copy link
Contributor

dvdcut commented Mar 24, 2020

@pihome-shc i had same issue as your in first: end up with multiple entries in /lib/systemd/system/pihome_amazon_echo.service (should have read all the thread before proceeding but i guess i was very excited) but after sudo apt-get install python-pip and removing extra entries i can start service but amazon echo cannot find any device.
But running from second ssh session script is responding.
echo -e "M-SEARCH\r\nurn:Belkin:device:**" | nc.traditional -u 239.255.255.250 1900

i will investigate this further may be its my router, pihome id doing what is meant to do,

@dvdcut
Copy link
Contributor

dvdcut commented Mar 24, 2020

@twa127 any specific device i have to add?
on Amazon Alexa app tap on top right ->Add Device->Other->Discover Devices
is this right ?

@twa127
Copy link
Contributor

twa127 commented Mar 24, 2020 via email

@dvdcut
Copy link
Contributor

dvdcut commented Mar 24, 2020

i thought it is my broadband router, i tried different router but no progress, @pihome-shc what port scanner you are using?

@dvdcut
Copy link
Contributor

dvdcut commented Apr 2, 2020

@twa127 thank you for asking, i m fine,

@pihome-shc
Copy link
Owner Author

@dvdcut, welcome back

@pihome-shc
Copy link
Owner Author

@twa127
after updating #212,

root@pihome:/var/www/add_on# cd amazon_echo/
root@pihome:/var/www/add_on/amazon_echo# ls
debounce_handler.py  echo_pihome.py  fauxmo.py  install_echo.sh  README.md
root@pihome:/var/www/add_on/amazon_echo# bash install_echo.sh
install_echo.sh: line 2: $'\r': command not found
Checking if python-requests is Installed
install_echo.sh: line 49: warning: here-document at line 30 delimited by end-of-file (wanted `EOT')
install_echo.sh: line 50: syntax error: unexpected end of file
root@pihome:/var/www/add_on/amazon_echo# bash install_echo.sh
install_echo.sh: line 2: $'\r': command not found
Checking if python-requests is Installed
install_echo.sh: line 49: warning: here-document at line 30 delimited by end-of-file (wanted `EOT')
install_echo.sh: line 50: syntax error: unexpected end of file
root@pihome:/var/www/add_on/amazon_echo#

@twa127
Copy link
Contributor

twa127 commented Apr 19, 2020

spelling mistake at line 14 should read sudo apt-get install python-pip

never got picked-up before because pip was already installed, I'll commit change

@pihome-shc pihome-shc mentioned this issue Apr 19, 2020
@pihome-shc
Copy link
Owner Author

@twa127 after still had issues with install_echo.sh, but after changing from Windows (CR LF) to Unix (LF) it worked, fine,

@twa127
Copy link
Contributor

twa127 commented Apr 19, 2020

ah edited it notepad, I'll commit the copy from the Pi

@pihome-shc
Copy link
Owner Author

i have added instructions on PiHome website.

http://www.pihome.eu/2020/04/25/pihome-with-amazon-echo-voice-control/

is there anything else needs to be done with this?

@twa127
Copy link
Contributor

twa127 commented Apr 25, 2020

Looks good to me, mine been running okay for a couple of weeks now. If we are moving to Python 3 I will look at moving it up as there are newer versions of fauxmo for Python 3

@dvdcut
Copy link
Contributor

dvdcut commented Apr 28, 2020

do we want to add google in this mix now without external dependencies as @scottagecheeseandcrackers did this write-up on Link pihome google voice setup
😂 (i can never get those emojis working in github)

@pihome-shc
Copy link
Owner Author

@dvdcut is there any library available to support this? i dont have google home only one android phone

@scottagecheeseandcrackers
Copy link

scottagecheeseandcrackers commented May 12, 2020

i was thinking if we switch to mqqt would that help to integrate voice commands ? or it does nt matter ?

@dvdcut - I was unaware of homebridge so I've been running a mqtt setup for a while now via openhab. My wife did not seem happy with voice control and oddly refuses to use the pihome site. I mounted a spare android phone to the wall, with a simply mqtt display to act as a physical boost button 😅

20200512_231518

@scottagecheeseandcrackers

@dvdcut is there any library available to support this? i dont have google home only one android phone

Just reading this - https://github.com/oznu/homebridge-gsh

  • looks like a promising way to integrate homebridge and google assistant. Downside it doesn't support temp sensors yet...only thermostats. I'm excited to try the new homebridge implementations for pihome...Through openhab I managed to get the thermostat feature in google home to work...but simply as a means to convey the current zone temperature.

Screenshot_20200512-232110_Home

@pihome-shc
Copy link
Owner Author

@scottagecheeseandcrackers that looks very good gui, one of my PiHome customer said the same thing about his wife (refuse to use web interface on mobile) he needs something similar i think

@scottagecheeseandcrackers
Copy link

scottagecheeseandcrackers commented May 13, 2020

@pihome-shc - unfortuantely unlike you guys I haven't a clue how to code. Instead I chose to use openhab - to set a simple gui. If it's any help here is the link that I followed to set it the gui...

https://www.openhab.org/docs/configuration/habpanel.html

@pihome-shc
Copy link
Owner Author

@twa127
after last update, i and running install script.

root@pihome:/var/www/add_on/amazon_echo# bash ./install_echo.sh
Check if pip3 is Installed
pip3 already installed
Installing Fauxmo
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting fauxmo
  Downloading https://files.pythonhosted.org/packages/9b/45/1d79cdecba19695e33cc0e4f14f4f1248bf0b8b317e9ffa36b48d0ced                                     594/fauxmo-0.5.0-py3-none-any.whl
Installing collected packages: fauxmo
Successfully installed fauxmo-0.5.0
Changing Privileges for Fauxmo
chown: invalid user: ‘fauxmo:fauxmo’
Backing Up and Updateing /etc/fauxmo/config.json
Adding Accessories for Each Zone
cp: cannot stat '/etc/fauxmo/config.json': No such file or directory
Traceback (most recent call last):
  File "config_json.py", line 51, in <module>
    with open(src, "w") as write_file:
IOError: [Errno 2] No such file or directory: '/etc/fauxmo/config.json'
Adding Unprivileged Fauxmo User
Checking For Existing Unit File
Creating Unit File: /lib/systemd/system/pihome_amazon_echo.service
Enabling the service
Starting the service
root@pihome:/var/www/add_on/amazon_echo#

/etc/fauxmo/ dont have any jason file.

@twa127
Copy link
Contributor

twa127 commented May 15, 2020

Sorry my error, I've committed an update, if you want to try it I've attached

install_echo.zip

@pihome-shc
Copy link
Owner Author

@twa127 after running install script, it can discover devices and start the boost, but one very odd message, i tried hot water and if hot water is over the boost set temperature it reads this device isnt responding.

@twa127
Copy link
Contributor

twa127 commented May 15, 2020

Did you update your copy of boostSet.php

@pihome-shc
Copy link
Owner Author

Yes, from github, i will give it another try for sake of troubleshooting

@twa127
Copy link
Contributor

twa127 commented May 15, 2020

okay, its a bit strange as should be no different from last version, uses the same api just small change in the return data and the api simply uses boost_view

now gives {"success":true,"state":false,"state_str":"off"} old version gave {"success":true,"state":false}

@twa127
Copy link
Contributor

twa127 commented May 15, 2020

just tried lowering the boost temp to be below actual temp and it all worked okay

@pihome-shc
Copy link
Owner Author

my bad, i had old devices in Alexa app, and i think echo was getting confused. after removing all devices and discovery all working as expected.

@twa127
Copy link
Contributor

twa127 commented May 15, 2020

ah! good news ;-)

pihome-shc pushed a commit that referenced this issue Aug 26, 2020
Merge pull request #378 from twa127/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants