Skip to content
This repository has been archived by the owner on May 23, 2020. It is now read-only.

robmarkcole/robins-homeassistant-config

Repository files navigation

My home-assistant configuration files.

HASSIO

I run a hassio on a pi 3.

Motion triggered USB camera

I am using a cheap 10 euro USB webcam with a Motion Hassio addon as described here.

Hue sensors

I have Philips Hue remotes and motion sensors. I wrote a custom component to integrate them here.

Water leak detector

My leak detector is a DIY sensor using micropython, with a writeup on Hackster.

BME680 Temperature, humidity and air quality sensors

CURRENTLY NOT USING: I branched a Pimoroni library for the BME680 to publish data over MQTT, repo here.

Automation to boil my kettle in the morning

I own an Appkettle which is integrated with HA via IFTTT. Write up on Hackster.

Late train notification via Hue lamp

If my train is late, a Hue light turns red. On Hackster.

Elgato HomeKit sensors

My Elgato door sensor cannot be integrated directly into HA since it is HomeKit only. To get around this I use the Homebridge addon for Hassio. See this thread. The same trick works for my Fibaro leak sensor.

MacBook sensor

I have a sensor which is ON when I am using my MacBook. I did this using Hammerspoon as described here.

RF doorbell

I integrate an RF doorbell using an Arduino which relays signals over the serial port, as described here.

Python scripts

I am a big fan of using python_scripts over long YAML automations. I have a dedicated repo here.

Google Cloud SQL recorder

I use a Google cloud SQL database as a recorder, as described here.

Bayesian 'in bed' sensor

My own bayesian 'in bed bayesian sensor' is working nicely after a lot of experimentation. I found that the 'sun below horizon' input wasn't particularly useful, since in the UK at this time of year the sun is setting before 5pm.! Instead I'm using a template sensor which is ON at 'late night'.

- platform: template
  sensors:
    late_night_sensor:
      value_template: >-
          {{ strptime("22:00", "%H%M")  < now().strftime("%H:%M")
             or now().strftime("%H:%M") < strptime("07:00", "%H%M") }}

As a couple of others have done I also have a sensor to detect when there has been no motion in the house for 5 minutes. I implemented that using an input_select and an automation:

- id: '1513346519354'
  alias: House_idle
  trigger:
  - entity_id: binary_sensor.motion_at_home
    for:
      minutes: 5
    from: 'on'
    platform: state
    to: 'off'
  action:
  - data:
      entity_id: input_boolean.house_idle
    service: input_boolean.turn_on

Finally the bayesian sensor is:

- platform: 'bayesian'
  name: 'in_bed_bayesian'
  prior: 0.25
  observations:
    - entity_id: 'input_boolean.house_idle'
      prob_given_true: 0.6
      platform: 'state'
      to_state: 'on'
    - entity_id: 'binary_sensor.late_night_sensor'
      prob_given_true: 0.8
      platform: 'state'
      to_state: 'on'
    - entity_id: 'binary_sensor.motion_at_home'
      prob_given_true: 0.1
      platform: 'state'
      to_state: 'on'
    - entity_id: 'switch.macbook_power'
      prob_given_true: 0.1
      platform: 'state'
      to_state: 'on'
    - entity_id: 'switch.tv'
      prob_given_true: 0.1
      platform: 'state'
      to_state: 'on'

I am using the history statistics component and a template sensor to display the number of hours I spent in bed last night.

- platform: history_stats
  name: Time in bed
  entity_id: binary_sensor.in_bed_bayesian
  state: 'on'
  type: time
  end: '{{ now() }}'
  duration:
    hours: 24

And the template sensor:

- platform: template
  sensors:
    time_in_bed_template:
      friendly_name: 'Time in bed'
      value_template: '{{states.sensor.time_in_bed.attributes.value}}'

Lastly, I wrote a notebook discussing the ideas behind the bayesian sensor, and many thanks to @jlmcgehee21 for all his edits: http://nbviewer.jupyter.org/github/robmarkcole/HASS-data-science/blob/master/Bayesian%20sensor%20tutorial.ipynb

Hassio Add-ons

Try to limit your addons, as too many will make your system unstable.

  1. IDE: https://github.com/hassio-addons/addon-ide
  2. SSH & Web Terminal: https://github.com/hassio-addons/addon-ssh/blob/v3.2.0/README.md
  3. MQTT Server & Web client: https://github.com/hassio-addons/addon-mqtt/blob/master/README.md
  4. Motion camera detection: https://github.com/HerrHofrat/hassio-addons
  5. Glances: https://github.com/hassio-addons/addon-glances
  6. Jupyterlab Lite: https://github.com/hassio-addons/addon-jupyterlab-lite
  7. Log Viewer: https://github.com/hassio-addons/addon-log-viewer