Home Assistant

_images/homeassistlogo.png _images/demoDash.png

trigBoard can send to Home Assistant out of the box! If you’re already familiar with Home Assistant, then you already know how powerful this is and will be very happy to find that you can integrate the trigBoard in just a few steps. This takes the trigBoard to a new level, because now you can tie this in to alerts, automations, monitoring, etc… It’s also very easy to add sensors to the trigBoard and provide that additional data to your system.

Home Assistant Setup

First step is to make sure you have Home Assistant Installed (if you don’t already) - head over here and follow these steps: Home Assistant Installation

Note - I am running Home Assistant on a Raspberry Pi 3 64bit

Make sure you’re in advanced mode:

_images/advancedModehass.png

Take note of the IP address:

_images/hassIPaddress.png

MQTT Mosquitto Broker Add-On

Supervisor>>Add-on Store

_images/addonmosquite.png

Search for “mqtt”

_images/mqttsearch.png

Go and install, then start:

_images/mqttInsatll.png _images/mqttstart.png

Then just for reference, here is my configuration tab and note the MQTT port we’re going to use:

_images/mqttconfigtab.png

Now go to Configuration>>Integrations>>Click Configure in the MQTT block>>Click Submit in the popup window

_images/MqttSubmitconfig.png

trigBoard Setup

Launch the configurator as you normally would when setting up the trigBoard - hold wake button until Blue LED is flashing. Can go here for reference on all parameters: Configurator Tool

Setup the WiFi network settings first and make sure you get a connection, then setup the messages:

The only requirement here for all of your messages is that they contain no spaces or commas, because we’re going to use these characters for parsing on the Home Assistant side. Also, I recommend setting the battery threshold low, so that it never sends the low battery alert. Reason is because the low battery alert message would be a second packet for you to parse out… when really, you don’t need this alert since you will already have the ability to use the battery voltage to generate alerts within the Home Assistant system. If you have a trigBoard that rarely wakes and reports its status, but still want battery monitoring, you could set the timer to check if the contact is still open/closed and just set those messages to the same as your normal open and close messages like this:

_images/trigmessagessetuphass.png

or could use STILL_OPEN/CLOSED and just setup automations to detect these - that works too!

_images/stillopneclosedhass.png

MQTT Settings

1- Enable MQTT
2- Enable Security
3- Enter in same credentials you use to login to Home Assistant
4- Default port is fine at 1883
5- Server is the IP Address of your Home Assistant Server - see above on where you can find this
6- Important The topic is the identifier for this trigBoard and will be unique for this board. Choose something descriptive and take note of what you entered.
_images/mqttsettingshass.png

Home Assistant Yaml

We’ll be using the File Editor to make changes to the configuration.yaml file, so go an install/start that just as shown above for Mosquitto

_images/fileEditor.png

I like to keep this in the sidebar for quick access:

_images/showinsidebar.png

Launch the file editor and make you are editing the configuration.yaml file:

_images/yamleditor.png

Here is where we’re going to add the trigBoards (more advanced users may keep this config elsewhere)

Let’s start by adding a sensor subscribed to that same topic we had set in the trigBoard Configurator:

sensor:
  - platform: mqtt
    state_topic: "frontdoor"
    name: "Front Door"
    icon: mdi:door

Which looks like this when you paste it in:

_images/pastedttedtYaml.png

Save that:

_images/saveyoaml.png

Go to Configuration>>Server Controls>>Check Configuration

_images/checkconfiguration.png

If all good, you can scroll down a bit and click “MANUALLY CONFIGURED MQTT ENTRIES”

_images/refreshmqtthass.png

Testing

Let’s make sure you see the trigBoard - Developer Tools>>**STATES** and look for your newly created entity:

_images/sensorfoundSatethass.png

If you look at its state while opening/closing the contact, you should see the normal trigBoard message.

Parsing

Within the Developer Tools, go to the TEMPLATE tab:

Here we can experiment with parsing, first just to look at the raw message:

_images/rawmessageTaml.png

If we split by the space character:

_images/splitSpcacetemp.png

Now we can select the part of the message we want:

_images/firstpartbeforecommahass.png

And we can split again to get rid of that comma:

_images/hassridofcomma.png

And we can the same thing to get the voltage and strip out the unit:

_images/volatgeParsingTemp.png

Final Config

With this knowledge, we can use a value_template in the YAML file to automatically pull this information out of the trigBoard message. We need to create two sensors for both status and voltage. Note that you can add a custom MDI Icon and give a unit:

sensor:
  - platform: mqtt
    state_topic: "frontdoor"
    name: "Front Door"
    value_template: "{{ value.split(' ')[1].split(',')[0] }}"
    icon: mdi:door
  - platform: mqtt
    state_topic: "frontdoor"
    name: "Front Door Battery"
    value_template: "{{ value.split(',')[1].split('V')[0] }}"
    icon: mdi:battery
    unit_of_measurement: "V"

Which looks like this in the file:

_images/finalwithtaemphass.png

Don’t forget to save and reload MQTT entries!

Now you’re all set - head over to Overview and click the 3 dots in the upper right to edit your dashboard. Go ahead an take control of the Lovelace UI, then create an Entity Card and you should be able to add in the trigBoard:

_images/cardeditorUI.png

And now you have a trigBoard in your dashboard!

_images/cardFinishedHAss.png

With these entities, you can go nuts with this! Create conditional cards to show custom text when these states change, automations to run actions based on events (even have your Alexa/Google speak!), or really anything you want from here!

Custom Sensors

Want to add a temperature sensor to the trigBoard? Maybe report status of something along with the message? This is very EASY

First step is to make sure you can compile/upload the Base Firmware

The key is to just concat the data onto the existing message - here is a snippet from a sensor I have that samples a GPIO pin:

_images/solarBoardHASSaddon.png

You see how it’s just a comma separated value added to the end of the push message? That’s all you need, since this is super easy to then pull out from the value_template, like in this case I only needed battery voltage and this new value for state:

sensor:
    state_topic: "trigSolarTester"
    name: "trigSolar Voltage"
    icon: mdi:car-battery
    unit_of_measurement: "V"
    value_template: "{{ value.split(',')[1].split('V')[0] }}"

  - platform: mqtt
    state_topic: "trigSolarTester"
    name: "trigSolar State"
    icon: mdi:solar-power
    unit_of_measurement: "V"
    value_template: "{{ value.split(',')[2] }}"

Or here’s another example adding a temperature value:

_images/mcptempsensorexample.png

And same as before, this sensor is on a timer and wakes every minute to send data - I only care about voltage and this new temperature value:

sensor:
  - platform: mqtt
    state_topic: "MCP9808_OUTSIDE"
    name: "Back Porch Temperature"
    icon: mdi:temperature-fahrenheit
    unit_of_measurement: "F"
    value_template: "{{ value.split(',')[2] }}"

  - platform: mqtt
    state_topic: "MCP9808_OUTSIDE"
    name: "Back Porch TempSensor Voltage"
    icon: mdi:car-battery
    unit_of_measurement: "V"
    value_template: "{{ value.split(',')[1].split('V')[0] }}"

Plotting with Grafana+InfluxDB

This takes plotting your data to the next level - just look at this dashboard I created:

_images/dashboardshowinggrafana.png

Install InfluxDB

Same as before: Supervisor>>Add-on Store, then search for InfluxDB Go ahead and install/start that:

_images/influxdbaddon.png

Once started, go into InfluxDB and click the InfluxDB Admin icon:

_images/influxadmindbicon.png

Create a new database and call it homeassistant

_images/influxdbhomeassistant.png

I changed my duration to 7d

_images/influxduration7d.png

Click on Users and create a new user called homeassistant and choose a password:

_images/homeassistantuserinfluxdb.png

Don’t forget to change the permissions to ALL

_images/homeassistantuserpermissons.png

While we’re in here, add a user for Grafana as well and also give ALL permissions:

_images/addgrafanauser.png

Go back to Supervisor and select InfluxDB and click the Documentation tab - scroll down a bit to the Yaml snippet - COPY this:

_images/homeinfluxdbyamlcopysni.png

Head back over to your file editor to modify your configuration.yaml file and paste this in there, but note that the database name, user, and password all match up with what we have created in the InfluxDB admin page:

_images/influxpastedyamlconfig.png

Finally, give your Home Assistant a restart: Configuration>>Server Controls and click RESTART

_images/restartinfluxdb.png

Install Grafana

Supervisor>>Add-on Store, then search for Grafana Go ahead and install/start that:

_images/grafanainstalladdaon.png

Once started go into the Documentation tab - and COPY this URL:

_images/grafanalinkdocumenattioon.png

Go to the configuration tab and make sure SSL is false:

_images/grafanaconfiguration.png

Now open up Grafana and click the configuration icon and go into the Data Sources:

_images/grafanadatasourcesicon.png

Add a data source:

_images/adddatasourcegrafana.png

Search for InfluxDB and select that:

_images/influxdbdaatasource.png

That URL we copied can be pasted here now:

_images/urlintografana.png

Enter in the homeassistant InfluxDB, then the user and password is the one we created for Grafana - Save & Test and you should see this:

_images/saveandtestgrafana.png

Create a Dashboard

In Grafana, go and create a new dashboard, then add an empty panel:

_images/grafanacreateanewdash.png _images/grafanaaddpaneldash.png

Here we have a query where we can select anything we want to plot or even just display in text. I use it to create a beautiful looking dashboards.

If we wanted to pull in and plot the battery voltage from a trigBoard, we can run a query like this:

_images/zoominonimagequery.png

Then looks like this:

_images/trigBoardvoltagequeryy.png

Then if you save this dashboard, you can share, then copy the link out:

_images/sharegrafanalink.png _images/copygrafanalink.png

In your Home Assistant Dashboard, you can now create a webpage card and paste that URL in:

_images/homeassistantwebpage.png

Now you have Grafana plots in your Dashboard!

Note that you can modify that URL to include the time frame and I recommend enabling kiosk mode, so only the plot is shown - here’s an example:

http://homeassistant.local:8123/api/hassio_ingress/lT8ixi8MuSreoBQVVB9bjFyRyfmXki0Z5rnit7RGHWo/d/xc8gaT9Mk/trigsolartest?orgId=1&refresh=30s&kiosk&from=now-24h&viewPanel=2

See the kiosk label in there, the auto refresh time at 30sec, the time frame is now-24hr to give last 24hours

Here’s a query I needed for an ESPhome device to get its state:

_images/esphomstatequery.png