script type="text/javascript"> jQuery(document).ready(function(){ jQuery("article.et_pb_post").each(function(){ jQuery(">a:first-child, .et_pb_image_container", this).insertAfter(jQuery(".post-meta", this)); }); });
Select Page

How does my Home Assistant app looks like? First of all when I started everything was in my configuration.yaml file. As I moved on i decided to split up the configuration to have a better overview and cleaner config when debugging. This is why i started using the: secrets.yaml, automation.yaml and script.yaml files.

Devices

  • Kodi mediaplayer (Raspberry Pi 3)
  • Netatmo Weather Station
  • Philips Hue lights
  • Philips Hue Motion Sensor
  • HP Envy 5530 (All-in-One)

I devided my Home Assistant setup in multiple Tabs for each room where devices are located that i want to use.

Automations

  • Update Kodi Library every hour, except if there is a movie playing
  • Turn on a scene when starting a Movie in Kodi
  • Revert back to the original scene when a movie is Stopped / Paused in Kodi
  • Turn on the lights when it gets dark
  • When my Work iPhone leaves home for work (on weekdays between times) send me a message about the expected Travel Time and the Quickest route I should take (by Telegram)
  • Send me a Telegram message when there is a new Home Assistant version
  • Send me a P2000 message within 5km from my home (Dutch Police/Firefighters/Paramedics)
    https://github.com/cyberjunky/home-assistant-custom-components/#p2000-emergency-services-component
  • Notify me by Telegram when a package is about to arrive (PostNL)

Backup

We all forget to configure backups and when the system crashes we think “where the …. are my backups”! This is why I just create a backup script that only copies the yaml files and uploads them by FTP to an external system. The script is below and runs by a cronjob.

#!/bin/bash
TIME=`date +%b-%d-%y`
FILENAME=backup-$TIME.tar.gz
SRCDIR=/home/homeassistant/.homeassistant/*.yaml
DESDIR=/home/pi
sudo tar -cpzf $DESDIR/$FILENAME $SRCDIR
echo $FILENAME
ftp-upload -h 192.168.10.254 -u FTPUSERNAME --password FTPPASSWORD $DESDIR/$FILENAME
rm -f $DESDIR/$FILENAME
#END#!/bin/bash

The script grabs a source dir (where your Home Assistant yaml files are located and uses a DESDIR to create the tar/gz file. Next modify the ftp-upload parameters to change FTPUSERNAME and FTPPASSWORD with your FTP Useraccount and password and that’s all.

Next you have to create a backup cronjob that runs every night or whenever you want. The script above gives a date stamp within the filename and also removes it from your system (to prevent filling up the disk).

Create a cronjob by running

crontab -e

add the following line to create cronjob that runs daily at 15:00. Keep in mind that the FTP location will fill up and you have to manually remove the files! Also the >/dev/null 2>&1 will prevent mailing from the cronjob 🙂

0 15 * * * /home/pi/ftpbackup.sh >/dev/null 2>&1

Reading HP Envy 5530

I’m currently reading the Ink levels from my Envy 5530 in Home Assistant just to know when my ink is about to “die”. To accomplish this i use the “hp-info” tool provided in Linux by installing hplip and configuring my HP-Envy as device.

sudo apt-get install hplip

then setup your printer with the HP tool (do not use Cups else HP-Info wont work). Use the command below with the IP address of your network printer and follow the on-screen setup tool (pretty basic).

hp-setup -i 192.168.1.10

After setting up the printer and confirming i can print from the Raspberry I used the HP-Info tool just like:

hp-info

This will give you a lot of info about the default printer, in my case the Envy 5530. Next just use some expressions to read the agent1-level (ink level for color in my case). You can do this by:

hp-info 2>&1 | grep -oP “(?<=agent1-level\s{18})(.*\S)” | tr “\n” ” “

Running this command wil give you the ink level (estimated by the printer) for agent1 (color in my case). Create a Command_line sensor (see docs) and put the command between ‘ and  ‘ so it will run and not mess-up the ” ” in the command.