Categories
Raspberry PI Raspbian Tools VMUG

VMUG Controller and how I finally got it working

So a last year one of the projects I was working on that consumed me was trying to set up a VMUG Controller. The VMUG Controller is a Raspberry Pi appliance that allows you to check in and events and has a printer to print out a name badge. The whole system is a closed environments which means to access the web page you need to be connected to the vmugc Wifi. The whole process for setup has been very well documented by Dan Barr of the Central PA VMUG. You can find the instructions here on his Github.

However no matter how good the instructions are there are a few issues that need to be addressed.

Hardware: You need to use either a Raspberry Pi 2 or Pi 3 B+

Operating System: Rasbian Jessie – In order for the installation script to work you need to find the right version of Raspbian Jessie (I think this is the right version). If not you can find older versions of Rasbian here.

Do not Update the OS or this will break the whole thing. You will also need to install PHP7 as Jessie only has PHP 5 which you can find instructions on how to do that below.

How to install php7 on Raspbian
://help.nextcloud.com/t/upgrade-php5-to-php7-on-raspbian-jessie-8-0/24537

Once this is complete you can proceed with following the installation script.

Once the install has completed you will then see the new WiFi SSID VMUGC which you will need to connect to in order to access the web page.

After that it should just work.

I hope you found this post helpful, If so please share it with your friends. We could really use the support and to get the word out there.

Smartthings to Home Assistant using MQTT

I have been away for a while, but in my absence I have been playing with a Home Automation System called Home Assistant. You can find out more about it here on their website: https://home-assistant.io/ 

One of my Father’s Day Gifts from my Wife and Kids was a SmarThing Hub with a Arrival sensor. Now Home Assistant has literally hundreds of pre-built integrations however SmartThings is not one of them. To make it work with Home Assistant you will have to use a protocol called MQTT which is very versatile and can be used to create your own Automations.  (Find out more about it here.)

Now my Home Assistant instance is running on a Rasberry Pi 3 (also a Father’s Day Gift) however it also runs on a Raspberry Pi 2. I am also running HASSbain which is a Raspian image created by Home Assistant. As for MQTT there are a few products out there that you can use, I prefer Mosquitto as there seems to be more guides out there on how to configure and manage it.

Start off by checking for and installing updates for Raspian:

sudo apt-get update

sudo apt-get upgrade

this could take a while depending on your setup.

Next you will need to setup the smarthings-mqtt-bridge via npm
sudo apt-get install npm

sudo npm install -g smartthings-mqtt-bridge

Then you will need to setup pm2 to run the processes
sudo npm install pm2 -g

Once installed you will need to create and edit smartthings-mqtt-bridge config
sudo cp /usr/local/lib/node_modules/smartthings-mqtt-bridge/_config.yml ~/config.yml

sudo nano ~/config.yml
Here is what the mqtt-bridge-configuration ~/config.yml file should look like if all is configured correctly.
mqtt:
  # Specify your MQTT Broker’s hostname or IP address here
  host: mqtt://localhost
  # Preface for the topics $PREFACE/$DEVICE_NAME/$PROPERTY
  preface: smartthings

  # Suffix for the state topics $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_SUFFIX
  # state_suffix: state
  # Suffix for the command topics $PREFACE/$DEVICE_NAME/$PROPERTY/$COMMAND_SUFFIX
  # command_suffix: cmd

  # Other optional settings from https://www.npmjs.com/package/mqtt#mqttclientstreambuilder-options
  username: pi
  password: mqttpass

  # Port number to listen on
  port: 8080

Now that all of the local configurations have been completed you need to configure the SmartThings Device handler, Device, and SmartApp using steps outlined in https://github.com/stjohnjohnson/smartthings-mqtt-bridge150

Device Settings
IP: raspberry pi IP
MAC: Raspberry pi MAC
Port: 8080

Next you will need to add mqtt to HomeAssistant config configuration.yaml
mqtt:
  broker: localhost
  port: 1883
  client_id: home-assistant-1
  username: pi
  password: mqttpass

Now you will need to add your devices to their own file, or configuration.yaml
Since I am using mine for presence detection mine looks something like this

device_tracker:
  – platform: mqtt
    name: “MQTT Presense Detection”
    devices: 
      Friendly Name: smartthings/device name/presence
      Friendly Name1: smartthings/device name/presence
     
Now you will need to start the bridge

sudo ln -s “$(which nodejs)” /usr/local/bin/node
pm2 restart smartthings-mqtt-bridge

restart Home Assistant
sudo systemctl restart home-assistant.service

That should do it. You may want to sudo reboot

In the future I may do more of these as I have learned at lot from it, including beginning to dabble with Docker.