top of page
Green Coral and Fish

Installing Home Assistant to the Pi-hat module..

So now you have finished building your kit and its time to install Home Assistant and add the Marine Assistant code. By the end of this guide you should be able to test all your inputs and outputs and will be ready to start adding some sensors.

Quick guide...

Here is a quick breakdown of the steps that you will need to do to get your Pi Hat module setup.

​

Below each step is explained in more detail if you need.

​

Home assistant is constantly being updated, It is possible that there is some variation to what us expained below. Google is your friend! 

Detailed Guide...

Depending on your experience with home assistant you might already be familiar with some of these steps. Home assistant is constantly being updated, Which is good but also means that some of the Install processes might chage as time goes by. If something comes up thats not detailed below, Google is your friend. If not, Send me a message via the Contact page and Ill Help out ASAP...

1. Burning The SD card Image.

To Write (or Burn) the Sd card image you will need to down load the Raspberry pi imager, This software downloads the Home assistant software and writes it to your SD card based on what Pi version you have and the latest HA version available.

The Pi Imager has 3 boxes that need filling out, Device, operating System and Storage....

Device.

This is the raspberry pi hardware that you will be using, In my case i have Raspberry Pi 4 selected. You select the Version you have. Pi 4 or 5 are recomended.

Operating System.

This is the Software that we want to run, In Our case Home Assistant. In the drop down menu scroll down to find "specific use OS" there you will find an option for Home Automation/assistants then after that you should find the latest version of Home Assistant.

Storage.

This Is the Location Of your SD card, Be sure you have this selected correctly! Check "My computer" if unsure.

imager.webp

2. Initail Home Assistant Setup.

To Access Home Assitant open your internet browser and type in the following:

 homeassistant.local:8123

Once the SD card is finished writing you can insert it into the slot on the back of the Pi, connect your ethernet connection and 12v power supply, Wifi can be set up after if you wish.​

​​​The First boot can take upto 20 minutes to finish, it is configuring settings and prepareing Home Assistant, just let it do its thing and follow the instructions on screen until you get the prompt to create an account. Once you have an account setup you can login and will be greeted with the Initial dashboard.

Initail setup.

Create a HA Account

Create an Home assitant accout, this is the local account that will be used to login to HA. Be sure to write these detail down and keep them safe.

Initial Dashboard

3. Install SSH Terminal add-on

We will need to install two Add-ons to get the features we need for marine Assistant to work, SSH terminal is one of them and is used to install the second add-on "HACS" Which is done in the next step.

To install this add-on you will need to be in advanced mode, go to your profile (Bottom left corner) then scroll down and activate Advanced mode.

Now click Settings -> Add-ons -> Add-on store (Bottom right)

Search for "Terminal & SSH" and look for the one with the icon like this....

Click here

Click here

Click on Install -> Wait for it to complete then Click start.

Click on "Open Web UI" and you should be greeted with the screen below.

This is the Home Assitant Terminal, here you can use commands to install things and change settings.

​

We will need this to install HACS in the next step.

3. Install HACS

Before continuing you will need an account at github If you dont have one click HERE to create one

At this point you should have the terminal window open and ready to type in commands, We will only need to put in one command and that is to download  HACS. Copy and paste the code below to do this.

wget -O - https://get.hacs.xyz | bash -

Let it download and do its thing, once finished you will need to restart Home Assistant for the Changes to take affect.

This process is usually quite quite and should take no longer than a minute or two.

To Restart to to settings then System and at the top right there is a little power icon. Click that and select restart

restart.png

Now we need to add the integration HACS to be able to use its features...

Go to Settings, click Devices and services then in the bottom right corner click "Add Integration"

​

You will then need to type in HACS and click on its icon. You will need to click all the check boxes and click submit. Next you will need to authorize HACS to access Github. Follow the onscreen instructions. 

installHACScode_edited.jpg
installHACScode_edited.jpg

You will need to copy the code from the window when prompted.

You will now need to restart again

Hacs Should now be ready and visable in your sidebar.

3. Installing add-ons

There are Three more Add-ons that need to be installed, File Editior, Raspberry Pi Gpio and ESPHome all three are needed to get the features for Marine Assistant. Here is how to install them...

Raspberry Pi Gpio

This Add-on is Installed through HACS Click on  HACS in the sidebar then add the integration "Raspberry Pi Gpio" 

Search for the Raspberry Pi Gpio add-on in HACS , Typing "Gpio" should be enough. Click on it then click on Install. this will give us access to use the Pi Gpio in HA. Once it is installed be sure that It is runing.

Click here

What is this for?

This will enable use of the Gpio pins of the raspberry pi, here we then can connect our sensors and the software knows what sensor is on what pin. This is explained in more detail in the next step

File Editor.

This Add-on is Installed through Home assistant itself, Go to settings then add-ons and click on "add-on" store in the bottom right corner.

Search for the File editor add-on , Click on it then click on Install. This will give us access to the file system on the Raspberry pi. Once it is installed be sure that It is runing.

fileeditor.png

Click here

What is this for?

This will enable Access to th eFile system of the Raspberry pi where we can put the Code needed to use the sensors on the Raspberry Pi, more will be explained further in this guide. 

ESP Home

This Add-on is Installed through Home assistant itself, Go to settings then add-ons and click on "add-on" store in the bottom right corner.

Search for the "ESPHome" add-on , Click on it then click on Install. This will add ESP32 support. Once it is installed be sure that It is runing.

Be sure not to install the "DEV" or "Beta" version

Click this one.

What is this for?

ESPHome is used to input the code for the sensor module and future modules, It speaks to the ESP32 in the sensor module. The Pi hat doesnt need it directly but prepareing this now will make it easier in the future.

You will now need to restart again

6. Adding the Marine Assistant code

For this step you will need:

1. Download the text editor Notepad++. This is needed to open the code, dont use a normal text editor like word.

        Click here to download (Windows): Notepad++

2. Download the Code file "Pi-hat code" in the downloads section of this website, click HERE to go to downloads.

You will need to open the Code in Notepad++ and copy it into HA. In Home Assistant Open the File editor and be sure you are in the Configuration.yaml file.

Copy the Marine Assistant code into this file underneath the code that is already there. Click on Save in the top right corner then restart HA.

Check this, make sure its the correct file

Insert code from here, in my case line 14

Save here

The Marine Assistant code may look different to the image above as it is also being updated regulary.

Quick explanation of the code:

The code for the Pi hat module is relativly simple, it consists of two "sections" the first one twoards the start of the code are all the Binary sensors. Binary sensor means that they are sensors that are either on or off. Switches, float sensors, leak sensors.....

This is how they are put together:​

First a list or the 10 binary inputs and there coresponding GPIO Pins

Line by line:

The type of I/O "binary_sensor"

What platform it uses "rpi_gpio"

Start of the list of sensors and their details.

Port is the Corresponding Gpio pin

Name, here float 1. You can change is to whatever you want

Invert_Logic: Makes this input reversed. 

You are free to conect anything that connects GND and the SIG pins togather to any of the 10 I/O pins. The Name can be changed to what ever you want as long as it is between the Speech marks. If you would like a Input to work the other way around you can set the Invert_Logic to false.

The second part of the code is the Switches. The Pi hat has Three switches, two are used for the 12v outputs and one for the buzzer. The code for these come after the binary sensors and looks pretty much the same. The only difference is the persistent option, if true then the output will keep its last state in case of a power loss.

There is also Reserve I/O on the PCB should you wish to add more senosrs or your own extras, their Corresponding gpio pins are listed on the PCB. Code for these has not been added as standard, should you wish to add something simply copy and paste one of the other senosrs and change the values as needed.

7. Testing the code and Inputs / Outputs

You should now be finished and have everything up and running, to test this go to "OverView" in the sidebar of your HA. This is your dashboard and it can be modified to however you like, however to start Home Assistant automaticly detects whatever you have connected. You should see something similar to the image below... 

On the Left you can see all the Binary inputs (Float switches for example), on the right three "switches" 2 are for the 12volt outputs 1 and 2 and there is also a switch for the buzzer too. Try the buzzer switch, it should turn the buzzer on.

Can't see this dashboard? you may need to add the "cards" yourself. Click on edit -> Take controll -> edit ->add card -> select the card you would like. More info on creating dashboards can be found on the Dashboards page

Tips And Tricks

  • Use a Good quality SD card, I prefer the Samsung or Sandisk crads. 64Gb​

Troubleshooting

Problem

Solution

Home assistant doesnt load in browser.

Be sure you have the address correct : http://homeassistant.local:8123

Find the IP adress in your Router and put that into your browser.

Check ethernet / Wifi conection.

bottom of page