Home Monitoring

This is my home monitoring setup repo.

A few goals.

  • Monitor Powerwall battery charging
    • Alert at certain levels
  • Monitor my indoor thermostat temperature over time and compare to weather forecast
    • Optimize when to turn on the AC when there is enough solar generation to offset its use
    • Pre-cool the house

The first thing is to decide which home automation software to run. Two I'm considering.

  • Homeassistant
  • Homekit with Homebridge

TODO's

Done

  • Set up companion app
  • Move Home Assistant to Mac mini

You run this as a server and it can run without a hub like Homekit requires. Has great out of the box functionality and a ton of integrations. There's an iOS app which I haven't set up yet.

Install

Good background: Which Installation Method is Best for Home Assistant? – Siytek

This was the best tutorial I found to install. To install as a VM on a mac (hard)

Refer to installation guide here: Run Home Assistant on macOS with a Debian 12 Virtual Machine – Siytek

Original article I used replaced by above: How To Install Home Assistant Supervised on Mac OS – Siytek

Note there may be updates here: home-assistant/supervised-installer: Installer for a generic Linux system

Other options reviewed To install natively on a mac (easy, but didn't work and no addons) - How To Install Home Assistant On Mac OS – Siytek - But you miss the Home Assistant Supervisor and its features Official install docs which require understanding VM's (hard) - MacOS - Home Assistant

UTM set up

It uses UTM | Virtual machines for Mac which is very cool. UTM has lots of Mac friendly features. Even AppleScript Scripting | UTM Documentation!

  • Set networking to Bridged (Advanced)
  • In your VM run ip addr | more to get the internet ip address

On networking: UTM Networking Mac M1 - YouTube

  • Shared Network (NAT) - can connect out to the WAN but can not be connected to
  • Host Only - No connection to the WAN or host network. But can communicate between VMs on the machine with ssh.
  • Bridged (Advanced) - select virtio-net-pic. Get IP from your host network.

More references

Start UTM on startup

Ideally I'd run as a service in the background, but choosing to do it as a login item as that's easier for me following these instructions - Remote Control | UTM Documentation.

Headless can run in the background Headless | UTM Documentation, but I don't want to have to login via ssh. Interseting ideas here too. [MacOS] Start VM Headless/In Background · Issue #2280 · utmapp/UTM

Home Assistant companion app (iOS/Android)

  • Install the app
  • Enter server address manually if not found

You can run the companion app on your Mac and it has sensors you can use for automation! It lets you add widgets and buttons to trigger actions that get sent to Home Assistant. See details here: Getting started with the home assistant app for MAC os | JuanMTech

Moving VM to a new Machine

Refer to installation guide here: Run Home Assistant on macOS with a Debian 12 Virtual Machine – Siytek

Original article I used replaced by above: How To Install Home Assistant Supervised on Mac OS – Siytek

Install UTM

brew install --cask utm

UTM | Virtual machines for Mac macOS | UTM Documentation

Set up virtual machine

Start UTM Drag VM image into UTM interface

Set up networking

see info in this article here Configuring Bridged Mode Networking

This is likely already configured for the VM as it’s a he VM file. It should be set to "Bridged (Advanced)."

Make sure it's on the right Ethernet interview. You can find them listed running this command networksetup -listallhardwareports

Check the vm's ip address with hostname -I or ip addr | more -- give more info on IP address

Test locally

go to http://:8123 in browser login with homeassistant login it will take some time for Homeassistant to start up again

[Set up remote access](## Set up remote access)

see section below on Cloudflare setup it should automatically come up

Set up UTM to run on start up

Remote Control | UTM Documentation.

  1. Find or create a shortcut to start the vm. I have one named "Home Assistant" which is my VM name already.
  2. Select add to dock
  3. Show in Finder
  4. Drag the item to the login items in system preferences

To disable Home Assistant on Mac

  1. shutdown the home assistant server
  2. remove the login item shortcut from system preferences.

Common Linux Commands

As root

reboot now - reboot vm shutdown - shutdown

Configure

Getting started with the home assistant app for MAC os | JuanMTech (838) HOW TO Connect Home Assistant to Apple Homekit - YouTube

Important security setup recommendations. 5 ESSENTIAL Tips for Security on Home Assistant - YouTube

Devices to configure

Top Add Ons to install

Integrations to consider

The Best Home Assistant Addons And Repos Of 2023 - Gadget-Freakz.com

Automatically Backing up Home Assistant

Great article outlining options: Home Assistant Backup Methods & Best Practices - SmartHomeScene

For me it's OneDrive using lavinir/hassio-onedrive-backup

Other info: How do I back-up Home Assistant? – Maartendamen.com

Set up remote access

Cloudflare tunnel approach The Easiest Free Way To Do Home Assistant Remote Access! - YouTube brenner-tobias/ha-addons: Repository for Home Assistant Add-Ons How tos · brenner-tobias/addon-cloudflared Wiki

General tunnel creation instructions

Great additional advice on the risks of Cloudflare tunnels

TODO: look into stronger authentication approaches for the tunnel.

Dynamic DNS + port forwarding approach (not recommended) Home Assistant Remote Access for FREE - DuckDNS + LetsEncrypt + Single URL - YouTube Home Assistant 101: Setting up Remote Access - YouTube

Dashboard configuration

Great video on creating a dashboard - easy vs hard

Automation approaches

Tutorials and info Create a Basic Automation in Home Assistant Easy home Assistant Notifications using Alerts! - YouTube I was wrong about Home Assistant Automations - YouTube 5 Home Assistant Built-In Integrations You Probably Should be Using - YouTube Easy Notifications with Alerts — Slacker Labs HOW TO Connect Home Assistant to Apple Homekit - YouTube Getting started with the home assistant app for MAC os | JuanMTech See types of triggers at Automation Trigger - Home Assistant

Useful tips

Running automation every time period - use time pattern - How Do Time Patterns Work in Home Assistant - Home Automation Insider

Finding your variable - use dev tools and look at states. You can test code in Templates. Example here is the powerwall charge state class. Call its state to get the charing percentage. See State Objects - Home Assistant for attributes. {{states.sensor.sensor-name.state}} {{states.sensor.powerwall_charge}} {{states.sensor.powerwall_charge.state}}

Example: {{states.sensor.powerwall_charge.name}} is at {{states.sensor.powerwall_charge.state}} {{states.sensor.powerwall_charge.attributes.unit_of_measurement}} {{states.binary_sensor.powerwall_charging.name}} is {{states.binary_sensor.powerwall_charging.state}} ({{states.sensor.powerwall_battery_now.state}} {{states.sensor.powerwall_battery_now.attributes.unit_of_measurement}}) Result: Powerwall Charge is at 58 % Powerwall Charging is on (-2.29 kW)

Raycast plugin

The Raycast Store: Home Assistant plugin allos you to control Home Assistant from the Raycast app. It provides a clean interface to view entities, trigger automations, and more.

It is extremely slow loading via the extrenal URL, so configure access via the local URL. Otherwise follow the instructions included with the plugin.

You can search entities and even change them. For example I can increase or decrease the thermostat by 0.5 degrees.

Tesla Configuration info

When configuring any energy cards with Tesla sensors these mean the following:

  • Now - current energy usage (+ or -)

  • Export - energy the device is outputting

  • Import - energy the device is consuming

  • Powerwall Battery = battery

  • Powerwall Solar = solar

  • Powerwall Site = grid (i.e. energy using or exporting to the grid)

  • Powerwall Load = Home (i.e. the load from your home)

battery: entity: sensor.powerwall_battery_now state_of_charge: sensor.powerwall_charge display_state: two_way grid: entity: sensor.powerwall_site_now solar: entity: sensor.powerwall_solar_now display_zero_state: true home: entity: sensor.powerwall_load_now

From Using Tesla Powerwall Data on the HA Energy Dashboard - Third party integrations - Home Assistant Community Here’s what I did after upgrading to Home Assistant 2019.9 45

  • Grid Consumption: Powerwall Site Import
  • Return to grid: Powerwall Site Export
  • Solar Production: Powerwall Solar Export
  • Home Battery Storage:
    • Energy going in to the battery (kWh): Powerwall Battery Import
    • Energy coming out of the battery (kWh): Powerwall Battery Export

More info on Powerwall

Best power distribution card I've found. Requires HACS. ulic75/power-flow-card: A power distribution card inspired by the official Energy Distribution card for Home Assistant

Forecast Solar configuration

Forecast.Solar - Home Assistant

  • Put in the kW capacity of your solar system in watts.
  • To calculate your azimuth see - find_your_azimuth [Forecast.Solar]
    • suncalc.org azimuth for me is 66.88
    • Openstreet Maps azimuth for me is 303 but I think I did this wrong
  • declination - got from my Tesla plans - 18

Weather

Recommend National Weather Service Use any number for the API key - reference: NWS Integration API Key - Where to obtain ley? - Configuration - Home Assistant Community

Mushroom dashboard Cards

Take a look at the additional cards here: lovelace-mushroom/docs/cards/template.md at main · piitaya/lovelace-mushroom

More automation tutorials

Potential Automations

Automations to explore

Notification options

sensor.powerwall_charge

Nintendo Switch integration

There is no official integration for Nintendo Switch but these seem promising/interesting.

Advice on Templates

Mastering Home Assistant Templates: A Beginner's Guide - YouTube Mastering Home Assistant Templates: Intro to Date and Time - YouTube

References