Skip to content

Instantly share code, notes, and snippets.

@billyshub
Last active April 23, 2024 05:24
Show Gist options
  • Save billyshub/d63b78b2f8352f6d6ce5846f6b194ead to your computer and use it in GitHub Desktop.
Save billyshub/d63b78b2f8352f6d6ce5846f6b194ead to your computer and use it in GitHub Desktop.
Home Assistant Automations

Intro

Thought I'd share some of my home automations for inspiration. Let me know of any further improvents or even some new ideas you've found useful.

Garage Door Automatically Opens When Arriving Home

What you'll need:

Name URL ~$AU
Sonoff SV link $10
Magnetic switch MC38 link $2.5
Soap Box link $1.5
Jumper wires link $2
2 core copper wire link $2
USB cable link $1.5
5V power plug link $3
FTDI adaptor link $4

First you'll need to setup control of the garage door. This setup is pretty much taklen from a Dr Zzs video here but replacing the ultrasonic sensor with a magentic switch from his first video here.

Once this is complete you have a few options to trigger the garage door opening/closing. You can create an geofenced automation on tasker or the home assistant app to detect when you're home, or you can push some buttons/voice commands. Below is a few ways of completing this so experiment to see which works best for your scenario.

  • Phone bluetooth is connected to car.
  • Phone location goes from not home zone to home zone for at least 1 minute.
  • Phone is connected to home Wi-Fi.
  • Voice command google assistant "Open garage door".
  • Android Auto home assistant button.

Digital Photo Frame

If you've got an old tablet lying around this is a great use case for it.
I bought a cheap photo frame from kmart and adjusted the border such that the tablet fits inside. Leave a hold on the side for your power cord. You could also use a tablet case or 3d print a frame for it.
I use google photos and have it set to automatically add photos of myself + my partner into a shared album.
I dowloaded this great app on the tablet called Fotoo to automate the slideshow of all photos and newly added photos in that album.
The app well worth the premium if you can support, many features and customisations such as sleep/wake timers, date information, potrait background blur, and screen burn in reduction.

Sunrise Bulb Alarm + Heater Om

I have a Yeelight for my bed side table lamp and wanted to wake up naturally from light.
There's a really good automation tempalte called Wake-up light alarm with sunrise effect, you'll find the blueprint in there. Just make sure you have date_time_iso and date sensor in your configuration.yaml. If you enable the phone alarm sensor in your mobile pgone app, you can configure it to grab the sensor of your next phone alarm and make it check if you're actually home before triggering.
I've set it up so 15 minutes before your alarm goes off it slowly increases brightness every minute until it's reached its maximum brightnes. Incase i'm in a deep sleep, i've left my alarm music routine to play at time of alarm also.
There's even a pre-sunrise action I've setup that checks if temperature outisde is below 10 degrees, if it is satisfied it will turn on the smart plug for my heater.
Finally, as a post sun-rise action I've set it to turn off the bulb and heater 5 minutes after the alarm went off.
image

DNS Ad Blocker On Your Phone + Always on VPN

If you're tired of ads i'd recommend a mobile browser like firefox with uBlock origin add on along with a DNS ad blocker such as AdGuard Home. This works great for all devices at home but when devices like your mobile leave your home network the ads will return. I decided to look into having an always on VPN to solve this.
To do so setup either your router or your mobile device to have the AdGuard Home DNS server addresses, then setup wireguard on home assistant or your router.
I noticed the standard phone always on VPN was inconsitent, so decided to create my own Tasker automation to replace this.
To do so, download the Wireguard VPN app on your device and enable allow remote control apps under advanced settings.
Download the almighty Tasker app and setup a new Tasker Function task to turn on your Wireguard connection when Wi-Fi is disconnected and vice versa for off. Your Tasker Functions should contain WireGuardSetTunnel(true,<WIREGUARD-NAME>) with your wireguard connection name inserted. For the profile triggers, you can set it up such that when your phone is connected to a Wi-Fi-SSD network, it turns off and vice versa (use the invert checkbox to do the opposite). And that's it, phone will automatically turn wireguard on/off dependant on your Wi-Fi connection.
c

Wake PC Wirelessly to Game/Access Your PC Remotely

Wake on Wireless Lan (WoWL) has always been a pain and is very rarely truly supported.
On the other hand, i know waking my PC on USB is quite simple and works well with the press of a key on my keyboard. I have a Broadlink Mini already in my study to control the AC so I decided to investigate ways of using these 2 methods to wake my PC remotely. I found this neat Universal USB receiver called FLIRC which does the job perfectly.
You simply plug this device into your PC, and download their software to do a one time program an IR button to Wake on USB (For the IR code, copying an unused button on a tv remote will do).
Couple this with Windows Remote Desktop Protocol or something i like to use for gaming called Parsec, and you'll have a fully accessible PC remotely.
image

Shares Tracking

If you're like me and have different forms of investments (e.g. Crypto and Shares), you'll have to setup a new platform to track and manage these different investments.
I wanted something simple that could be accessed via home assistant so decided to use the Yahoo finance HACS add-on.
You can add a new tab on the home screen to view the current prices and write some code to calculate the shares profit. (or even some automations if it dips/rises above a certain value!)
For the formulas i've done something like the below for crypto you can modify by replacing sensor.yahoofinance_btc_aud, CURRENT INVESTMENT & ORIGINAL INVESTMENT:

  - platform: template
    sensors:
      bitcoin_profit:
        friendly_name: 'Bitcoin Profit'
        value_template: "{{ (states('sensor.yahoofinance_btc_aud') | float * <CURRENT INVESTMENT> - <ORIGINAL INVESTMENT>) | round(2) }}"
        unit_of_measurement: '$'
        icon_template: mdi:bitcoin

You can even add up all the total profits (or losses, RIP) to get an overall portfolio snapshot.
as

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment