pihome-shc / pihome

PiHome - Smart Heating, Ventilation and Air Conditioning (HVAC)
http://www.pihome.eu
Other
55 stars 25 forks source link

Voice Command #172

Open pihome-shc opened 4 years ago

pihome-shc commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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

twa127 commented 4 years ago

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

pihome-shc commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

running in DEBUG mode

image

pihome-shc commented 4 years ago

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 commented 4 years ago

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

twa127 commented 4 years ago

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

pihome-shc commented 4 years ago

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 commented 4 years ago

strange

twa127 commented 4 years ago

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

pihome-shc commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 notifications@github.com 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 commented 4 years ago

How about trying pi connect to WiFi

Sent from my iPhone

On 24 Mar 2020, at 00:26, PiHomeHVAC notifications@github.com 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.

dvdcut commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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 notifications@github.com 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.

dvdcut commented 4 years ago

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

twa127 commented 4 years ago

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

dvdcut commented 4 years ago

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

twa127 commented 4 years ago

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

dvdcut commented 4 years ago

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 commented 4 years ago

i think i m going to do fresh install right from beginning including os and i will report back once i m done. @twa127 and @pihome-shc what model of echo you both have?

twa127 commented 4 years ago

I have one of the original Echo, had it for over 2 years. I wonder if the problem is with the router as the connection is UPnP which my either not be available with your router or may be disabled by default

pihome-shc commented 4 years ago

@dvdcut / @twa127 i have Echo Dot 3rd Gen, i m using Net Analyzer App on my Android phone.

pihome-shc commented 4 years ago

My home router does have UPnP enabled. image

dvdcut commented 4 years ago

after spending hours my final conclusion :( i tried fresh install (including fresh os install) then i removed all boost options, delete all zones and left one zone with one boost option just to be sure.

i think problem with echo 3rd generation, below link does not directly linked to pihome, i think something changed in 3rd gen and code need upgrade to work with 3rd gen echo.

https://bitbucket.org/xoseperez/fauxmoesp/issues/66/fauxmo-with-echo-dot-3 https://github.com/n8henrie/fauxmo/issues/38

feeling exhausted and sad, @twa127 i can buy you echo 3rd generation as gift

twa127 commented 4 years ago

he he I have always liked old technology, I wonder if I build an Rpi Echo emulator if it will work like the latest version, then I can investigate, otherwise I could always buy a dot

twa127 commented 4 years ago

obviously amazon developers have never heard of backward compatibility :-(

twa127 commented 4 years ago

Hi can you please try -

sudo systemctl stop pihome_amazon_echo.service sudo python /var/www/amazon_echo/echo_pihome.py

once it gets to the polling loop try device discovery and let me know the output

pihome-shc commented 4 years ago

@twa127 i same results with sudo, all these big companies dont care about customers anymore, some throttling mobile phones that you paid fully some adding some sneaky updates to brick older models.

root@pihome:/var/www/amazon_echo# sudo python /var/www/amazon_echo/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

@dvdcut can you try to test this on your build

twa127 commented 4 years ago

True, so after you try Discover Devices on the Alexa App nothing nothing else appears after 192.168.99.2:52000 DEBUG:root:Entering fauxmo polling loop

twa127 commented 4 years ago

I get

DEBUG:root:Responding to search for Hot Water DEBUG:root:Responding to search for Ground Floor DEBUG:root:Responding to search for Hot Water DEBUG:root:Responding to search for Ground Floor DEBUG:root:Responding to setup.xml for Hot Water DEBUG:root:Responding to setup.xml for Ground Floor DEBUG:root:Responding to setup.xml for Hot Water DEBUG:root:Responding to setup.xml for Ground Floor

twa127 commented 4 years ago

If you get change can you try replacing fauxmo.py with the attached and see if that helps

fauxmo.zip

pihome-shc commented 4 years ago

@twa127, same result after replace fauxmo.py file, and nothing after DEBUG:root:Entering fauxmo polling loop

`root@pihome:~# sudo python /var/www/amazon_echo/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

`

twa127 commented 4 years ago

Thanks for trying, I think more 😬

Sent from my iPhone

On 25 Mar 2020, at 22:43, PiHomeHVAC notifications@github.com wrote:

 @twa127, same result after replace fauxmo.py file, and nothing after DEBUG:root:Entering fauxmo polling loop

`root@pihome:~# sudo python /var/www/amazon_echo/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

`

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

dvdcut commented 4 years ago

@twa127 same here :(

twa127 commented 4 years ago

dvdcut

Can you please try running wireshark with a capture filter of ip host xxx.xxx.xxx.xxxx and ip host yyy.yyy.yyy.yyyy using the ip addresses of the Echo and the RPI and post a dump of the result after running device recovery

pihome-shc commented 4 years ago

@twa127 here is wireshark capture for echo (192.168.99.15) and rpi (192.168.99.2) and laptop (192.168.99.7) i had ssh session open thats why you can see that as well. wireshartk_echo.zip

dvdcut commented 4 years ago

@pihome-shc / @twa127 i never used wire shark don't know what i suppose to do with it, i'll watch some youtube to educate myself and come back to you.

twa127 commented 4 years ago

Hi,

Can you give this a try please

fauxmo.zip

twa127 commented 4 years ago

Yep, I'd never used it before either