ioBroker Alexa integration

With the help of the ioBroker Alexa2 adapter, we have the possibility that ioBroker can control certain functions of Alexa. For example, we can take advantage of Alexa’s ability to speak to publish announcements and warnings through the Amazon Echo and Echo Dot Smart speakers.

To use the ioBroker Alexa2 adapter, we need an ioBroker cloud service account, which can be connected to Alexa using the ioBroker.iot skill of the Amazon Alexa app.

The Alexa2 adapter can be used with one of the online services “IoT Assistant” or “ioBroker Pro”. If not already, we need to install a copy of the ioBroker at ” IoT” cloud adapter on our local server in order to connect to the online services.

Alexa2 adapter installation

To install the Alexa2 adapter, go to the Adapters page and enter the search term Alexa in the search box. Let’s install an instance of the Alexa2 adapter.

Let's install an instance of the Alexa2 adapter

After installation, you will be taken to the adapter settings page. To connect to Alexa devices, we need to connect the ioBroker Alexa2 adapter to our Amazon account. Click on the link for this.

Click on the link to connect your amazon account with the iobroker alexa2 adapter

On the page that opens, log in with your Amazon login data, if you have successfully logged in, close the page. Your Alexa2 adapter settings should now look like this.

Your Alexa2 adapter settings should now look like this.

Save and close the settings page by clicking the save and close button. This completes the installation of the Alexa2 adapter.

Let’s test the operation of the Alexa2 adapter. Go to the Scripts panel, add a new javascript file. (If it is not already installed, install a copy of the Javascript adapter .)

Go to the Scripts panel, add a new javascript file

Copy the code snippet below into the empty javascript file.

var alexa = 'alexa2.0.Echo-Devices.xxxxxxxxx.Commands.speak'/*speak*/;
var text = 'test message';

setState(alexa, text);

We replace the value of the “var alexa” variable with the Commands/speak object of one of the devices in the Echo-Devices subfolder of the Alexa2 adapter. The setState() function is used to transfer the contents of the “text” variable to the given object.

replace it with the Commands/speak object of one of the devices in the Echo-Devices subfolder of the Alexa2 adapter

Save the file, press the small triangle button to start the script, then listen to Alexa.

Alexa test javascript example in iobroker

For example, we can also control Alexa with push buttons using the VIS adapter .

Beelink SER5 Mini PC

ad

Beelink SER5 Mini PC

AMD Ryzen 7 5800H Processor,Mini Computer with 16G DDR4 RAM/500GB M.2 NVMe 2280 SSD,4K FPS/Three-Screen Display/WiFi 6/BT5.2/Support Auto Power On.

Ideal for Smart Home, Mosquitto, ioBrokers or media servers.

Alexa2 adapter objects

After installation, the Alexa2 adapter data points are created on the Objects tab.

The data points of the Alexa2 adapter are created on the Objects tab.

Let’s take a look at Alexa2’s data points. The first level of the directory tree can be seen in the following table.

Echo-DevicesThis folder contains the Amazon Echo devices.
HistoryThe last commands and events can be found in the History folder.
Smart-Home-DevicesIncludes all Smart-home devices that Alexa knows about.
infoHere you will find general information about the status of the adapter. E.g. Is the adapter connected to Alexa, but here we also find Alexa cookies.
requestResultWe can find information about possible errors in the requests of TuneIn and Smart-home devices.

In the following, we will examine the most important data points of the ” Echo-Devices ” folder, without claiming to be complete.

In the ” Commands ” subfolder we find the ” announcement ” object. With this, we can publish an announcement on the given Amazon Echo device with Alexa. This command is similar to the ” speak ” command given in the above example, Alexa reads the String specified as a parameter in the text variable. The difference is that a warning tone can be heard before the ” announcement ” command is executed.


var alexa = 'alexa2.0.Echo-Devices.xxxx.Commands.announcement'/*announcement*/;
var text = 'test message';

setState(alexa, text);

The ” calendarNext ” object expects a boolean value as a parameter. If activated, Alexa will read the next event in our calendar.

var alexa = 'alexa2.0.Echo-Devices.xxxx.Commands.calendarNext'/*calendarNext*/;
var trigger = true;

setState(alexa, trigger);

The ” Today calendar ” object reads today’s calendar events, and ” calendarTomorrow ” reads tomorrow’s calendar events with Alexa, according to the code snippet above.

” doNotDisturb ” is also a boolean value, it activates the do not disturb function.

When ” flashbriefing ” is activated, it reads news, local weather and more with Alexa. You can set the news providers in the Amazon Alexa application Settings/News/MyNewsChannel  or Settings/News/Flash Briefing .

The ” speak ” data point has already been presented above. The ” speak-volume ” object can be used to adjust Alexa’s volume. We can give a number as a parameter, from 1-100.

var alexa_speak = 'alexa2.0.Echo-Devices.xxxx.Commands.speak'/*speak*/;
var alexa_volume = 'alexa2.0.Echo-Devices.xxxx.Commands.speak-volume'/*Volume to use for speak commands*/
var num = 80;
var text = 'test message';

setState(alexa_volume, num);
setState(alexa_speak, text);

With the help of the ” textCommand ” object, we can send a text command to Alexa. Its parameter is String. We avoid using numbers in the text (we can write two instead of 2).

var alexa = 'alexa2.0.Echo-Devices.xxxx.Commands.textCommand'/*textCommand*/;
var command = 'Turn on the living room light!';

setState(alexa, command);

The ” traffic ” object reads the local traffic news, while the ” weather ” reads the weather with Alexa. Both data points expect a boolean value.

In the ” Routines ” folder we find the routines created in the Amazon Alexa application. We can activate the objects by setting them to true.

That’s it for the ioBroker Alexa2 adapter. More information can be found on the adapter’s github page.