Controlling your OBS Scenes with a Home Automation device

You can easily set up a standard 433 Mhz remote control that you use every day in your home to control scenes in OBS (Open Broadcast Software) if you don’t own a fancy Stream Deck.

All you need is a remote, a 433 Mhz Wifi Bridge and some Node-RED magic.

Sonoff 433 Mhz Bridge

Flash the bridge using these instructions:

Standard Home Automation Remote control
433 Mhz Wifi Bridge to OBS via Websockets Node-RED Flow

Install the OBS Websocket plugin:

Node-RED Switch using button codes to control flow

The 433 Mhz Bridge when it detects a signal, it publishes a message with it’s contents via MQTT. These will have codes attached to them and in the case of a remote, that code / data that is sent via the message payload translates to the button pressed. You can “train” your solution with the remotes you have. These can be standard house-hold remotes.

Scene flows per button press

The switch statements routes the flow based on the button data to a specific function.

Scene switch command to OBS Socket Server

The function sends a message with the “scene-name” with the parameter of the scene created in OBS.

Scenes in OBS

For additional commands refer to the protocol document:

Happy streaming! 😎

Building an Azure IoT Central “Gateway” using Node-RED

I control a few devices from the Internet, but I don’t want all devices exposed and connected to IoT Central. One solution is to build a gateway locally which routes request messages to switch things on or off to the correct device locally.

In this post we will look at how to send commands from IoT Central and route them using Node-RED to the automation device via MQTT.

Home Automation Gateway Architecture

This architure uses Node-RED as a gateway, and then uses Eclipse Mosquito as a MQTT server. The Grow Light and Air Conditioner in the diagram is an off the shelf Sonoff POW-R2 device flashed with Tasmota.

Flashing with Tasmota

Installing Eclipse Mosquitto in a Container

Installing Node-RED in a Container

“Gateway” flow in Node-RED

With Node-RED you can visually map the flow / sequence of events. Node-RED supports Azure IoT Hubs and Azure IoT Central, so it’s perfect for this job to do quickly and easily without having to write code.

Gateway device created in IoT Central’s Command Capabilities

In Azure IoT Central we have a single device linked with a command. The command accepts a parameter, which will be the device name / topic name on the local MQTT server.

Executing a command on IoT Central

The diagram above shows the command with the parameter.

Defined Methods to IoT Central Commands

The Node-RED Azure component supports Direct Methods. These are commands that you can directly invoke on a device. In this case, the device is the gateway itself created within Node-RED.

It supports two methods (as per Azure IoT Central template)

  • turngatewaydeviceon
  • turngatewaydeviceoff
Switch to determine flow based on Direct Method Invoked from IoT Central

With a Node-Red switch statement we can controll the flow with whichever method name was invoked from IoT Central.

Switch Home Automation On flow

If it’s the “DeviceOn” flow, then the device parameter name (payload) is used to build up the topic for the Sonoff device via MQTT. The payload of the message will be “on”.

Switch Home Automation Device Off Flow

If it’s the “DeviceOff” flow, then the device parameter name (payload) is used to build up the topic for the Sonoff device via MQTT. The payload of the message will be “off”.

Installing Node-RED in a Container

Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.

It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.

Running Node-RED is easiest in a Docker container. This is really easy to set up.

docker pull nodered/node-red

Pull the container from the Docker Repository

sudo docker run -d -p 1880:1880 -v /home/ubuntu/docker-nodered/data:/data --name mynodered nodered/node-red

Start Mosquitto.

The default port for Node-RED is 1880. Also ensure that the volumes are mapped to a local folder on the host to preserve the configuration.