Switching off the lights the hard way

Standard

How many components does it take to switch on a light by voice? Here we look at what’s involved in using a Neopixel strip as a Google Home connected light bulb.

There are multiple ways of issuing commands to Google Assistant like via IFTTT or api.ai but only using Actions SDK directly lets us issue short commands like “Hey Google, lights on” rather than “Hey Google, tell house lights to switch on”. When registering as a ‘Light’, it also lets us use existing built in traits like ‘brightness and colour’ without having to write our own intents and re inventing the wheel.

Ignoring the initial OAuth handshake the flow of data is as follows:
Voice > CHIP/Phone > Google Assistant > https  > express > Mosca MQTT > ESP32 > NeoPixel

Connecting to Google Actions requires a publicly accessible https endpoint, but getting proper SSL working on embedded in a home network behind a router is not easy, to say the least. So I opted to create a Dockerized HTTPS to MQTT gateway which will run on a publicly available VPS which will forward the received https traffic via MQTT to connected devices and respond back to the request with the MQTT reply from the device.
Continue reading

Debugging client/server requests with req.uest.info

Standard

req.uest.info is an open source online debugging tool for capturing and displaying  requests from clients in JSON without the need for a server, built using Node, MongoDB, Express, Angular & Socket.io.

The demo http://submit-request.herokuapp.com/ is currently hosted on Heroku. Simply set your form or application submit url to http://submit-request.herokuapp.com/submit/ and view the submission data.

When a REST request is made to /submit url the node express route/handler re-transmits/pushes the data to all connected clients using socket.io emit.

This message is handled on the client side by the angular socket.io service.

On row click, the data is passed through a json syntax highlighter and displayed.

TODO: Currently requests are visible to all by default, I’m working on allowing logged in users to make private requests from a set of IP addresses. The user authenticating and IP address management is already implemented using MongoDB and passport.js. What’s left is to search for the ip address when a request arrives, then if a match is found, send the request only to the users connected client. (ip address of each logged in client will have to be stored with their socket connection).

This was a fun experiment in the MEAN stack and socket.io. Javascript and it’s developer tools (npm,bower,yeoman,jade,bootstrap,etc) are maturing fast enabling rapid development of projects like these in a few nights rather than months.

Feel free give feedback in the comments below or to submit a pull request/fork.