Using HA-Bridge with Mozilla Gateway

I do not know how many of us are using the HA-Bridge with the Mozilla Gateway (MG), but it certainly does allow much added capability. It integrates very nicely with MG in both directions. It is especially useful for creating custom scripts, adding it to the HA-Bridge with a device name. Then, going back to MG, scan for new devices and your script will show up as a new device. Just add it, and you now have a very easy way to run custom scrips. I am running HA-Bridge on a separate computer, which is never turned off. It also allows me to control what few X10 devices I have left as well, with the MG.

Also, as it is a full two way communication with MG<>HA-Bridge, it allows full Alexa control of all your MG devices. I have been using HA-Bridge for a few years now, and once I discovered the total integration with MG, I highly recommend it for all MG users. HA-Bridge will run on nearly all devices.

https://www.bwssystems.com/

This is really interesting, thanks for the pointer!

Thanks @mrstegeman. Some things I am using HABridge for:

  • Alexa voice audio control on my Linux PC. It is a script which controls PulseAudio allowing me to mute/unmute under varying conditions. Now bridged into MG so I also have a button to control it via the Gateway.

  • Voice control over my security cameras, using MotionEye software. I can turn it on and off remotely via the Gateway (I am not viewing the cameras via MG, just turning them on/off. I have a port forward to the MotionEye web interface).

  • Groups, such as “Evening Lights On” This voice command or MG button will turn on the Living room lamps, family room lamp, breezway light and backyard light. This also automatically turn off at 12:30am via the Gateway rule.

  • Allows for TRUE dimming control using intensity percents in a single command (I wish MG did this too).

Anyway, if you only want to add very good Alexa integration to Mozilla Gateway, or if you want control of non-standard types of devices, you all should give HABridge a try.

I had been running HA with my security system. I’m converting to a different system, so I migrated my Z-Wave stuff to Mozilla IoT on Raspberry Pi. I was hoping to simply continue using my Mozilla gateway, instead of the security system (and the monthly premium) but I would lose Alexa integration. Until the HA-Bridge. Is it safe to assume I can run this on my Pi alongside the Mozilla gateway? What happens to existing rules on the gateway?

I don’t run HABridge alongside IoT. I run it on my Fedora PC which is always on. You could probably get away with it on a Raspberry Pi 4 with 2-4 GB RAM, but I would think anything less would be overwhelmed by memory limitations.

Your existing rules on the gateway would be unaffected and as long as you have a rule set assigned to a gateway button, it will carry across to HA and can be voice controlled. Rules do not directly carry across to HA otherwise.

Something to watch out for, when you add a IoT thing into HA, it will come back across to IoT as a newly discovered item, since it is completely a two way connection. It’s a round robin so to speak. I wish there was a way to avoid this as it can be confusing sometimes.

I had to run the Mozilla gateway on my Pi 3 because the z-wave dongle wouldn’t work on the Pi 4. Sigh. This, I don’t want to mix with what is running on my Pi 4. I may need another Pi with enough RAM. Thanks…something to think about.

Very odd the dongle would not work on a Pi 4. That should make no difference.

There is a hardware issue with the Z-Stick that makes it not work with the Pi 4’s USB-3 ports. However, you can plug it into a USB hub to make it work.

@mrstegeman: Just to re-confirm what I think I read and need to do.

I’m moving my current docker-based MIOT GW instance to a RPI Raspian Lite Docker environment. Would like to copy the existing working directory to the RPI onto a USB stick on the RPI (avoid excessive SD card wear). My plan is to:

  • stop RPI GW
  • backup the current MIOT GW folder
  • insert a 64G USB stick in the RPI, format and mount: e.g.: /media/MyUSB
  • restore the MIOT GW folder to the RPI on the usb
  • Execute docker on the RPI GW with appropriate -v option to map the /media/MyUSB folder as GW home directory

In a previous thread, it was mentioned some of the add-ons may need to be re-installed.

Q: Are there any other issues to worry about? Permissions, USB file system type, or other issues?

I only have a handful of Z-Wave GE V2 devices which have worked flawlessly on the original laptop.

Thanks for any reminders or pointers to other posts…

Eric L. Edberg

ps: I originally attempted to use Ubuntu Core as the OS. How needlessly confusing it was attempting to transition to snaps. It was too locked-down I guess.

  1. The directory you need is ~/.mozilla-iot, which contains things like addons, log, etc. You don’t need the gateway source itself or the entire home directory.
  2. Since you seem to be changing architectures, you will definitely need to reinstall some add-ons, including the Z-Wave one.
  3. As for permissions, just make sure that whole directory is owned by the user running the gateway. With our Docker image, that would be 1000:1000, or node:node.
  4. There are some instructions in the README for sharing your Z-Wave dongle into your Docker container.

You will most likely need to format your USB storage as ext4 for Linux permissions to work properly. Also, if you mount the USB as /home then move your existing pi home there it would make things a little easier in my opinion.

I finally plunged into the deep end, got bored, and moved my IOT laptop configuration to my RPI 2B that was laying around. It went pretty smoothly except for the DateTime adaptor. Here, at a high level, is what I performed:

  • Installed Ubuntu Core and attempted to use it as the base for my docker image. Boy, what a mistake. Had nothing but problems. Snap sucks. In my previous work life, I was very used to CoreOS. Researched that on Red Hat. It too seemed overly-complicated.

  • Installed Rapian Lite Buster. It installed and worked much easier for those who know legacy linux. Installed DOCKER and pulled the Mozilla IOT v12 container.

  • Installed and mounted a 16G USB drive to be used as the Mozilla IOT home folder to avoid disk write issues on my RPI. Well see if writing to a USB is a better choice in the long term. Mounted the USB folder in /etc/fstab.

  • Copied the previous/legacy Mozilla IOT folder to the USB

  • Pulled the Mozilla IOT gateway:latest Docker image

  • Inserted an AEOTECH Gen 5 USB Z-Wave device previous installed on the laptop to verify the device name was detected by the RPI (it was)

  • So, at this point I moved the MIOT folder to a folder on the RPI 2B (in a USB folder), inserted the Z-wave device and verified it was detected, built a custom docker script to start the latest image (see below). As I’ve played with all this shit before, it was not too hard. NOBS, beware. Note: to complicate issues, I was moving from a X64 laptop to a RPI with a different architecture.

  • Suprisingly, when I started the IOT docker container, it detected the Z-Wave AEOTECH and loaded all modules except for the DateTime adapter.

  • After debugging the DateTime adapter, and manually trying to execute the install script shown in the log, Rapian Buster Lite does not have Python3 “pip” installed. I then apt-get installed “phthon3 pip”.

  • I then tried to manually re-install the DateTime python module on the CLI using the command shown in the log file. It HUNG, and after 5 minutes I broke out.

  • I then reviewed the log file and the DateTime adapter appeared to have loaded correctly. Whew… I guess that the command I copied from the log file had not-cli-correct syntax and re-directed output somewhere but it did install correctly.

  • After that, I was able to add the new DateTime device.

  • @mrstegeman, stated I would need to re-download/install the Z-wave add-on since I moved from an x64 to a RPI. I did not do this and the IOT was able to control lights without any updates. Not sure if it downloaded an update in the background like DateTime tried to do.

Bottom line:

  • If you are familiar with Linux, file permissions, copying, reading logs, scp, mounting, installing and booting OS’, debugging, general updating of programs add-ons, and have backups of your environment in case of failures, this upgrade was mostly EASY-PEASY. Not so much if you have issues and are note familiar with Linux…

Eric Edberg

ps: here is my docker start command

docker rm mozilla-iot-gateway

docker run -d --restart always --net=host \
        -e TZ=America/Chicago \
        --device /dev/ttyACM0:/dev/ttyACM0 \
        --log-opt max-size=1m \
        --log-opt max-file=5 \
        -v /etc/timezone:/etc/timezone:ro \
        -v /mnt/EdbergFS/mozilla-iot:/home/node/.mozilla-iot \
        --name mozilla-iot-gateway mozillaiot/gateway:latest