Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Making a SuperHA-Pi (Install instructions)


AutoFrank

Recommended Posts

The genesis of this post was a desire to try and simplify the third party programs (mainly sonos http api, HA bridge & NUT UPS monitor) that I have running on a few Raspberry PI devices.

 

The Goal - Get them all onto one Pi device, move from SD to USB booting and overall make it easier to manage, especially in the case of a crash (ie have a spare usb stick)

 

I currently don't use NodeRed or MQTT but decided to include them as well to see if I could get them all working on a Pi3

 

I ended up with the following running on a Pi3 from a Sandisk 16gb Cruzer USB memory stick

  • sonos-http-api - 

    Please login or register to see this link.

     
  • HA bridge - 

    Please login or register to see this link.

  • NUT UPS Server - 

    Please login or register to see this link.

  • NodeRed - 

    Please login or register to see this link.

  • Mosquitto MQTT (broker and client) - 

    Please login or register to see this link.

 

The results can be accessed at 

  • Sonos API - http://192.168.1.240:5005/Livingroom/state
  • HA Bridge - http://192.168.1.240/#!/
  • NodeRed - http://192.168.1.240:1880/
  • MQTT pub and sub available at 192.168.1.240
  • NUT UPS service listener at 192.168.1.240:3493

 

Preface: The following steps worked for me and I referenced some of web pages I used but not all. I use Windows and I don't know the MAC equivalents.

My purpose for posting is to document what I did and hopefully this may help some users get started.  

It is not meant to be a foolproof guide that will work for all. You may come across some issues I never encountered and your best friend is google for resolving those

 

...af

 

 

=====

 

Installing Raspbian Buster

Download the zip from

Please login or register to see this link.

 
Use an application such as Win32DiskImager and a card reader to burn image onto SD Card (or Flash drive)
Before removing the SD card from the Card Reader use File explorer to view the content of the SD Card
Place a file called SSH (no file extension) into the root folder of the SD Card. This will allow you SSH into the Pi and use it headless

Place SD Card into Pi, connect Ethenet and apply power
Use Advanced Port Scanner (PC) or Fing (mobile) to find the IP address of the PI
Use Putty to SSH into the PI (enter IP address and port 22)
Login into Pi
Username - pi
password - raspberry
You can change the password if you like 

 

Booting from SD card and then from the USB Flash Drive

If you have a Pi3 you can get your Pi to boot from a Flash Drive/Memory Stick. It is documented below but in summary thisisi what you do

  1. Initially burn a standard raspbian image on an SD card. You then boot up the Pi using the SD card and run some commands over SSH. This tells the Pi to boot from USB first the next time
  2. Burn a standard raspbian image onto a Flash Drive. Remove the SD card and insert the Flash Drive and power on. It can take 20-30 second to boot and get a SSH connection so be patient.

Don't forget to add  the SH file (no extension) in the root of both the SD Card and Flash Drive/Memory as described above to enable SSH access from each to the Pi 


Boot up the PI with the SD card and a standard Raspbian Buster Image
SSH in the Pi
Enter the following commands (one per line)

Please login or register to see this code.

The last command should give a result like 17:3020000a
If not then repeat the above steps

 

Power off pi
Remove the SD Card and insert the Flash Drive/Memory Stick into one USB port
Add power and ethernet and let it boot (It can take up to 30 seconds to boot up)
SSH in as normal and confirm you can log in

Use an application like WnSCP if you want to get file access to the card/flash drive while it is running on the Pi

 

References: h

Please login or register to see this link.

 

======


Install NODE.JS & NPM
I use Node.js v8 here as there appears to be a conflict between v10 and npm where npm doesn't work correctly.

Npm is included in the Node v8 release below
Clone/Copy the zip the Pi

Please login or register to see this code.

Extract & Install

Please login or register to see this code.

reboot Pi using 

Please login or register to see this code.

Use following commands to verify install

Please login or register to see this code.

 

======


Sonos http api Install

Clone http api files to PI

Please login or register to see this code.

List folder contents and change to http-api folder and install the api (enter each one seperately)

Please login or register to see this code.

Start the API Service

Please login or register to see this code.

You should see references to sonos rooms, etc


Now open a browser and assuming your sonos zone/room name is Kitchen you can confirm that the api is working by entering the following 

Please login or register to see this code.

For me it is http://192.168.1.240:5005/kitchen/state

You should see something like 

Please login or register to see this code.


Get API service to start automatically when Pi powers up

INSTALL PM2
Reboot Pi  (sudo reboot) and enter each command separately when it boots 

Please login or register to see this code.

Reboot Pi (sudo reboot ) and confirm service starts automatically by using browser commands above

 

FOR TextToSpeech function of the Sonos API

Change folder 

Please login or register to see this code.

Edit the settings.json file

Please login or register to see this code.


Amend as you need -

I use AWS Polly and these are my settings

Please login or register to see this code.


Reboot Pi (sudo reboot) and confirm with the SAY command to one of your zones

Ref: 

Please login or register to see this link.

 

======


HA Bridge Install

Install Java8

Please login or register to see this code.

Let finish and verify using following command to display version

Please login or register to see this code.

Install HA Bridge sw (enter each command separately) 

Please login or register to see this code.

Create the service file

Change directory and edit/create the ha-bridge.service file

Please login or register to see this code.

Copy the following into the ha-bridge.service file

Please login or register to see this code.

Save the file in the editor by hitting CTL-X and then saying Y to update and save.

Reload the system control config:

Please login or register to see this code.

To start the bridge:

Please login or register to see this code.

To start the service at boot, use the enable command:

Please login or register to see this code.

Open browser and access HA Bridge GUI at http://Ip of Pi/

Please login or register to see this attachment.

Configure as required

 

Note: If you have an instance running and want to migrate you will need to copy the habridge.config and device.db files to the new Pi

There are some guidelines here for that but I haven't tried them - 

Please login or register to see this link.

 

Ref:

Please login or register to see this link.

& others

 

======

 

Network Utility Tools Install

For UPS devices connected over USB

 

Update some pi network references

Please login or register to see this code.

Scroll to bottom and add this text (Change the static address to be that of your Pi)

Please login or register to see this code.

Save the file in the editor by hitting CTL-X and then saying Y to update and save.

Now hook up the UPS to the RPi using the USB cable and reboot the RPi. (sudo reboot)

Install NUT

Please login or register to see this code.

Confirm any questions with Y

reboot (sudo reboot)

Display USB interfaces to ensure that UPS is visible

Please login or register to see this code.

you should see something similar to this

Please login or register to see this code.

Note: You can see both the USB Drive (Cruzer) and the UPS System (MGE Systems)

 

Configure NUT

Please login or register to see this code.

Add this to the bottom of the file

Please login or register to see this code.

Review

Please login or register to see this link.

to change usbhid-ups above if required to match your UPS driver

Save the file in the editor by hitting CTL-X and then saying Y to update and save.

Test the UPS driver by running:

Please login or register to see this code.

You may see something similar to the following

Please login or register to see this code.

 

Configure Upsmon and upsd

Edit the upsd.conf file

Please login or register to see this code.

Scroll down to the LISTEN part and uncomment the LISTEN directive for localhost (127.0.0.1) and add another LISTEN directive for the static IP we assigned to the RPi earlier.

You should end up with 

Please login or register to see this code.

Edit the upsd.users file

Please login or register to see this code.

Add the following to the bottom

Please login or register to see this code.


Edit /etc/nut/upsmon.conf and add the UPS to be monitored and user credentials for upsd in the MONITOR section:

Please login or register to see this code.

Add the following to the MONITOR section

Please login or register to see this code.

Edit /etc/nut/nut.conf and set the value for MODE equal to 'netserver' without any spaces before and after the = sign:

Please login or register to see this code.

Add the following to the bottom of the file

Please login or register to see this code.

save and close file. Reboot Pi (sudo reboot)

 

I then created a service as the service doesn't always start by itself. The issue is referenced here -

Please login or register to see this link.

I used a py script and there are other ways. 

 

Edit/Create the py script file from the home directory)

 

Please login or register to see this code.

Add the following to the file

Please login or register to see this code.

Use systemd to run at start up by creating a service

Create/edit the service file 

Please login or register to see this code.

Add the following to the file

Please login or register to see this code.

CTRL-X and Y to exit

Change to systemd Directory 

Please login or register to see this code.

Reload the services

Please login or register to see this code.

Start service by ..

Please login or register to see this code.

Enable to run at boot

Please login or register to see this code.

Ref :

Please login or register to see this link.

 

======

 

Install Mosquitto MQTT Broker and Client

Retrieve and add the key (enter each command separately)

Please login or register to see this code.

Then make the repository available to apt

Change folder

Please login or register to see this code.

Enter the following to get the list for raspbian buster

Please login or register to see this code.

Update the source list

Please login or register to see this code.

This installs the mosquitto broker

Please login or register to see this code.

This installs mqtt mosquitto client 

Please login or register to see this code.

Testing MQTT

Open tow SSH sessions to the Pi (call one putty1 and the second putty2). Log into both

 

In putty1 session type the command with the topic name armtronix_mqtt (just used for testing)

Please login or register to see this code.

This will subscribe Pi to MQTT broker(which is runs on Pi) handling MQTT armtronix_mqtt.

 

In putty2 session type the following command with the same topic i.e armtronix_mqtt

Please login or register to see this code.

Now come to the window putty1, image 1 here you will be able to see the message "Hello"

 

Please login or register to see this attachment.

 

Ref:

Please login or register to see this link.

 

======


Install Node RED

I'm installing just NodeRed and not NodeJs/NPM as I don't want NodeJs version to be upgraded to the latest v10

Install Nodered

Please login or register to see this code.

test by starting start with 

Please login or register to see this code.

Now we need to create a service to get it to start on reboot

Create/Edit file

Please login or register to see this code.

Add the following to the service file

Please login or register to see this code.

CTRL-X and Y to exit

 

Ensure that the service runs at boot up using systemd

Change folder

Please login or register to see this code.

reload the services

Please login or register to see this code.

Start service by ..

Please login or register to see this code.

Enable to run at boot

Please login or register to see this code.

Access NodeRed UI at  http://ip of Pi:1880/

 

Please login or register to see this attachment.

 

Ref

Please login or register to see this link.

 & 

Please login or register to see this link.


======


Optional ...
Save the Flash Drive image to your PC to reburn later or create copies for fast swap out if you need to
Use something like Win23DiskImager to do this.


... Enjoy !!

 

 

 

Edited by AutoFrank
  • Like 1
  • Thanks 6
Link to comment
Share on other sites

Cool.

but node red already included MQTT node (emulated)

also node red already included sonos node (very cool - trust me)

idk for what purposes you install HA bridge... no comment here 

and last 

Please login or register to see this link.

also you can simple grab ups status from node-red.

so imho you can install *only* node-red ;) 

thats all ;) 

 

btw, now I am not used rPI in HA. NODE-RED now works in container (QNAP)

  • Like 2
Link to comment
Share on other sites

  • Topic Author
  • Thanks @10der

    I use ha-bridge to add scenes and VD button trigger devices to my amazon account for Alexa for voice control.

     

    The great thing about the individual packages is that people can pick in an "al la carte" fashion....

     

    I must take a look at nodered when I get a chance .. 

    Edited by AutoFrank
    • Thanks 1
    Link to comment
    Share on other sites

    all this works with node red, dont need the other stuff. I control my vd an scenes and the other Modules from fibaro with my Alexa through node red.

    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • 48 minutes ago, ctyd said:

    all this works with node red, dont need the other stuff. I control my vd an scenes and the other Modules from fibaro with my Alexa through node red.

     

    thanks, that might be a good place for somebody new starting out @ctyd

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...