Is using Firestorm the right way to go

I have a Pixel Blaze V2 and a V3 on order.
What I want to do is use my home automation system (Loxone) to control the pixel blaze.
Now Loxone can deal with some HTTP commands (It can control a Sonos sound system using this method) so I have been trying to control the PB directly from Loxone but that’s not possible, or I am doing something wrong.
So my next thought was to use the scripting block within Loxone . This is based on Pico C so don’t really know where to start there. But the only command I could see that might be of use is charhttpget(charaddress,char*page); But don’t know how to implement this.
So my real question is is Firestorm the way to go and use the HTTP commands to get Loxone to control the PB.

Hi! Firestorm seems viable for this. Did you see how you can use the “/command” API with http GET?

As I don’t have an RPi, I have tried to install Firestorm on my Ubuntu laptop (its a dual boot with Windows 10) but I can’t seem to get it to work.
When I type the command yarn it says " Error: There are no scenarios; must have at least one"

Also how do you access the Firestorm UI, the github basically says there is one, but no mention of how to access it.

Any help greatly appreciated

Sure - I run Firestorm locally on OSX. I access the UI at http://0.0.0.0 (assuming you’ve started it without the PORT= env var set first as shown in the docs).

On Ubuntu, looks like you might be running the wrong yarn. Scroll down to the ~70 point upvoted answer here:

Still no joy. Followed the instructions. Had to remove cmdtest first
When I run yarn I get this error message

error archiver@5.0.2: The engine “node” is incompatible with this module. Expected version “>= 10”. Got “8.10.0”
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Not too sure what to do now. Did visit the yarn page above but not much help really.

@TechDoctor,
Based on the error message, the version of nodejs on your system is too old.

If you have ubuntu 18.04, this page may help explain what’s going on and how to get a newer version:
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04

In addition to Wizard’s link… I don’t really know my way around Node, but I’ve gotten similar messages and if you have other stuff on your system that needs that early system node (v8.10.0), you can use Node Version Manager (nvm) to quickly install a LTS (long term support) version of Node like this:

nvm install v14.15.4
# then
nvm use v14.15.4
# or
nvm alias default v14.15.4
2 Likes

Yeah finally got it to work. So thanks to Wizard and Jeff for pointing me in the right direction.
Had to remove Apache2 to get it to work.
Couldn’t use port 80 so set server to 3000 .
I now have the Firestorm server working and can access it from my main pc.
Got the 0.0.0.0:3000/discover to work. But can’t seem to change the patterns.
Its fairly late here, so I must be missing something really obvious. So going to sleep on it.

I can now change the patterns in a web browser using the GET command but for some reason I can’t get the POST command to work.
And Loxone still won’t communicate with Firestorm. But at least I am a step or two nearer.

@TechDoctor,
I didn’t see HTTP POST support in Loxone.

The GET flavor command supports the same stuff as the POST flavor command, so you don’t POST unless it is more convenient for you.

What Loxone script are you trying? It looks like a subset of C, so we might be able to help with at least that part.

Yeah got it working.
@wizard I am using the Loxone virtual outputs rather than the Pico C scripting, much easier.
So you set up a Virtual output with the ip address of the computer firestorm is running on so in my case this is http://192.168.1.101:3000
So once you have done this you then create a virtual output command for each pattern or command you wish to send.
So I have a pattern called White
So in the virtual command where is says command for on you enter
/command?command=%7B%22programName%22%3A+%22White%22%7D&ids=3601529
Set HTTP Method for ON to POST and leave everything else as is or blank.
Now you need to set up a virtual input to trigger the virtual command. Set this to push button join this to the virtual command. And that its.
So far I have only done two commands but at least it works.

This also means I can remotely control the PixelBlaze when away from the house if I want to.

1 Like

Ahhh. Just got mi RPi 4 4GB. Followed the instructions to install Firestorm. All worked OK, just had a power outage, and when the power came back on Firestorm doesn’t run. So I thought I will re-install everything. I now get this error message

env: ‘/usr/lib/node_modules/pm2/bin/pm2’: No such file or directory

The command I used was

sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi

So not too sure what to do now.
The only thing I have found out is that the node_modules directory doesn’t exist.

Hi @TechDoctor,
I think the location of pm2 moves around between versions. What do you get if you run

which pm2

If a path pops up, and is different, try replacing it in the instructions.

BTW you only need to get that once to set pm2 to run on startup. If it is running on startup, then this is the key bit that causes pm2 to load Firestorm:

Note, be sure your alias is still active before running these!

pm2 start server.js 
pm2 save

You should see an entry for Firestorm if you query pm2 for a list of services:

pm2 list
1 Like

Many thanks got there eventually. The path was incorrect. For anyone else having similar problems the path is

/usr/local/bin/pm2

so the command you use at this point will be

#run pm2 on boot
sudo env PATH=$PATH:/usr/bin /usr/local/bin/pm2 startup systemd -u pi --hp /home/pi

And note there is a space between …/bin and /usr/local…
Once I followed your instructions I rebooted the PI and then waited a few minutes to makes sure everything was up and running and it works. Will reboot later to see if it all works again.

1 Like

Looks like I spoke too soon, it has stopped working. Will try and figure out what is going on and report back.
This is what I get when the command yarn server is run

listening on 80
Pixelblaze Discovery Server listening on 0.0.0.0: 1889
events.js:174
throw er; // Unhandled ‘error’ event
^

Error: listen EACCES: permission denied 0.0.0.0:80
at Server.setupListenHandle [as _listen2] (net.js:1263:19)
at listenInCluster (net.js:1328:12)
at Server.listen (net.js:1415:7)
at Function.listen (/home/pi/Firestorm/node_modules/express/lib/application.js:618:24)
at Object. (/home/pi/Firestorm/server.js:24:5)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Emitted ‘error’ event at:
at emitErrorNT (net.js:1307:8)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

When I do the

pm2 list

I get

pm2 list

Thats it for now

I am back to using my ubuntu install on my laptop, to see if there is anything funny going on. But Firestorm runs perfectly.
But when I do **pm2 list ** the fields are empty
But it is working . I am at a loss as to what to do now.

@TechDoctor,
pm2 is a tool for running nodejs services in the background. Running yarn server runs Firestorm in your terminal but pm2 is already running it for you in the background.

You do not need to run yarn server anymore. Once pm2 is set up to run Firestorm on startup (and this appears to be the case now), you wont be able to run another copy on the same port and you will see errors like above. If you reboot your Pi, you should be able to get to Firestorm via browser by pointing it at your Pi’s IP address.

It is possible to get pm2 to run Firestorm without permission to use port 80, which is what all of the alias and authbind stuff is about in the instructions. On most Linux/unix systems port 80 (and all ports below 1024) are restricted to authorized users on the system. The authbind stuff is what allows the pi user to run Firestorm on port 80.

You can see the console output (and more) of Firestorm when it is running via pm2 by running this:

pm2 logs server --lines 1000 --nostream

This will show the last 1000 lines of both the error and stdout streams.

If you see something like “Error: listen EACCES: permission denied 0.0.0.0:80” in the pm2 log, then permissions aren’t set up properly to allow pm2 to use port 80. It is critical that pm2 be run via authbind, like so:

authbind --deep pm2

Which is what the alias command in the instructions is all about. I make note if this in the instructions here:

alias pm2='authbind --deep pm2'

#...

#I believe the pm2 alias with authbind is critical here
#alternatively `authbind --deep pm2 start server.js` might work
pm2 start server.js 
pm2 save

Try rebooting fresh, once online, can you access Firestorm at the Pi’s IP on port 80? If not, try running these 3 commands above (in the Firestorm directory) again.

You can also verify that the authbind config for port 80 exists, and is owned by pi by running

ls -l /etc/authbind/byport/80
1 Like

Now I did see this in the log file, so re did the alias command and then
pm2 start server.js
I get the message

[PM2][ERROR] Script already launched, add -f option to force re-execution

Then did the pm save command.
Which appears to be successful.
Doing the
ls -l /etc/authbind/byport/80
I get -rwxr-xr-x 1 pi root 0 Feb 9 19:51 /etc/authbind/byport/80

I feel I am doing something really silly for it not to work. But I did follow the original instructions to the letter and then where needed changed directory paths.
So still not working.
Ah just had a thought I do have XRDP running on the Pi so I can remote login from my windows pc would that cause any problems.

Update.
XRDP uses 0.0.0.0 so just deleted it.
Installed Putty on my Windows PC
Still can’t get it to work after re-installing on the PI.
I think I will start again with a fresh Pi OS install, and redo it. Fingers crossed.

I hate to ask and don’t mean to be pedantic, but did you use the -f option? Otherwise I imagine the command didn’t do anything.

If it still didn’t work with -f you can delete the entry and that should allow you to re-add it.

pm2 delete server

Do you have another webserver using port 80? If so, then yes there is a conflict. Firestorm also needs port 1889, but that is much less common.

What do you get when you run this?

sudo netstat -ltnp | grep 80 

You can run Firestorm’s webserver on a different port using the PORT environment variable. I think modifying the start command with something like this should work as pm2 docs say they pick up the environment, though I haven’t tested it:

PORT=3000 pm2 start server.js

I also recommend that you run pm2 flush to clear out the logs so you can more easily see if a change produces no errors.

pm2 list 2.0

I take it there should only be one Server running.

I think I am going to re-install the Pi OS. Will be quicker for everyone and safer on my sanity I think.
Thanks for all your help its been amazing.

Ah, it seems the -f option doesn’t replace, but force-adds. Hopefully some pm2 delete server commands would clear that up, as would a full reinstall!