pihome icon indicating copy to clipboard operation
pihome copied to clipboard

Voice Command

Open pihome-shc opened this issue 4 years ago • 127 comments

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?

pihome-shc avatar Mar 15 '20 12:03 pihome-shc

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

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

pihome-shc avatar Mar 15 '20 15:03 pihome-shc

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

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'

twa127 avatar Mar 23 '20 12:03 twa127

@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

dvdcut avatar Mar 23 '20 13:03 dvdcut

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

twa127 avatar Mar 23 '20 13:03 twa127

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

twa127 avatar Mar 23 '20 13:03 twa127

@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?

pihome-shc avatar Mar 23 '20 17:03 pihome-shc

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

twa127 avatar Mar 23 '20 18:03 twa127

@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?

pihome-shc avatar Mar 23 '20 19:03 pihome-shc

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 avatar Mar 23 '20 20:03 twa127

running in DEBUG mode

image

twa127 avatar Mar 23 '20 21:03 twa127

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 avatar Mar 23 '20 21:03 pihome-shc

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

pihome-shc avatar Mar 23 '20 21:03 pihome-shc

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

twa127 avatar Mar 23 '20 21:03 twa127

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. :(

pihome-shc avatar Mar 23 '20 22:03 pihome-shc

strange

twa127 avatar Mar 23 '20 22:03 twa127

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

twa127 avatar Mar 23 '20 22:03 twa127

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 avatar Mar 23 '20 23:03 pihome-shc

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

pihome-shc avatar Mar 24 '20 00:03 pihome-shc

Hi what port scanner are you using and I’ll post a screenshot of what mine looks like

Sent from my iPhone

On 24 Mar 2020, at 00:26, PiHomeHVAC [email protected] wrote:

 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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

twa127 avatar Mar 24 '20 08:03 twa127

How about trying pi connect to WiFi

Sent from my iPhone

On 24 Mar 2020, at 00:26, PiHomeHVAC [email protected] wrote:

 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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

twa127 avatar Mar 24 '20 08:03 twa127

@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 avatar Mar 24 '20 10:03 dvdcut

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

dvdcut avatar Mar 24 '20 11:03 dvdcut

I just said ‘find my devices’ but tried deleting and then using the app as you described and that worked okay as well

Sent from my iPhone

On 24 Mar 2020, at 11:39, dvdcut [email protected] wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

twa127 avatar Mar 24 '20 12:03 twa127

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

dvdcut avatar Mar 24 '20 12:03 dvdcut

what exactly is your network setup ie Rpi on Ethernet with no WiFi and Echo on Wifi ?

twa127 avatar Mar 24 '20 13:03 twa127

i have rpi on wifi connected to this different router, and echo to over wifi, i will try pi on Ethernet now.

dvdcut avatar Mar 24 '20 13:03 dvdcut

just tried my test system Rpi connected via Ethernet with WiFi down, Echo Wifi both on the same router, works fine. The same if Rpi Ethernet down and connected via Wifi

twa127 avatar Mar 24 '20 13:03 twa127

here is output of my service status, now, rpi is on ethernet and echo on same network. i think only common thing between my setup is @pihome-shc is i m using his img file for my rpi.

root@pihome:~# sudo systemctl status pihome_amazon_echo.service
● pihome_amazon_echo.service - Echo
   Loaded: loaded (/lib/systemd/system/pihome_amazon_echo.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2020-03-24 13:37:31 GMT; 1min 53s ago
 Main PID: 625 (python)
    Tasks: 1 (limit: 2319)
   Memory: 16.4M
   CGroup: /system.slice/pihome_amazon_echo.service
           └─625 /usr/bin/python /var/www/amazon_echo/echo_pihome.py

Mar 24 13:37:31 pihome systemd[1]: Started Echo.
Mar 24 13:37:34 pihome python[625]: DEBUG:root:Listening for UPnP broadcasts
Mar 24 13:37:34 pihome python[625]: DEBUG:root:got local address of 10.0.0.11
Mar 24 13:37:34 pihome python[625]: DEBUG:root:UPnP broadcast listener: new device registered
Mar 24 13:37:34 pihome python[625]: DEBUG:root:FauxMo device 'First Floor' ready on 10.0.0.11:52001
Mar 24 13:37:34 pihome python[625]: DEBUG:root:UPnP broadcast listener: new device registered
Mar 24 13:37:34 pihome python[625]: DEBUG:root:FauxMo device 'Hot Water' ready on 10.0.0.11:52002
Mar 24 13:37:34 pihome python[625]: DEBUG:root:UPnP broadcast listener: new device registered
Mar 24 13:37:34 pihome python[625]: DEBUG:root:FauxMo device 'Ground Floor' ready on 10.0.0.11:52000
Mar 24 13:37:34 pihome python[625]: DEBUG:root:Entering fauxmo polling loop

dvdcut avatar Mar 24 '20 13:03 dvdcut