Home Home Control: Raspberry Pi
Post
Cancel
Preview Image

Home Control: Raspberry Pi

Running OpenHab on a Raspberry Pi. This also runs a MQTT server and Node-Red. Separate servers for SQL and Grafana are run on the main TITAN server and linked from the Pi as these are write-intensive and want to avoid SD-card wear-out on the Pi. This allows the main server to be turned off when we are away, whilst maintaining elements of home control like automated welcome light.

WHEN COMPLETED SATISFACTORILY SAVE HABPANEL AND NODE-RED FLOWS BACKUPS

Install OpenHab on RaspPi3

  • Based on the OpenHABian installation docs
  • Configured DHCP Server (VirginMedia router) with reserved IP address against Raspberry Pi’s MAC address:
    MAC = B8:27:EB:CF:E8:C0, IP = 192.168.0.130
  • Downloads
    • Get the latest OpenHABian image from GitHub [v1.7.3]
  • Write image to SD card using the official Raspberry Pi Imager
    • Choose OS: “Use Custom” and select the image downloaded above
    • Choose Storage: select the SD-Card
    • Write the image. Do not remove the SD card on completion
  • Amend installation parameters before transferring the SD card to the Pi
    • Select the boot drive in Finder. If it is not mounted, unplug the SD card and plug in again and the FAT32 boot partition should appear. Edit the file openhabian.conf and make the following changes:
      • userpw=”[STRONGBOX]
      • timezone=Europe/London
      • locales=”en_GB.UTF-8″
      • system_default_locale=”en_GB.UTF-8″
      • ipv6=disable
    • Save the file, unmount the SD card, remove and insert into the RaspPi and boot it
    • It takes quite a while to run through everything initially (15-45 minutes) so helpful to plug into monitor via HDMI to watch things progressing. Alternatively use browser to monitor progress at http://192.168.0.130:80
  • Confirm can connect to the openHAB UI at http://192.168.0.130:8080
  • Confirm can connect to Samba network shares
  • Confirm can connect to the openHAB Log Viewer (frontail): http://192.168.0.130:9001
  • Connect to the Raspberry Pi SSH console using username openhabian and password [STRONGBOX]. Should see a welcome screen

Install Mosquito MQTT and Node-RED

  • Use Terminal to SSH into OpenHABian: ssh [email protected]
    • Go to the Config Tool, run command: sudo openhabian-config
    • Select option 20 Optional Components
    • Select option 23 Mosquito
      • Username: openhabian, password: [STRONGBOX]
    • Select option 25 Node-RED
    • After Node-RED completes, exit back to SSH command line
    • To get Mosquito to work with external devices needs the config file to be amended:
      • cd /etc/mosquito
      • sudo nano mosquito.conf, and add the following:
        • listener 1883
        • allow_anonymous true
    • Reboot the Raspberry Pi
      • sudo reboot now
  • NOTE: If setting up a new OpenHAB on the same IP, system might reject the SSH key as belonging to a previous install on that IP address. Delete old key from known_hosts and try again:
    • /Volumes/MacOS Catalina – Home/bob/.ssh/known_hosts

Setup OpenHAB

  • OH3: Goto http://openhabian:8080 to the OpenHAB GUI
    • Create a new user: bob -> PW in StrongBox
    • At Install-Addons screen, select then install:
      • Hue binding, MQTT binding, Nest binding, NTP binding, SolarEdge binding, JsonPath transformation
    • Using Samba shares, copy backup files html, items, sitemaps, things, etc to openHAB-conf. Confirm in GUI that they have been read in ok

Setup Node-RED

  • Check and install required Nodes on the palette:
    • contrib-openhab, contrib-huemagic, contrib-timeout, node-email, node-mysql, node-random
  • Import flows JSON from backup file, some configuration nodes do not have passwords and need reset
    • MQTT
    • MySQL node “MySQL-TITAN”
      • 192.168.0.32 / 3306 / openhab / opt1Max$ / sensors
    • Email node
    • Zappi HTTP Request Node authentication
      • 14302505 : PW in StrongBox
  • To get OpenHAB node to work, need to get an API token (refer here)
    • In OpenHAB GUI bottom left, click on profile button
    • Enter OH3 username/PW and Token Name = “oh3”
    • Create API token, and copy to the OpenHAB Node Controller in lieu of username & password. Looks like:
      • oh.oh3.961umQx8GMsxKxV2aYtG0gG9Y77DDcvLwk9u2SxyO3MOAjbcQV4NDk7UyEBQcSoxkQuJkDKAImQTFohnvg

Setup HabPanel

  • Goto the OpenHAB GUI at http://192.168.0.130:8080 and select HabPanel
  • Via the 3-bars icon at top left, select the cog at bottom right of popout and select “Edit the local panel configuration”
  • Import panel configuration from backup, then save to new panel configuration “Home”
  • Note: sometimes the CSS file is not updated properly and keeps using the one in the cache. Press Command+Option+E to empty the cache, then reload the page to refresh

Backup SD Card

Refer to instructions here

References / Resources

This post is licensed under CC BY 4.0 by the author.
Recently Updated
Trending Tags
Contents
Trending Tags