User avatar
sapnho
Posts: 208
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Alexa Routine to publish MQTT to be picked up by RPi

Sat Jul 13, 2019 1:25 pm

I have set up a script with an RPi that listens in on MQTT topics and executes a code if a specific message comes up. I am doing this using Home Assistant and the Nabu Casa interface. (https://www.thedigitalpictureframe.com/ ... assistant/)

Now, I was wondering if there isn't a way to publish an MQTT message without having to go through Home Assistant first. Alexa has these wonderful routines which allows you to specify a phrase which launches a particular action. However, it is always connected to a device, group or scene which come through a smart home device or in my case Home Assistant.

Would anybody know if there is a way to have Alexa publish a simple MQTT message that is then picked up by the Raspberry Pi.
www.TheDigitalPictureFrame.com
Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.

Andyroo
Posts: 4146
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Alexa Routine to publish MQTT to be picked up by RPi

Sat Jul 13, 2019 1:41 pm

Never tried this https://github.com/mhdawson/AlexaMqttBridge

For Python (not 3 :cry: ) you could look at https://github.com/toddmedema/echo/blob ... le-mqtt.py to see how it hangs together. The main hook is via https://github.com/makermusings/fauxmo and this is available fir the Pi and 8266 Wemos chips.

I must really get this out of the project pile one day :lol:
Need Pi spray - these things are breeding in my house...

PhatFil
Posts: 1342
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Alexa Routine to publish MQTT to be picked up by RPi

Sat Jul 13, 2019 2:54 pm

For issuing basic 'Device_Name ON/OFF' type commands to stimulate Pi activity by Alexa/voice, I use Node-Red with the Alexa-local node.

branching off a mqtt-publish node to publish any message would be a fairly trivial addition to any flow.

a little creative thinking will let you create a set of alexa local nodes to suit almost any task,

User avatar
sapnho
Posts: 208
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Alexa Routine to publish MQTT to be picked up by RPi

Sat Jul 13, 2019 3:41 pm

Excellent, thanks, guys. I think Node Red is the path to try then!
www.TheDigitalPictureFrame.com
Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.

Andyroo
Posts: 4146
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Alexa Routine to publish MQTT to be picked up by RPi

Sat Jul 13, 2019 6:32 pm

Totally forgot Node-Red :oops: :lol: :oops:

Have a look at https://tech.scargill.net/the-script/ - I think it is only for Stretch though as I've not seen any news on the Blog for Buster.

Also the 'man with the Swiss accent' (Andreas Spiess) on YouTube has a few very good videos on MQTT - he used this install in this video but its worth spending a few days just binge watching him :lol:
Need Pi spray - these things are breeding in my house...

User avatar
sapnho
Posts: 208
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Alexa Routine to publish MQTT to be picked up by RPi

Sat Jul 13, 2019 9:46 pm

Great, thanks!
www.TheDigitalPictureFrame.com
Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.

User avatar
sapnho
Posts: 208
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Alexa Routine to publish MQTT to be picked up by RPi

Mon Jul 15, 2019 2:46 pm

So, I had a closer look at the Alexa local node and the Alexa Skills. They are easy to install but what I would like to avoid is to always add something like "Turn on/off" or "Set" to my commands.

My commands should be more natural like "Good morning" activating a script. With the Home Assistant Nabu Casa service, this is very easy to do but the local node solution emulates a Hue device and the seems to require that.

Is there any (simple) solution which would just accept normal text to trigger scripts and not devices?
www.TheDigitalPictureFrame.com
Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.

User avatar
sapnho
Posts: 208
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Alexa Routine to publish MQTT to be picked up by RPi

Sat Jul 20, 2019 8:06 am

Thanks again for the Node-RED lead! I got everything working and have summarized the steps here: https://www.thedigitalpictureframe.com/ ... -node-red/

Node-RED is amazing! 8-)
www.TheDigitalPictureFrame.com
Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.

mattmiller
Posts: 2099
Joined: Thu Feb 05, 2015 11:25 pm

Re: Alexa Routine to publish MQTT to be picked up by RPi

Sat Jul 20, 2019 9:33 am

JFI
Unfortunately, node-red-alexa-local doesn't work with recent Alexa devices :(

The node says it is coming but hasn't been updated for 11 months so may be a legacy project

I'm using

node-red-contrib-alexa-home-skill

Its a bit more involved to setup but has proved quite reliable

User avatar
sapnho
Posts: 208
Joined: Sun Sep 14, 2014 3:49 pm
Location: Frankfurt am Main
Contact: Website

Re: Alexa Routine to publish MQTT to be picked up by RPi

Sat Jul 20, 2019 9:47 am

Ah yes, you must have one older Alexa Gen (2) in your network for devices to be discovered. Once that has happened, it works fine with all Echos.
www.TheDigitalPictureFrame.com
Build a really great digital picture frame with the Raspberry Pi.
With lots of great tips from this forum.

Return to “Automation, sensing and robotics”