How to make a custom universial smart home enddevice with Raspi/Arduino/…?

Hello everyone,

i’m quite new to this field and totally new to this forum, but i would like to start making my own smart home devices to achieve a higher level of connectivity and comfort for my home. In particular I’m thinking of animated LED strips, a smart garage opener or sensors (e.g. weather station, motion sensor, door/window sensor), but that’s not why I’m here, as there are plenty of tutorials on the www for that.

My goal is to realize smart home devices with a Raspberry Pi, Arduino, ESP8266 or similar. These should be compatible with Alexa at least, but it would be nice to support other platforms like Philips Hue and maybe Google Home, Apple HomeKit, … It is also important to me that the devices can not only be operated by voice control, but also in the Alexa app (and at best Philips-Hue-App, Google, Apple, …), so that I can add the devices to my rooms and zones and to also control them via sliders and color pickers (which I find more user-friendly than voice control). It would also be great if I could use a single microcontroller to control several devices at the same time (devices that are placed close together). But it should be possible to register each device connected to the microcontroller separately in the smart home network as a kind of virtual device. As programming language I would prefer Python, but that is not a must-have.

For this reason, an Alexa skill would be out of question, since it only supports voice commands (as far as I know) and the devices do not appear in the Alexa app. Please correct me if I’m wrong.
The best option I can think of right now would be to implement the microcontroller as a ZigBee enddevice. In my understanding, the device would then be compatible with most manufacturers and platforms, so I can simply connect the device to my (already existing) Philips-Hue-Bridge. This would automatically make it available for Alexa, since the Hue-Bridge is connected to Alexa. And I can even control the devices via Alexa- and Philips-Hue-app.

My problem is firtly, that I don’t know if all my assumptions are correct? And secondly, that all tutorials about implementing ZigBee on microcontrollers I found so far, aim at building a ZigBee router/controller. Instead, I only want to implement a device that I can connect to the Hue-Bridge as easily as my other smart (non-Philips) devices (that I bought and didn’t make myself).

Hopefully, some of you have an idea, which would be the best way to realize my goals. You are welcome to comment any ideas you have, even if they are completely different from my approach.

Thanks in advance :slight_smile:

When using the openHAB Alexa skill, the devices also show up in the Alexa app and can be controlled through it.

When using the openHAB Alexa skill, the devices also show up in the Alexa app and can be controlled through it.

Oh, really? I thought you could only set up voice commands in there. Thanks for the hint, I will have a look at it.

It might be worth taking a step back for a second a consider what the purpose of openHAB is.

The “HAB” part of the name stands for “Home Automation Bus”. What that implies is that openHAB creates a messaging bus that can be used to integrate different technologies.

So what openHAB does is:

  • integrate with lots of different technologies (bindings, 300+ at last count)
  • expose the data and actuators in a normalized way (Things, Channels, and Items)
  • let you define behaviors based on events (Rules)
  • save time series data (Persistence)
  • build a user interface for your custom home automation (Sitemaps, HABPanel)

openHAB provides all of these services. So, for example, you can wire up some sensors and relays to an ESP8266, flash Tasmota or ESPEasy onto the microcontroler, configure it to use MQTT. Then you configure openHAB to use MQTT and subscribe/publish to the device.

From this point your DIY device is completely integrated with openHAB. To expose it to Alexa, install the Alexa binding and tag the Items that represent the sensors and relays on the ESP8266 in openHAB. Once you have the device represented by Items, it doesn’t matter what technology it uses. A Zigbee device is the same as an MQTT is the same as a KNX is the same as a web service. They can all be exposed to and controlled from Alexa, no separate Hue Hub is required. openHAB becomes the integration hub. That’s what it’s for.

So the actual most straight forward approach in my mind would be to use WiFi since the Raspberry Pi (assuming an RPi 0W or 3+) and ESP8266 come with WiFi. You’d have to wire in an Xbee transceiver to turn them into something that can speak ZigBee.

From there, install a ready made firmware like Tasmota or ESPEasy. These let you set up everything through a simple web interface. No need to write any code yourself. There are various ways these firmware let you configure the way the device will communicate. I believe MQTT is the most common. I believe both of these firmwares support Home Assitant’s MQTT standard. Turn this on.

MQTT requires the installation of an MQTT broker. This is pretty simple and most OH users use Mosquitto. If you use openHABian, Mosquitto can be installed through openHABian config.

From the openHAB side, install the MQTT binding, configure the connection to the broker and your devices will automatically be discovered as Things. Accept the Things and create Items to represent the Channels you care about.

Tag the Items per the Amazon add-on instructions to expose them to Alexa. Ask Alexa to reload or what ever Alexa requires and they will all show up as devices.

4 Likes