Fundamental setup of sensors, data inputs and more ; full support for spark fun weather shield (see repo for adjusted ino sketch that makes it work with home-assistant.io)

This commit is contained in:
KemoNine 2019-05-04 00:23:34 +00:00
parent 2dccda89dd
commit 9e00d312ee
22 changed files with 607 additions and 308 deletions

View File

@ -7,3 +7,11 @@ Notes and information about my [home-automation.io](https://www.home-automation.
Unless otherwise stated the contents of this repository are licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](LICENSE.txt). Unless otherwise stated the contents of this repository are licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](LICENSE.txt).
![cc-by-nc-sa](cc-by-nc-sa.png) ![cc-by-nc-sa](cc-by-nc-sa.png)
# Additional Credits
Large portions of this repo and config were adapted from the following sources.
- [https://github.com/renemarc/home-assistant-config/](https://github.com/renemarc/home-assistant-config/)
- [https://github.com/stanvx/Home-Assistant-Configuration](https://github.com/stanvx/Home-Assistant-Configuration)
- [https://www.awesome-ha.com/](https://www.awesome-ha.com/)

View File

@ -1,16 +1,18 @@
/* /*
Weather Shield Example Weather Shield Example
By: Nathan Seidle By: Nathan Seidle
SparkFun Electronics SparkFun Electronics
Date: June 10th, 2016 Date: June 10th, 2016
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license). License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
This example prints the current humidity, air pressure, temperature and light levels. This example prints the current humidity, air pressure, temperature and light levels.
The weather shield is capable of a lot. Be sure to checkout the other more advanced examples for creating The weather shield is capable of a lot. Be sure to checkout the other more advanced examples for creating
your own weather station. your own weather station.
*/ */
#include <ArduinoJson.h>
#include <Wire.h> //I2C needed for sensors #include <Wire.h> //I2C needed for sensors
#include "SparkFunMPL3115A2.h" //Pressure sensor - Search "SparkFun MPL3115" and install from Library Manager #include "SparkFunMPL3115A2.h" //Pressure sensor - Search "SparkFun MPL3115" and install from Library Manager
@ -35,7 +37,6 @@ long lastSecond; //The millis counter to see when a second rolls by
void setup() void setup()
{ {
Serial.begin(9600); Serial.begin(9600);
Serial.println("Weather Shield Example");
pinMode(STAT_BLUE, OUTPUT); //Status LED Blue pinMode(STAT_BLUE, OUTPUT); //Status LED Blue
pinMode(STAT_GREEN, OUTPUT); //Status LED Green pinMode(STAT_GREEN, OUTPUT); //Status LED Green
@ -54,17 +55,17 @@ void setup()
lastSecond = millis(); lastSecond = millis();
Serial.println("Weather Shield online!"); digitalWrite(STAT_GREEN, HIGH); //Signal online / active status
} }
void loop() void loop()
{ {
//Print readings every second //Print readings every 10 seconds
if (millis() - lastSecond >= 1000) if (millis() - lastSecond >= 10000)
{ {
digitalWrite(STAT_BLUE, HIGH); //Blink stat LED digitalWrite(STAT_BLUE, HIGH); //Blink stat LED
lastSecond += 1000; lastSecond += 10000;
//Check Humidity Sensor //Check Humidity Sensor
float humidity = myHumidity.readHumidity(); float humidity = myHumidity.readHumidity();
@ -74,7 +75,7 @@ void loop()
Serial.println("I2C communication to sensors is not working. Check solder connections."); Serial.println("I2C communication to sensors is not working. Check solder connections.");
//Try re-initializing the I2C comm and the sensors //Try re-initializing the I2C comm and the sensors
myPressure.begin(); myPressure.begin();
myPressure.setModeBarometer(); myPressure.setModeBarometer();
myPressure.setOversampleRate(7); myPressure.setOversampleRate(7);
myPressure.enableEventFlags(); myPressure.enableEventFlags();
@ -82,38 +83,36 @@ void loop()
} }
else else
{ {
Serial.print("Humidity = "); DynamicJsonDocument jsonBuffer(1024);
Serial.print(humidity);
Serial.print("%,"); jsonBuffer["humidity_percent"] = humidity; // %
float temp_h = myHumidity.readTemperature(); float temp_h = myHumidity.readTemperature();
Serial.print(" temp_h = "); jsonBuffer["temp_c"] = temp_h; // C
Serial.print(temp_h, 2);
Serial.print("C,");
//Check Pressure Sensor //Check Pressure Sensor
float pressure = myPressure.readPressure(); float pressure = myPressure.readPressure();
Serial.print(" Pressure = "); jsonBuffer["pressure_pa"] = pressure; // Pa
Serial.print(pressure);
Serial.print("Pa,");
//Check tempf from pressure sensor //Check tempf from pressure sensor
float tempf = myPressure.readTempF(); float tempf = myPressure.readTempF();
Serial.print(" temp_p = "); jsonBuffer["temp_f"] = tempf; // F
Serial.print(tempf, 2);
Serial.print("F,");
//Heat Index
float hi = heatIndex(tempf, humidity);
jsonBuffer["hi_f"] = hi; // F
jsonBuffer["hi_c"] = convertFtoC(hi); // C
//Check light sensor //Check light sensor
float light_lvl = get_light_level(); float light_lvl = get_light_level();
Serial.print(" light_lvl = "); jsonBuffer["light_lvl_v"] = light_lvl; // V
Serial.print(light_lvl);
Serial.print("V,");
//Check batt level //Check batt level
float batt_lvl = get_battery_level(); float batt_lvl = get_battery_level();
Serial.print(" VinPin = "); jsonBuffer["batt_lvl_v"] = batt_lvl; // V
Serial.print(batt_lvl);
Serial.print("V");
// Print json sensor data
serializeJson(jsonBuffer, Serial);
Serial.println(); Serial.println();
} }
@ -156,3 +155,32 @@ float get_battery_level()
return (rawVoltage); return (rawVoltage);
} }
float convertFtoC(float f) {
return (f - 32) * 0.55555;
}
float heatIndex(float temperature, float percentHumidity)
{
float hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (percentHumidity * 0.094));
if (hi > 79) {
hi = -42.379 +
2.04901523 * temperature +
10.14333127 * percentHumidity +
-0.22475541 * temperature * percentHumidity +
-0.00683783 * pow(temperature, 2) +
-0.05481717 * pow(percentHumidity, 2) +
0.00122874 * pow(temperature, 2) * percentHumidity +
0.00085282 * temperature * pow(percentHumidity, 2) +
-0.00000199 * pow(temperature, 2) * pow(percentHumidity, 2);
if ((percentHumidity < 13) && (temperature >= 80.0) && (temperature <= 112.0))
hi -= ((13.0 - percentHumidity) * 0.25) * sqrt((17.0 - abs(temperature - 95.0)) * 0.05882);
else if ((percentHumidity > 85.0) && (temperature >= 80.0) && (temperature <= 87.0))
hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2);
}
return hi;
}

3
cameras/README.md Normal file
View File

@ -0,0 +1,3 @@
# Cameras
Various configs for different cameras deployed on the network.

6
cameras/unifi_video.yaml Normal file
View File

@ -0,0 +1,6 @@
- platform: uvc
nvr: !secret unifi_video_nvr
port: !secret unifi_video_port
key: !secret unifi_video_api_key
password: !secret unifi_video_camera_password
ssl: true

View File

@ -1,228 +1,203 @@
# Enables Default Home Assistant Components # Setup basic Home Assistant information
default_config: homeassistant:
name: !secret zone_home_name
# Enables Person Component latitude: !secret zone_home_latitude
person: longitude: !secret zone_home_longitude
elevation: !secret zone_home_elevation
# Enables System Health unit_system: imperial # metric
system_health: time_zone: !secret homeassistant_time_zone
customize_domain: {}
# Cameras customize_glob: {}
# @link https://home-assistant.io/components/camera/ whitelist_external_dirs:
#camera: !include_dir_merge_list cameras/ - !secret homeassistant_whitelist_config
# Enable the configuration UI # Database recorder
# @link https://home-assistant.io/components/config/ recorder:
config: db_url: !secret recorder_db_url
purge_keep_days: 90
purge_interval: 1
# Counters
# @link https://www.home-assistant.io/components/counter/
#counter: !include misc/counters.yaml # Log some details
logger:
default: warning
# Enable the UI customizer logs:
# @link https://github.com/andrey-git/home-assistant-customizer homeassistant.components.device_tracker.unifi: fatal # When Unifi Controller is temporarily unreachable.
# customizer: pyunifi.controller: error # When Unifi Controller is temporarily unreachable.
# custom_ui: local
# Check for available updates
# Device trackers # Note: This component will send some information about your system to
# @link https://home-assistant.io/components/device_tracker/ # the developers to assist with development of Home Assistant.
#device_tracker: !include misc/device_trackers.yaml # Optionally allow Home Assistant developers to focus on popular components.
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
# https://home-assistant.io/components/updater/
# Discover some devices automatically updater:
# @link https://home-assistant.io/components/discovery/ include_used_components: true
discovery:
ignore:
- google_cast # MQTT Integration
# https://home-assistant.io/components/mqtt/
#mqtt:
# Displays # broker: !secret mqtt_broker
# @see /custom_components/display/ # port: !secret mqtt_port
# @link https://github.com/daemondazz/homeassistant-displays # username: !secret mqtt_username
#display: !include misc/displays.yaml # password: !secret mqtt_password
# birth_message:
# topic: 'hass/status'
# Enable the official UI # payload: 'online'
# @link https://home-assistant.io/components/frontend/ # will_message:
frontend: # topic: 'hass/status'
# javascript_version: latest # payload: 'offline'
# extra_html_url:
# - /local/custom_ui/state-card-custom-ui.html
# - /local/custom_ui/state-card-hline.html # ZWave integration
# - /local/custom_ui/state-card-value_only.html # https://home-assistant.io/docs/z-wave/adding/
# extra_html_url_es5: # https://home-assistant.io/docs/z-wave/
# - /local/custom_ui/state-card-custom-ui-es5.html # https://home-assistant.io/components/zwave/
# - /local/custom_ui/state-card-hline.html #zwave:
# - /local/custom_ui/state-card-value_only.html # usb_path: /dev/ttyACM0
# themes: !include_dir_named themes/ # network_key: !secret zwave_network_key
# Combine entities into groups and organize UI # Enable the web server
# @link https://home-assistant.io/components/group/ # `cors_allowed_origins` includes the domain:port for AppDaemon.
#group: !include_dir_merge_named groups/ # https://home-assistant.io/components/http/
http:
api_password: !secret http_password
# Enable support for tracking state changes over time base_url: !secret http_base_url
# @link https://home-assistant.io/components/history/
history:
# Enable the official UI
# https://home-assistant.io/components/frontend/
# Setup basic Home Assistant information frontend:
homeassistant: # javascript_version: latest
name: !secret zone_home_name # extra_html_url:
latitude: !secret zone_home_latitude # - /local/custom_ui/state-card-custom-ui.html
longitude: !secret zone_home_longitude # - /local/custom_ui/state-card-hline.html
elevation: !secret zone_home_elevation # - /local/custom_ui/state-card-value_only.html
unit_system: imperial # metric # extra_html_url_es5:
time_zone: !secret homeassistant_time_zone # - /local/custom_ui/state-card-custom-ui-es5.html
#customize_glob: !include customize_glob.yaml # - /local/custom_ui/state-card-hline.html
#customize: !include customize.yaml # - /local/custom_ui/state-card-value_only.html
whitelist_external_dirs: # themes: !include_dir_named themes/
- !secret homeassistant_whitelist_config
# Enable the UI customizer
# Enable the web server # https://github.com/andrey-git/home-assistant-customizer
# `cors_allowed_origins` includes the domain:port for AppDaemon. #customizer:
# @link https://home-assistant.io/components/http/ # custom_ui: local
http:
api_password: !secret http_password
base_url: !secret http_base_url # Notification services
# https://home-assistant.io/components/notify/
#notify: !include_dir_merge_list notifications/
# Input booleans
# @link https://home-assistant.io/components/input_boolean/
#input_boolean: !include misc/input_booleans.yaml # Enables Default Home Assistant Components
default_config:
# Lists of selectable values
# @link https://home-assistant.io/components/input_select/ # Enables Person Component
#input_select: !include misc/input_selects.yaml person:
# LIFX # Combine entities into groups and organize UI
# @link https://www.home-assistant.io/components/lifx/ # https://home-assistant.io/components/group/
#lifx: !include misc/lifx.yaml #group: !include_dir_merge_named groups/
# Zones
# Lights # https://home-assistant.io/components/zone/
# @link https://home-assistant.io/components/light/ #zone: !include misc/zones.yaml
#light: !include_dir_merge_list lights/
# Variables
# View all events in a logbook # @see /custom_components/variable.py
# @link https://home-assistant.io/components/logbook/ # https://github.com/rogro82/hass-variables
logbook: #variable: !include misc/variables.yaml
# Log some details # Counters
# @link https://home-assistant.io/components/logger/ # https://www.home-assistant.io/components/counter/
logger: #counter: !include misc/counters.yaml
default: warning
# logs:
# aiohttp.server: critical # EBOX newer component bug. # Input booleans
# custom_components.display: critical # When tablet is offline. # https://home-assistant.io/components/input_boolean/
# custom_components.light.lightpack: critical # When Lightpack is offline. #input_boolean: !include misc/input_booleans.yaml
# homeassistant.components.device_tracker.unifi: fatal # When Unifi Controller is temporarily unreachable.
# homeassistant.components.media_player.plex: fatal # When Plex is offline.
# homeassistant.components.switch.tplink: error # When switch is unplugged. # Lists of selectable values
# pyunifi.controller: error # When Unifi Controller is temporarily unreachable. # https://home-assistant.io/components/input_select/
#input_select: !include misc/input_selects.yaml
# Media players
# @link https://home-assistant.io/components/media_player/ # Enables System Health
#media_player: !include misc/media_players.yaml system_health:
# MQTT Integration # Enable the configuration UI
# @link https://home-assistant.io/components/mqtt/ config:
#mqtt:
# broker: !secret mqtt_broker
# port: !secret mqtt_port # Enable support for tracking state changes over time
# username: !secret mqtt_username history:
# password: !secret mqtt_password
# birth_message:
# topic: 'hass/status' # View all events in a logbook
# payload: 'online' logbook:
# will_message: exclude:
# topic: 'hass/status' entities:
# payload: 'offline' - sensor.uptime
- sensor.time
- sensor.date
# Notification services - sensor.date_time
# @link https://home-assistant.io/components/notify/ - sensor.date_time_iso
#notify: !include_dir_merge_list notifications/ - sensor.time_date
- sensor.time_utc
- sensor.beat
# Database recorder - sensor.pcf8523
# Limit the number of tracked entities and length of history.
# @link https://home-assistant.io/components/recorder/
#recorder: !include misc/recorder.yaml # Scenes
recorder: # https://home-assistant.io/components/scene/
db_url: !secret recorder_db_url #scene: !include misc/scenes.yaml
purge_keep_days: 90
purge_interval: 1
# Discover some devices automatically
discovery:
# Scenes ignore:
# @link https://home-assistant.io/components/scene/ - google_cast
#scene: !include misc/scenes.yaml - harmony
# Scripts # Device Trackers
# @link https://home-assistant.io/components/script/ device_tracker: !include_dir_merge_list device_trackers/
#script: !include_dir_named scripts/
# Cameras
# Sensors camera: !include_dir_merge_list cameras/
# @link https://home-assistant.io/components/sensor/
#sensor: !include_dir_merge_list sensors/
# Displays
# @see /custom_components/display/
# Shell commands # https://github.com/daemondazz/homeassistant-displays
# @link https://home-assistant.io/components/shell_command/ #display: !include misc/displays.yaml
#shell_command: !include misc/shell_commands.yaml
# Sensors
# Track the sun sensor: !include_dir_merge_list sensors/
# @link https://home-assistant.io/components/sun/
sun: # Track the sun
sun:
# Switches
# @link https://home-assistant.io/components/switch/ # Cameras
#switch: !include_dir_merge_list switches/ # https://home-assistant.io/components/camera/
#camera: !include_dir_merge_list cameras/
# Check for available updates
# Note: This component will send some information about your system to # Media Devices
# the developers to assist with development of Home Assistant. cast: !include media/cast.yaml
# Optionally allow Home Assistant developers to focus on popular components.
# @link https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
# @link https://home-assistant.io/components/updater/
updater:
include_used_components: true
# Variables
# @see /custom_components/variable.py
# @link https://github.com/rogro82/hass-variables
#variable: !include misc/variables.yaml
# Zones
# @link https://home-assistant.io/components/zone/
#zone: !include misc/zones.yaml
# ZWave integration
# @link https://home-assistant.io/docs/z-wave/adding/
# @link https://home-assistant.io/docs/z-wave/
# @link https://home-assistant.io/components/zwave/
#zwave:
# usb_path: /dev/ttyACM0
# network_key: !secret zwave_network_key

View File

@ -0,0 +1,3 @@
# Device Trackers
Various configs for tracking devices.

View File

@ -0,0 +1,25 @@
- platform: unifi
host: !secret unifi_host
port: !secret unifi_port
username: !secret unifi_username
password: !secret unifi_password
ssid_filter:
!secret unifi_ssids
monitored_conditions:
- _id
- assoc_time
- authorized
- bssid
- channel
- essid
- first_seen
- hostname
- ip
- last_seen
- latest_assoc_time
- mac
- name
- signal
- site_id
- user_id
- usergroup_id

3
docker/README.md Normal file
View File

@ -0,0 +1,3 @@
# Docker
Various run scripts for deploying Home-Automation.io on arm boards. Raspberry Pi and others are supported.

View File

@ -4,6 +4,10 @@
# create role homeautomation nosuperuser nocreatedb nocreaterole password 'badPassword'; # create role homeautomation nosuperuser nocreatedb nocreaterole password 'badPassword';
# create database homeautomation owner homeautomation; # create database homeautomation owner homeautomation;
# --device /dev/ttyACM0:/dev/ttyACM0
# --device /dev/rtc1:/dev/rtc1
# -v /sys/class:/sys/class
ARCH=`arch` ARCH=`arch`
if [ $ARCH == "aarch64" ] if [ $ARCH == "aarch64" ]
then then
@ -12,16 +16,20 @@ else
REPO="homeassistant/raspberrypi3-homeassistant" REPO="homeassistant/raspberrypi3-homeassistant"
fi fi
touch /var/home-assistant/known_devices.yaml
docker container stop home-assistant docker container stop home-assistant
docker container rm home-assistant docker container rm home-assistant
docker run -it --name home-assistant \ docker run -it --name home-assistant \
--restart unless-stopped \ --restart unless-stopped \
--network docker-private \ --network docker-private \
--device /dev/ttyACM0:/dev/ttyACM0 \
-e DEBUG=1 \ -e DEBUG=1 \
-l traefik.frontend.rule=Host:home-automation.domain.tld \ -l traefik.frontend.rule=Host:home-automation.domain.tld \
-l traefik.frontend.passHostHeader=true \ -l traefik.frontend.passHostHeader=true \
-l traefik.port=8123 \ -l traefik.port=8123 \
-v /sys/class:/sys/class \
-v /etc/localtime:/etc/localtime:ro \ -v /etc/localtime:/etc/localtime:ro \
-v /var/home-assistant:/config \ -v /var/home-assistant:/config \
${REPO}:latest ${REPO}:latest

View File

@ -1,18 +1,9 @@
## Home-Automation.io ## Home-Automation.io
- https://www.home-assistant.io/components/recorder/
- https://www.home-assistant.io/
- https://www.home-assistant.io/docs/installation/docker/
- https://www.home-assistant.io/docs/ecosystem/backup/backup_usb/
- https://www.home-assistant.io/docs/z-wave/ - https://www.home-assistant.io/docs/z-wave/
- https://www.home-assistant.io/docs/z-wave/installation - https://www.home-assistant.io/docs/z-wave/installation
- https://www.home-assistant.io/docs/z-wave/adding - https://www.home-assistant.io/docs/z-wave/adding
- https://community.home-assistant.io/t/real-time-clock/91699
- https://www.home-assistant.io/components/time_date/
- https://www.home-assistant.io/components/worldclock/
- https://www.home-assistant.io/components/timer/ - https://www.home-assistant.io/components/timer/
- https://www.home-assistant.io/components/persistent_notification/ - https://www.home-assistant.io/components/persistent_notification/
- https://community.home-assistant.io/t/medication-reminder/18110 - https://community.home-assistant.io/t/medication-reminder/18110
@ -20,53 +11,20 @@
- https://github.com/pkozul/ha-floorplan - https://github.com/pkozul/ha-floorplan
- https://github.com/thomasloven/hass-fontawesome - https://github.com/thomasloven/hass-fontawesome
- https://www.home-assistant.io/components/caldav/ - https://www.home-assistant.io/components/caldav/
- https://www.home-assistant.io/components/weather.darksky/ - http://davmail.sourceforge.net/
- https://www.home-assistant.io/components/cloudflare/
- https://www.home-assistant.io/components/command_line/
- https://www.home-assistant.io/components/darksky/
- https://www.home-assistant.io/components/generic/ - https://www.home-assistant.io/components/generic/
- https://www.home-assistant.io/components/input_datetime/ - https://www.home-assistant.io/components/input_datetime/
- https://www.home-assistant.io/components/input_boolean/ - https://www.home-assistant.io/components/input_boolean/
- https://www.home-assistant.io/components/input_select/ - https://www.home-assistant.io/components/input_select/
- https://www.home-assistant.io/components/linux_battery/
- https://www.home-assistant.io/components/logbook/
- https://www.home-assistant.io/components/matrix/ - https://www.home-assistant.io/components/matrix/
- https://www.home-assistant.io/components/miflora/ - https://www.home-assistant.io/components/miflora/
- https://www.home-assistant.io/components/nfandroidtv/
- https://www.home-assistant.io/components/plant/ - https://www.home-assistant.io/components/plant/
- https://www.home-assistant.io/components/pollen/
- https://www.home-assistant.io/components/smtp/ - https://www.home-assistant.io/components/smtp/
- https://www.home-assistant.io/components/uvc/
- https://www.home-assistant.io/components/unifi/
- https://www.home-assistant.io/components/ups/ - https://www.home-assistant.io/components/ups/
- https://www.home-assistant.io/components/fedex/ - https://www.home-assistant.io/components/fedex/
- https://www.home-assistant.io/components/usps/ - https://www.home-assistant.io/components/usps/
### Samples
- https://github.com/renemarc/home-assistant-config/
- https://github.com/stanvx/Home-Assistant-Configuration
- https://www.awesome-ha.com/
## Simple Sensor Array
- https://learn.sparkfun.com/tutorials/arduino-weather-shield-hookup-guide-v12
- http://pinoutguide.com/images/arduino/micro.png
- https://strawberry-linux.com/pub/Weather%20Shield.pdf
- https://cdn.sparkfun.com/assets/1/1/4/d/6/Weather_Shield_V12.pdf
- https://www.arduino.cc/en/main/software#download
- https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino
- https://github.com/sparkfun/Weather_Shield
https://www.home-assistant.io/components/serial/
Humidity = 45.52%, temp_h = 22.58C, Pressure = 99065.00Pa, temp_p = 71.37F, light_lvl = 4.20V, VinPin = 0.00V
## Networked Devices
- https://www.home-assistant.io/components/harmony/
- https://www.home-assistant.io/components/cast/
## Setup Kiosk For HASS ## Setup Kiosk For HASS

View File

@ -1,16 +1,37 @@
#
# Home Assistant basic info # Home Assistant basic info
#
zone_home_name: "Some Name" zone_home_name: "Some Name"
zone_home_latitude: 0.0 zone_home_latitude: 0.0
zone_home_longitude: 0.0 zone_home_longitude: 0.0
zone_home_elevation: 0.0 zone_home_elevation: 0.0
zip_code: "00544"
homeassistant_time_zone: America/Eastern homeassistant_time_zone: America/Eastern
homeassistant_whitelist_config: ./ homeassistant_whitelist_config: ./
http_base_url: "" http_base_url: ""
http_password: "" http_password: ""
#
# Database Setup # Database Setup
#
recorder_db_url: "postgresql://user:password@SERVER_IP/DB_NAME" recorder_db_url: "postgresql://user:password@SERVER_IP/DB_NAME"
# API Keys
dark_sky_api_key: YOUR_API_KEY_HERE
# Media Devices
google_casts:
- host: 172.16.0.1
- host: 10.0.0.1
- host: 192.168.0.1
# UniFi Config
unifi_host: unifi.domain.tld
unifi_port: 8443
unifi_username: username
unifi_password: password
unifi_ssids:
- ssid_1
- ssid_2
# UniFi Video Config
unifi_video_nvr: unifivideo.domain.tld
unifi_video_port: 7080
unifi_video_api_key: API_KEY
unifi_video_camera_password: ubnt

3
sensors/README.md Normal file
View File

@ -0,0 +1,3 @@
# Sensors
Various sensor configurations. Each of the ```yaml``` files is a *different* sensor.

14
sensors/pollen.yaml Normal file
View File

@ -0,0 +1,14 @@
- platform: pollen
zip_code: !secret zip_code
monitored_conditions:
- allergy_average_forecasted
- allergy_average_historical
- allergy_index_today
- allergy_index_tomorrow
- allergy_index_yesterday
- asthma_average_forecasted
- asthma_average_historical
- asthma_index_today
- asthma_index_tomorrow
- asthma_index_yesterday
- disease_average_forecasted

4
sensors/rtc1.yaml Normal file
View File

@ -0,0 +1,4 @@
- platform: command_line
name: "pcf8523"
command: 'hwclock -r -f /dev/rtc1'
scan_interval: 3600

View File

@ -0,0 +1,3 @@
# Sensor Scripts
A collection of scripts for building more robust command line sensors to fill in gaps in the upstream components.

35
sensors/scripts/ac_sopine.py Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env python3
from distutils.util import strtobool
PATH_PRESENT = '/sys/class/power_supply/axp813-ac/present'
PATH_ONLINE = '/sys/class/power_supply/axp813-ac/online'
PATH_TYPE = '/sys/class/power_supply/axp813-ac/type'
PATH_HEALTH = '/sys/class/power_supply/axp813-ac/health'
PATH_INPUT_CURRENT_LIMIT = '/sys/class/power_supply/axp813-ac/input_current_limit'
PATH_VOLTAGE_MIN = '/sys/class/power_supply/axp813-ac/voltage_min'
present = False
with open(PATH_PRESENT, 'r') as f:
present = bool(strtobool(f.read().strip()))
online = False
with open(PATH_ONLINE, 'r') as f:
online = bool(strtobool(f.read().strip()))
result = {'present': present, 'online': online}
if present:
with open(PATH_TYPE, 'r') as f:
result['type'] = f.read().strip()
with open(PATH_HEALTH,'r') as f:
result['health'] = f.read().strip()
with open(PATH_INPUT_CURRENT_LIMIT, 'r') as f:
current = f.read().strip()
result['current'] = (int(current)/10000.0)*0.01
with open(PATH_VOLTAGE_MIN, 'r') as f:
voltage = f.read().strip()
result['voltage'] = (int(voltage)/10000.0)*0.01
import json
print(json.dumps(result))

View File

@ -0,0 +1,33 @@
#!/usr/bin/env python3
from distutils.util import strtobool
PATH_PRESENT = '/sys/class/power_supply/axp20x-battery/present'
PATH_STATUS = '/sys/class/power_supply/axp20x-battery/status'
PATH_VOLTAGE = '/sys/class/power_supply/axp20x-battery/voltage_now'
PATH_CURRENT = '/sys/class/power_supply/axp20x-battery/current_now'
PATH_CAPACITY = '/sys/class/power_supply/axp20x-battery/capacity'
PATH_HEALTH = '/sys/class/power_supply/axp20x-battery/health'
present = False
with open(PATH_PRESENT, 'r') as f:
present = bool(strtobool(f.read().strip()))
result = {'present': present}
if present:
with open(PATH_STATUS,'r') as f:
result['status'] = f.read().strip()
with open(PATH_VOLTAGE, 'r') as f:
voltage = f.read().strip()
result['voltage'] = (int(voltage)/10000.0)*0.01
with open(PATH_CURRENT, 'r') as f:
current = f.read().strip()
result['current'] = int(current)/1000
with open(PATH_CAPACITY, 'r') as f:
result['capacity'] = f.read().strip()
with open(PATH_HEALTH, 'r') as f:
result['health'] = f.read().strip()
import json
print(json.dumps(result))

32
sensors/sopine-ac.yaml Normal file
View File

@ -0,0 +1,32 @@
- platform: command_line
name: "sopine_ac"
command: '/config/sensors/scripts/ac_sopine.py'
json_attributes:
- present
- voltage
- online
- health
- type
- current
- platform: template
sensors:
sopine_ac_present:
entity_id: "sensor.sopine_ac"
value_template: "{{ state_attr('sensor.sopine_ac', 'present') }}"
sopine_ac_voltage:
entity_id: "sensor.sopine_ac"
value_template: "{{ state_attr('sensor.sopine_ac', 'voltage') }}"
sopine_ac_online:
entity_id: "sensor.sopine_ac"
value_template: "{{ state_attr('sensor.sopine_ac', 'online') }}"
sopine_ac_health:
entity_id: "sensor.sopine_ac"
value_template: "{{ state_attr('sensor.sopine_ac', 'health') }}"
sopine_ac_type:
entity_id: "sensor.sopine_ac"
value_template: "{{ state_attr('sensor.sopine_ac', 'type') }}"
sopine_ac_current:
entity_id: "sensor.sopine_ac"
value_template: "{{ state_attr('sensor.sopine_ac', 'current') }}"

View File

@ -0,0 +1,34 @@
- platform: command_line
name: "sopine_battery"
command: '/config/sensors/scripts/battery_sopine.py'
json_attributes:
- status
- voltage
- capacity
- present
- current
- health
- platform: template
sensors:
sopine_battery_status:
entity_id: "sensor.sopine_battery"
value_template: "{{ state_attr('sensor.sopine_battery', 'status') }}"
sopine_battery_voltage:
entity_id: "sensor.sopine_battery"
value_template: "{{ state_attr('sensor.sopine_battery', 'voltage') }}"
unit_of_measurement: "V"
sopine_battery_capacity:
entity_id: "sensor.sopine_battery"
value_template: "{{ state_attr('sensor.sopine_battery', 'capacity') }}"
unit_of_measurement: "%"
sopine_battery_present:
entity_id: "sensor.sopine_battery"
value_template: "{{ state_attr('sensor.sopine_battery', 'present') }}"
sopine_battery_current:
entity_id: "sensor.sopine_battery"
value_template: "{{ state_attr('sensor.sopine_battery', 'current') }}"
unit_of_measurement: "A"
sopine_battery_health:
entity_id: "sensor.sopine_battery"
value_template: "{{ state_attr('sensor.sopine_battery', 'health') }}"

View File

@ -0,0 +1,49 @@
# {
# "humidity_percent":45.0025,
# "temp_c":23.00256,
# "pressure_pa":98949.5,
# "temp_f":72.1625,
# "hi_f":71.19387,
# "hi_c":21.77415,
# "light_lvl_v":0.106452,
# "batt_lvl_v":0
#}
- platform: serial
serial_port: /dev/ttyACM0
name: sparkfun_weather_station
- platform: template
sensors:
sparkfun_weather_station_humidity_percent:
entity_id: "sensor.sparkfun_weather_station"
value_template: "{{ state_attr('sensor.sparkfun_weather_station', 'humidity_percent') }}"
unit_of_measurement: "%"
sparkfun_weather_station_temp_c:
entity_id: "sensor.sparkfun_weather_station"
value_template: "{{ state_attr('sensor.sparkfun_weather_station', 'temp_c') }}"
unit_of_measurement: "C"
sparkfun_weather_station_pressure_pa:
entity_id: "sensor.sparkfun_weather_station"
value_template: "{{ state_attr('sensor.sparkfun_weather_station', 'pressure_pa') }}"
unit_of_measurement: "Pa"
sparkfun_weather_station_temp_f:
entity_id: "sensor.sparkfun_weather_station"
value_template: "{{ state_attr('sensor.sparkfun_weather_station', 'temp_f') }}"
unit_of_measurement: "F"
sparkfun_weather_station_hi_f:
entity_id: "sensor.sparkfun_weather_station"
value_template: "{{ state_attr('sensor.sparkfun_weather_station', 'hi_f') }}"
unit_of_measurement: "F"
sparkfun_weather_station_hi_c:
entity_id: "sensor.sparkfun_weather_station"
value_template: "{{ state_attr('sensor.sparkfun_weather_station', 'hi_c') }}"
unit_of_measurement: "C"
sparkfun_weather_station_light_lvl_v:
entity_id: "sensor.sparkfun_weather_station"
value_template: "{{ state_attr('sensor.sparkfun_weather_station', 'light_lvl_v') }}"
unit_of_measurement: "V"
sparkfun_weather_station_batt_lvl_v:
entity_id: "sensor.sparkfun_weather_station"
value_template: "{{ state_attr('sensor.sparkfun_weather_station', 'batt_lvl_v') }}"
unit_of_measurement: "V"

9
sensors/time.yaml Normal file
View File

@ -0,0 +1,9 @@
# Track various times
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'date_time_iso'
- 'time_date'
- 'time_utc'

45
sensors/weather.yaml Normal file
View File

@ -0,0 +1,45 @@
- platform: darksky
api_key: !secret dark_sky_api_key
forecast:
- 0
- 1
- 2
- 3
- 4
- 5
hourly_forecast:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
monitored_conditions:
- summary
- icon
- temperature
- apparent_temperature
- temperature_high
- temperature_low
- humidity
- precip_type
- precip_intensity
- precip_probability
- precip_accumulation
- wind_speed
- wind_gust
- daily_summary
scan_interval:
# At least one of these must be specified:
days: 0
hours: 0
minutes: 30
seconds: 0
milliseconds: 0