<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Iot on Roland Huß</title><link>https://ro14nd.de/tags/iot/</link><description>Recent content in Iot on Roland Huß</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2026 Roland Huß</copyright><lastBuildDate>Mon, 12 Mar 2018 00:00:00 +0000</lastBuildDate><atom:link href="https://ro14nd.de/tags/iot/index.xml" rel="self" type="application/rss+xml"/><item><title>Dash2Alexa - Amazon Alexa Audio API Access</title><link>https://ro14nd.de/dash-2-alexa/</link><pubDate>Mon, 12 Mar 2018 00:00:00 +0000</pubDate><guid>https://ro14nd.de/dash-2-alexa/</guid><description>&lt;p&gt;Since I got my first Amazon Echo end of last year, I love it.
And although, as a typical German, I&amp;rsquo;m still a bit concerned about data privacy, at the end, convenience wins (as always :).
There are many things which work flawlessly, and to be honest, the most used feature for me is a simple timer.
But when it comes to aggregate actions, Alexa is still quite limited.
Ok, you can define your routines, but for only an insufficient set of fixed actions.
What I really would love to have is to start the radio when I get up in the morning, but this is not possible at the moment.&lt;/p&gt;
&lt;p&gt;So I remembered my last years Amazon Dash button hacks and thought it would be cool to combine both, the Dash button and Alexa.&lt;/p&gt;
&lt;p&gt;And here it is, my weekend hack &amp;hellip;..&lt;/p&gt;
&lt;iframe src="https://player.vimeo.com/video/259570045?byline=0&amp;portrait=0" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen&gt;&lt;/iframe&gt;
&lt;p&gt;In a nutshell, the setup looks like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Configure your router to not forward packets from your Dash Button.&lt;/li&gt;
&lt;li&gt;Spoof on ARP requests for the Dash button&amp;rsquo;s MAC.&lt;/li&gt;
&lt;li&gt;If found, call out to a text-to-speech service to convert configured Alexa commands to audio.&lt;/li&gt;
&lt;li&gt;Play the received audio output via RaspberryPi attached speakers.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That&amp;rsquo;s it.
You can use this &lt;a href="https://github.com/rhuss/dash2alexa" target="_blank" rel="noreferrer"&gt;sample code&lt;/a&gt; for doing the dirty work, but maybe you are interested in some more details.&lt;/p&gt;

&lt;h2 class="relative group"&gt;Amazon Dash Button
 &lt;div id="amazon-dash-button" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#amazon-dash-button" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Amazon_Dash" target="_blank" rel="noreferrer"&gt;Amazon Dash Button&lt;/a&gt; is part of Amazon&amp;rsquo;s consumer goods ordering service.
This button contains a Wifi sender and is quite inexpensive.
Each button is specific for a brand for which you can connect to a specific good.
When you press the button, this good is ordered (e.f. 24 cans of beer ;-)&lt;/p&gt;
&lt;p&gt;But this intended use case is not the only way how you can use this button.
In fact, it can be used just as a plain Wifi button for any purpose.&lt;/p&gt;
&lt;p&gt;First of all, you have to buy such a button e.g. 5 Euro here in Germany, but you can spend this five bucks for your first order.
You just configure it as described by Amazon and maybe order something to spend your credits.&lt;/p&gt;
&lt;p&gt;After this, you have to block the button in your home Wifi router for calling out to the internet.
For obvious reasons, this is &lt;strong&gt;very important&lt;/strong&gt; ;-)
When the button is blocked, it will flash red eventually when being pressed (in contrast to flashing green when an order is placed).&lt;/p&gt;
&lt;p&gt;When you press the button, it first asks via DHCP for an IP address.
The MAC address of the button is relevant, so its time to pick that up, e.g.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;By looking into your DHCP servers log&lt;/li&gt;
&lt;li&gt;By trying &lt;code&gt;arp -a&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;By checking your Wifi Router&amp;rsquo;s admin UI&lt;/li&gt;
&lt;li&gt;Via Wireshark spoofing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This Mac address will be watched for later by spoofing ARP package traffic.
When &lt;a href="https://golang.org" target="_blank" rel="noreferrer"&gt;golang&lt;/a&gt; is your preferred programming language, then you can use directly &lt;a href="https://github.com/rhuss/dash" target="_blank" rel="noreferrer"&gt;rhuss/dash&lt;/a&gt; which is based on top of &lt;a href="https://github.com/google/gopacket" target="_blank" rel="noreferrer"&gt;gopacket&lt;/a&gt; to watch for certain ARP packages and trigger an action when received.&lt;/p&gt;

&lt;h2 class="relative group"&gt;Amazon Polly API access
 &lt;div id="amazon-polly-api-access" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#amazon-polly-api-access" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;In our use case, when we detect that a button is pressed, then we want to send out some fixed, text-based audio.
For converting text coming from a configuration, a text-to-speech service is used.&lt;/p&gt;
&lt;p&gt;There are several such services available.
For our purpose, we are using &lt;a href="https://aws.amazon.com/polly/developers/?nc1=h_ls" target="_blank" rel="noreferrer"&gt;Amazon Polly&lt;/a&gt;, which offers a free tier for the first 12 months (including 5 million characters per month, fair enough for a handful of buttons ;-) and then 4 $ per one million of chars.&lt;/p&gt;
&lt;p&gt;A short cost calculation beyond the free tier: 100 characters for Alexa commands per button press (which is already quite a mouthful) costs ~ 0.4 cents.
Or the other way round, for five bucks you can press the button 1.250 times: Three times a day per yeare for 5 $
Well, for me that&amp;rsquo;s worth the fun ;-)&lt;/p&gt;
&lt;p&gt;You need an &lt;a href="https://portal.aws.amazon.com/billing/signup" target="_blank" rel="noreferrer"&gt;AWS account&lt;/a&gt; to access the speech API.
The access and secret token can be either that of your &lt;a href="https://console.aws.amazon.com/iam/home#/security_credential" target="_blank" rel="noreferrer"&gt;root AWS account&lt;/a&gt;, or you probably should create a dedicated &lt;a href="https://console.aws.amazon.com/iam/home#/users" target="_blank" rel="noreferrer"&gt;IAM User&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Of course, you can also use different text-to-speech tool.
Maybe even the good old Unix &lt;code&gt;speak&lt;/code&gt; will do it ?
Not tried it yet, but will check that for sure very soonish.
For now, the Polly voices are recognised quite well by my echo so that I won&amp;rsquo;t change it right now.&lt;/p&gt;

&lt;h2 class="relative group"&gt;Raspberry Pi Audio
 &lt;div id="raspberry-pi-audio" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#raspberry-pi-audio" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;The final jigsaw piece is the hardware on which to run the watcher.
For my use case, a Raspberry Pi 2 with some &lt;a href="https://www.amazon.de/gp/product/B00JRW0M32/" target="_blank" rel="noreferrer"&gt;inexpensive speakers&lt;/a&gt; was totally good enough.&lt;/p&gt;

&lt;h2 class="relative group"&gt;dash2alexa command
 &lt;div id="dash2alexa-command" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#dash2alexa-command" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;The &lt;a href="https://github.com/rhuss/dash2alexa" target="_blank" rel="noreferrer"&gt;dash2alexa&lt;/a&gt; command actually takes a configuration file (defautl: &lt;code&gt;~/.dash2alexa.yml&lt;/code&gt;)&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Sample configuration file for dash2alexa&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Adapt and copy it to ~/.dash2alexa.yml&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Access and secret for accessing the services&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;access&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;..........&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;secret&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;..........&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Network interface to listen for ARP requests when a Dash button is pressed&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;interface&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;wlan0&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Language (&amp;#34;de&amp;#34; or &amp;#34;en&amp;#34;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;language&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;de&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Gender which can be either &amp;#34;male&amp;#34; or &amp;#34;female&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;gender&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;male&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Keyword to use for alexa&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;keyword&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Alexa&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Player to use when playing an mp3 sound file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;player&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;mpeg123&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# List of Dash Buttons with associated Alexa command&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;buttons&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Symbolic name&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;- &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;heineken&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Mac adress of Dash button&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;mac&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;ac:63:be:00:11:22&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# How many seconds to wait between Alexa commands&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;wait&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;4&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Messages to talk&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;messages&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;Lautstärke 4&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;Spiele Bayern 3&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;There&amp;rsquo;s not much documentation yet, but some will follow soon.
Feel free to adapt the code, and I&amp;rsquo;m happy to integrate any pull requests.
Also, as I&amp;rsquo;m a bloody golang greenhorn still, would be curious whether things could be done better.&lt;/p&gt;

&lt;h2 class="relative group"&gt;tl;dr
 &lt;div id="tldr" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#tldr" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;This little hack uses Amazon Echo via its &amp;lsquo;Audio API&amp;rsquo; to perform specific action on a button press.
It&amp;rsquo;s entirely suited for a situation when its calm around, like putting the button right beside the bed for getting started even when your Echo is out of sight.&lt;/p&gt;
&lt;p&gt;And finally, it&amp;rsquo;s just pure fun ;-) Enjoy!&lt;/p&gt;
&lt;p&gt;P.S. Let me know in the comments whether you tried it out, too and how it works for you.&lt;/p&gt;</description></item></channel></rss>