Rules for Hue dimmer switches, Run gateway at boot, Groups of groups

  1. I have a Hue bulb and a Hue on/off /dimmer switch. In the Rules screen I have 2 rules so that the on and off buttons control the bulb state. But when I try to set up rules for the “increase/decrease brightness” buttons (event 2 and event 3) the bulb thing only allows me to set the brightness to a certain fixed level. What I need is to be able to set it to its current level + a percentage. How?
  2. I have built the gateway on a Raspbian Stretch install. I want to use the gnome-schedule Gui to run the gateway at boot. I have tried “cd /home/pi/gateway && npm start” as the command line, but it doesn’t work. Any ideas?
  3. Things in groups. Please consider implementing groups as a thing so that we can have groups of groups as a thing. Not being able to have groups of groups is a major shortcoming of the Hue Bridge. Many light fittings have more than one bulb - it would be nice to be able to treat a light fitting as one unit (a group) and put them in other groups (a room). What do you think?

You could accomplish this with having a rule for each percentage step that only triggers based on the current percentage.

How is it not working? Any errors?

We have systemctl scripts for starting and stopping the gateway here:

I’m going to guess that its failing to start because npm isn’t in the PATH or something similar. Try using something like:

cd /home/pi/gateway > /home/pi/log.txt 2>&1 && npm start >> /home/pi/log.txt 2>&1

and then examine log.txt after booting.

Re.1 Dimmer switch. Thanks for the idea Martin, but it seems to result in very complex set of rules. Any idea if the team plan to implement something simpler?
Re.2 Run gateway at boot. As you suggested Dave, it’s a PATH problem. The log shows “/bin/sh: 1: npm: not found”. What kind of command line do I need to run the systemctl script (and could it also suffer from PATH problems)? Sorry for these Noob questions - I’ve been researching PATH and it looks like a nightmare!
Re.3 Groups of groups. I’ve been following the Issue #119 you refer to, but they seem to be discussing groups, not groups of groups. In my usecase, and I suspect, that of many others, groups of groups are essential. Maybe I should join GitHub and contribute - but I hesitate, being ignorant of all the technical issues.

If you’re using Raspbian, systemctl is installed by default. You’d just need to copy the mozilla-iot-gateway.service file https://github.com/mozilla-iot/gateway/blob/master/image/etc/systemd/system/mozilla-iot-gateway.service into your /etc/systemd/system directory. You’d also need to edit the file to change the paths to match what you’ve setup.

As far as getting your original solution to work, you either need to add the directory containing npm into your PATH, or use a fully qualified path when starting npm.

When programs run under a regular user, their ~/.profile and ~/.bashrc scripts are run. At system startup, no user is logged in, so the PATH will be quite minimal. When you’re logged in as a regular user you can use the

type npm

command to see when npm is located.

Thanks for trying to help me.
I tried the mozilla-iot-gateway.service method, edited WorkingDirectory and ExecStart and got in a terrible mess.
I seem to be getting somewhere with the gnome-schedule method after using “type npm” to get the path. But what command do I use to execute npm?
I tried “npm start” and I get “missing script: start”. I also tried “npm” and “npm run”. It looks like “npm start” is the one to use, but where is the start script?

The start script is stored in the package.json file which should be in the gateway directory.


You need to make sure that the current directory is the one containing the package.json when running npm.

Update: I tried using package.json - but again I got into a terrible mess (not booting to desktop, etc). Finally gave up and flashed the gateway image then installed a Pixel desktop. I found using cron to start my Webthing on the gateway image much easier than trying to start the gateway on a Raspbian image. It all works now.
Thanks for trying to help.

Hi,

what about next build Mozilla iot, when should we expect a new version?

My favorite add-on for grouping things is the “Pulse” adapter. You can create multiple, uniquely-named 1-second pulses. You can nest pulses within multiple rules for nesting groups of real things. As a simple example, create two 1-sec pulses, one called “house” and the other “everything”. Check the “invert” check box for the “everything” pulse.

Using the rules engine, drag the “house” pulse as the input, selecting [Event “turnedOn”] as the trigger. For the actions, drag everything you want to turn on to the right side of the rule, and select the “on” properties for those things. To turn everything off, I use “everything” [Event “turnedOff”] as the input, and put all the things to turn off as the actions. Then with my local private voice-controller I say things like “turn on the house” (a bunch of stuff goes on), “turn off everything” (same group of stuff goes off).

Here’s a screen shot of a rule that turns on two bulbs and a string of cafe lights (and you can imagine a similar rule for “everything” off.)

Another example for color control groups. Create a pulse called “blueberry” that triggers a group of colored lights to go blue. Another called “strawberry” could turn other bulbs red. You could create a third pulse called “fruit cocktail” and when it turns on, it triggers blueberry and strawberry. :slight_smile:

You can also use the “Virtual Things” add-on, and create rules between virtual things and a group of real things. The following rule shows triggering a rule using a virtual color bulb or a pulse.

Is there any elegant solution for this problem yet?

1 Like