From 5bfa928c36582ed46165bb37bf81afb36ff881e6 Mon Sep 17 00:00:00 2001
From: Erick Hitter <services@ethitter.com>
Date: Sun, 9 Oct 2016 17:51:27 -0700
Subject: [PATCH] Sync wit upstream

4f50cc60
---
 automations/alert-office-cabinet.yaml         | 13 +++++
 automations/apc-notification-not-online.yaml  | 14 +++++
 automations/apc-notification-online.yaml      | 14 +++++
 ...-on.yaml => kitchen-nightlight-on-am.yaml} |  4 +-
 automations/kitchen-nightlight-on-pm.yaml     | 32 +++++++++++
 automations/maybe-an-earthquake.yaml          |  8 +++
 automations/update-notification.yaml          | 11 +++-
 configuration.yaml                            | 26 ++++++++-
 customizations/sensors.yaml                   | 10 ++++
 groups.yaml                                   | 56 +++++++++++--------
 input-sliders.yaml                            |  6 +-
 notifications.yaml                            |  6 +-
 panels-iframe.yaml                            |  8 +++
 scenes/master-bath-dash-on.yaml               |  2 +
 secrets.yaml                                  | 11 +++-
 sensors/apcupsd.yaml                          | 13 +++++
 sensors/fastcom.yaml                          |  8 +--
 sensors/pihole.yaml                           |  4 ++
 sensors/speedtest.yaml                        |  8 +--
 sensors/statistics-eth1-received.yaml         |  3 +
 sensors/statistics-eth1-sent.yaml             |  3 +
 sensors/systemmonitor.yaml                    |  3 +
 sensors/template.yaml                         | 15 +++++
 weblinks.yaml                                 |  4 ++
 wemo.yaml                                     |  2 +-
 25 files changed, 238 insertions(+), 46 deletions(-)
 create mode 100644 automations/alert-office-cabinet.yaml
 create mode 100644 automations/apc-notification-not-online.yaml
 create mode 100644 automations/apc-notification-online.yaml
 rename automations/{kitchen-nightlight-on.yaml => kitchen-nightlight-on-am.yaml} (90%)
 create mode 100644 automations/kitchen-nightlight-on-pm.yaml
 create mode 100644 panels-iframe.yaml
 create mode 100644 sensors/apcupsd.yaml
 create mode 100644 sensors/pihole.yaml
 create mode 100644 sensors/statistics-eth1-received.yaml
 create mode 100644 sensors/statistics-eth1-sent.yaml
 create mode 100644 sensors/template.yaml
 create mode 100644 weblinks.yaml

diff --git a/automations/alert-office-cabinet.yaml b/automations/alert-office-cabinet.yaml
new file mode 100644
index 0000000..d9e2677
--- /dev/null
+++ b/automations/alert-office-cabinet.yaml
@@ -0,0 +1,13 @@
+alias: Slack notification for office cabinet access
+trigger:
+  - platform: state
+    entity_id: binary_sensor.office_cabinet
+    to: "off"
+  - platform: state
+    entity_id: binary_sensor.office_cabinet_door_motion
+    to: "on"
+action:
+  service: notify.slack
+  data:
+    message: ':bellhop_bell: *Office cabinet accessed*'
+    target: '#home'
diff --git a/automations/apc-notification-not-online.yaml b/automations/apc-notification-not-online.yaml
new file mode 100644
index 0000000..20c9ddd
--- /dev/null
+++ b/automations/apc-notification-not-online.yaml
@@ -0,0 +1,14 @@
+alias: Notify when APC not online
+trigger:
+  platform: state
+  entity_id: sensor.ups_status
+  from: "ONLINE"
+action:
+  - service: notify.jabber
+    data:
+      message: "Office APC has status \"{{ states( 'sensor.ups_status' ) }}\""
+      target: !secret jabber_recipient
+  - service: notify.slack
+    data:
+      message: ":exclamation: :battery: Office APC has status \"{{ states( 'sensor.ups_status' ) }}\""
+      target: '#home'
diff --git a/automations/apc-notification-online.yaml b/automations/apc-notification-online.yaml
new file mode 100644
index 0000000..2f752f2
--- /dev/null
+++ b/automations/apc-notification-online.yaml
@@ -0,0 +1,14 @@
+alias: Notify when APC online
+trigger:
+  platform: state
+  entity_id: sensor.ups_status
+  to: "ONLINE"
+action:
+  - service: notify.jabber
+    data:
+      message: 'Office APC is "ONLINE"'
+      target: !secret jabber_recipient
+  - service: notify.slack
+    data:
+      message: ':exclamation: :electric_plug: Office APC is "ONLINE"'
+      target: '#home'
diff --git a/automations/kitchen-nightlight-on.yaml b/automations/kitchen-nightlight-on-am.yaml
similarity index 90%
rename from automations/kitchen-nightlight-on.yaml
rename to automations/kitchen-nightlight-on-am.yaml
index 620b174..951099f 100644
--- a/automations/kitchen-nightlight-on.yaml
+++ b/automations/kitchen-nightlight-on-am.yaml
@@ -1,4 +1,4 @@
-alias: Turn kitchen nightlight on
+alias: Turn kitchen nightlight on AM
 trigger:
   - platform: state
     entity_id: switch.kitchen
@@ -16,8 +16,6 @@ condition:
     - condition: state
       entity_id: sun.sun
       state: 'below_horizon'
-    - condition: time
-      after: '00:15:00'
     - condition: time
       before: '09:00:00'
     - condition: state
diff --git a/automations/kitchen-nightlight-on-pm.yaml b/automations/kitchen-nightlight-on-pm.yaml
new file mode 100644
index 0000000..ad1e138
--- /dev/null
+++ b/automations/kitchen-nightlight-on-pm.yaml
@@ -0,0 +1,32 @@
+alias: Turn kitchen nightlight on PM
+trigger:
+  - platform: state
+    entity_id: switch.kitchen
+  - platform: state
+    entity_id: light.ceiling_fan_1
+  - platform: state
+    entity_id: light.ceiling_fan_2
+  - platform: state
+    entity_id: binary_sensor.kitchen
+  - platform: state
+    entity_id: binary_sensor.lr_motion_sensor_over_utility_closet
+condition:
+  condition: and
+  conditions:
+    - condition: state
+      entity_id: sun.sun
+      state: 'below_horizon'
+    - condition: time
+      after: '21:30:00'
+    - condition: state
+      entity_id: light.ceiling_fan_1
+      state: 'off'
+    - condition: state
+      entity_id: light.ceiling_fan_2
+      state: 'off'
+    - condition: state
+      entity_id: switch.kitchen
+      state: 'off'
+action:
+  service: switch.turn_on
+  entity_id: switch.kitchen_nightlight
diff --git a/automations/maybe-an-earthquake.yaml b/automations/maybe-an-earthquake.yaml
index e04d6cd..803a999 100644
--- a/automations/maybe-an-earthquake.yaml
+++ b/automations/maybe-an-earthquake.yaml
@@ -34,3 +34,11 @@ action:
   - service: notify.jabber
     data:
       message: 'MAYBE AN EARTHQUAKE?!? ALL ACCELEROMETERS ARE ACTIVE.'
+      target: !secret jabber_recipient
+  - service: notify.slack
+    data:
+      message: 'MAYBE AN EARTHQUAKE?!? ALL ACCELEROMETERS ARE ACTIVE.'
+      target:
+        - '#alerts'
+        - '#general'
+        - '#home'
diff --git a/automations/update-notification.yaml b/automations/update-notification.yaml
index 18bbe7e..45a2ada 100644
--- a/automations/update-notification.yaml
+++ b/automations/update-notification.yaml
@@ -3,6 +3,11 @@ trigger:
   platform: state
   entity_id: updater.updater
 action:
-  service: notify.jabber
-  data:
-    message: 'There is a new release of Home Assistant available.'
+  - service: notify.jabber
+    data:
+      message: 'There is a new release of Home Assistant available.'
+      target: !secret jabber_recipient
+  - service: notify.slack
+    data:
+      message: ':exclamation: There is a new release of Home Assistant available.'
+      target: '#home'
diff --git a/configuration.yaml b/configuration.yaml
index f8eac0c..4491e89 100644
--- a/configuration.yaml
+++ b/configuration.yaml
@@ -16,7 +16,7 @@ homeassistant:
 http:
   api_password: !secret api_password
   server_port: 8123
-  ssl_certificate: /home/pi/ssl/cert
+  ssl_certificate: /home/pi/ssl/chain
   ssl_key: /home/pi/ssl/key
 
 zone:
@@ -34,15 +34,31 @@ frontend:
 
 # Set recorder options
 recorder:
-  # purge_days: 365
+  purge_days: 14
   db_url: !secret mysql_recorder
 
+# Also log states to InfluxDB
+influxdb:
+  host: !secret influxdb_host
+  database: !secret influxdb_db
+  username: !secret influxdb_user
+  password: !secret influxdb_password
+  ssl: true
+  verify_ssl: true
+
 # Enables support for tracking state changes over time.
 history:
 
 # Discover some devices automatically
 discovery:
 
+# Logging settings
+logger:
+  default: info # default logging level
+  logs:
+    homeassistant.components.device_tracker.asuswrt: error # suppress IPv6-related warnings; see https://github.com/home-assistant/home-assistant/issues/2814
+    homeassistant.components.sensor.rest: debug
+
 # View all events in a logbook
 logbook:
 
@@ -73,6 +89,12 @@ alarm_control_panel: !include alarm-control-panel.yaml
 
 wemo: !include wemo.yaml
 
+weblink: !include weblinks.yaml
+
+panel_iframe: !include panels-iframe.yaml
+
+apcupsd:
+
 # Display
 group: !include groups.yaml
 
diff --git a/customizations/sensors.yaml b/customizations/sensors.yaml
index 9cb485d..4ce614b 100644
--- a/customizations/sensors.yaml
+++ b/customizations/sensors.yaml
@@ -131,3 +131,13 @@ sensor.pws_wind_kph:
   friendly_name: Wind Speed (kph)
 sensor.pws_wind_mph:
   friendly_name: Wind Speed (mph)
+sensor.time:
+  friendly_name: Time (PT)
+sensor.pihole:
+  friendly_name: Ads Blocked
+sensor.eth1_data_received_mean:
+  friendly_name: Received eth1
+  icon: mdi:server-network
+sensor.eth1_data_sent_mean:
+  friendly_name: Sent eth1
+  icon: mdi:server-network
diff --git a/groups.yaml b/groups.yaml
index 1e523aa..6268207 100644
--- a/groups.yaml
+++ b/groups.yaml
@@ -27,15 +27,21 @@ sensor_view:
     - sensor.speedtest_download
     - sensor.speedtest_upload
     - sensor.fastcom_download
+    - sensor.pihole_queries_today
     - sun.sun
 status_view:
   name: Status
   view: yes
   icon: mdi:chip
   entities:
-    - group.sensor_pi
     - group.time_date
+    - group.sensor_pi
+    - group.sensor_apc
     - group.sensor_battery_levels
+    - sensor.pihole
+    - sensor.pihole_percent_ads_today
+    - sensor.pihole_queries_today
+    - sensor.pihole_domains_blocked
 weather_view:
   name: Weather
   view: yes
@@ -156,40 +162,41 @@ presence:
     - device_tracker.cl_samsung_s5
     - device_tracker.cl_iphone_5
     - device_tracker.green_keys
+time_date:
+  name: Time & Date
+  entities:
+    - sensor.date
+    - sensor.time
+    - sensor.time_utc
 sensor_pi:
   name: Raspberry Pi
   entities:
-    - sensor.cpu
     - sensor.cpu_use
     - sensor.disk_use_
     - sensor.disk_use_varlog
     - sensor.ram_use
     - sensor.ram_free
-#    - sensor.processor_use
     - sensor.swap_use
+    - sensor.swap_free
     - sensor.last_boot
     - sensor.since_last_boot
-    - sensor.received_eth0
-    - sensor.sent_eth0
-    # - sensor.packets_received_eth0
-    # - sensor.packets_sent_eth0
-    - sensor.ipv4_address_eth0
-    - sensor.ipv6_address_eth0
-    - sensor.received_eth1
-    - sensor.sent_eth1
-    # - sensor.packets_received_eth1
-    # - sensor.packets_sent_eth1
-    - sensor.ipv4_address_eth1
-    - sensor.ipv6_address_eth1
-time_date:
-  name: Time & Date
-  entities:
-    - sensor.time
-    - sensor.date
-    - sensor.date_time
-    - sensor.time_date
-    - sensor.time_utc
-    - sensor.beat
+    - sensor.eth1_data_received_mean # Stats sensor to replace sensor.received_eth1
+    - sensor.eth1_data_sent_mean # Stats sensor to replace sensor.sent_eth1
+sensor_apc:
+  name: APC
+  entities:
+    - sensor.ups_status
+    - sensor.ups_load
+    - sensor.ups_time_left
+    - sensor.ups_time_on_battery
+    - sensor.ups_last_transfer
+    - sensor.ups_transfer_count
+    - sensor.ups_battery
+    - sensor.ups_battery_nominal_voltage
+    - sensor.ups_input_voltage
+    - sensor.ups_nominal_input_voltage
+    - sensor.ups_nominal_output_power
+    - sensor.ups_output_voltage
 sensor_battery_levels:
   name: Sensor Battery Levels
   entities:
@@ -240,3 +247,4 @@ wunderground:
     - sensor.pws_visibility_mi
     - sensor.pws_uv
     - sensor.pws_solarradiation
+    - weblink.forecast
diff --git a/input-sliders.yaml b/input-sliders.yaml
index e4aa769..c90683d 100644
--- a/input-sliders.yaml
+++ b/input-sliders.yaml
@@ -1,18 +1,18 @@
 brightness_da:
   name: Brightness
-  initial: 0
+  initial: 1
   min: 1
   max: 255
   step: 1
 brightness_lr:
   name: Brightness
-  initial: 0
+  initial: 1
   min: 1
   max: 255
   step: 1
 brightness_master_bath:
   name: Brightness
-  initial: 0
+  initial: 1
   min: 1
   max: 255
   step: 1
diff --git a/notifications.yaml b/notifications.yaml
index fa47a75..f655b61 100644
--- a/notifications.yaml
+++ b/notifications.yaml
@@ -3,4 +3,8 @@
   sender: !secret jabber_sender
   password: !secret jabber_password
   recipient: !secret jabber_recipient
-  tls: True
+  tls: true
+- name: slack
+  platform: slack
+  api_key: !secret slack_api_key
+  default_channel: '#home'
diff --git a/panels-iframe.yaml b/panels-iframe.yaml
new file mode 100644
index 0000000..1ba8c44
--- /dev/null
+++ b/panels-iframe.yaml
@@ -0,0 +1,8 @@
+pihole:
+  title: 'Pi Hole'
+  icon: 'mdi:apple-safari'
+  url: !secret pi_hole_admin
+monit:
+  title: 'Monit'
+  icon: 'mdi:autorenew'
+  url: !secret monit_admin
diff --git a/scenes/master-bath-dash-on.yaml b/scenes/master-bath-dash-on.yaml
index bee0050..096e8db 100644
--- a/scenes/master-bath-dash-on.yaml
+++ b/scenes/master-bath-dash-on.yaml
@@ -8,3 +8,5 @@ entities:
     color_temp: 450
   light.master_bath_3:
     state: off
+  automation.brightness_master_bath_sync:
+    state: off
diff --git a/secrets.yaml b/secrets.yaml
index 873ee73..00397fd 100644
--- a/secrets.yaml
+++ b/secrets.yaml
@@ -11,6 +11,15 @@ gravatar_chris:
 gravatar_chris_2:
 wunderground_key:
 wunderground_pws_id:
+wunderground_forecast_url:
 logentries_token:
 mysql_recorder:
-wemo_ip:
+wemo_kitchen_ip:
+slack_api_key:
+influxdb_host:
+influxdb_user:
+influxdb_password:
+influxdb_db:
+pi_hole_host:
+pi_hole_admin:
+monit_admin:
diff --git a/sensors/apcupsd.yaml b/sensors/apcupsd.yaml
new file mode 100644
index 0000000..3d8a487
--- /dev/null
+++ b/sensors/apcupsd.yaml
@@ -0,0 +1,13 @@
+platform: apcupsd
+resources:
+  - bcharge
+  - linev
+  - loadpct
+  - nominv
+  - nombattv
+  - nompower
+  - numxfers
+  - status
+  - timeleft
+  - tonbatt
+  - lastxfer
diff --git a/sensors/fastcom.yaml b/sensors/fastcom.yaml
index 9febf5a..8ee5e2c 100644
--- a/sensors/fastcom.yaml
+++ b/sensors/fastcom.yaml
@@ -1,6 +1,6 @@
 platform: fastdotcom
 minute:
-  - 0
-  - 15
-  - 30
-  - 45
+  - 4
+  - 19
+  - 34
+  - 49
diff --git a/sensors/pihole.yaml b/sensors/pihole.yaml
new file mode 100644
index 0000000..f72a457
--- /dev/null
+++ b/sensors/pihole.yaml
@@ -0,0 +1,4 @@
+platform: pi_hole
+host: !secret pi_hole_host
+ssl: true
+verify: true
diff --git a/sensors/speedtest.yaml b/sensors/speedtest.yaml
index f2f21ba..ad399eb 100644
--- a/sensors/speedtest.yaml
+++ b/sensors/speedtest.yaml
@@ -1,9 +1,9 @@
 platform: speedtest
 minute:
-  - 0
-  - 15
-  - 30
-  - 45
+  - 2
+  - 17
+  - 32
+  - 47
 monitored_conditions:
 - ping
 - download
diff --git a/sensors/statistics-eth1-received.yaml b/sensors/statistics-eth1-received.yaml
new file mode 100644
index 0000000..2e242db
--- /dev/null
+++ b/sensors/statistics-eth1-received.yaml
@@ -0,0 +1,3 @@
+platform: statistics
+name: eth1 Data Received
+entity_id: sensor.received_eth1
diff --git a/sensors/statistics-eth1-sent.yaml b/sensors/statistics-eth1-sent.yaml
new file mode 100644
index 0000000..2a0e2e7
--- /dev/null
+++ b/sensors/statistics-eth1-sent.yaml
@@ -0,0 +1,3 @@
+platform: statistics
+name: eth1 Data Sent
+entity_id: sensor.sent_eth1
diff --git a/sensors/systemmonitor.yaml b/sensors/systemmonitor.yaml
index 531b29b..9c449fd 100644
--- a/sensors/systemmonitor.yaml
+++ b/sensors/systemmonitor.yaml
@@ -5,9 +5,12 @@ resources:
   - type: disk_use_percent
     arg: /var/log
   - type: memory_use_percent
+  - type: memory_use
   - type: memory_free
   - type: processor_use
   - type: swap_use_percent
+  - type: swap_use
+  - type: swap_free
   - type: last_boot
   - type: since_last_boot
   - type: network_in
diff --git a/sensors/template.yaml b/sensors/template.yaml
new file mode 100644
index 0000000..7bba152
--- /dev/null
+++ b/sensors/template.yaml
@@ -0,0 +1,15 @@
+platform: template
+sensors:
+  pihole_queries_today:
+    value_template: '{{ states.sensor.pihole.attributes.queries_today | round(0) }}'
+    friendly_name: DNS Queries Today
+    entity_id: sensor.pihole
+  pihole_domains_blocked:
+    value_template: '{{ states.sensor.pihole.attributes.domains_blocked | round(0) }}'
+    friendly_name: Domains Blocked
+    entity_id: sensor.pihole
+  pihole_percent_ads_today:
+    value_template: '{{ states.sensor.pihole.attributes.percentage_today | round(1) }}'
+    friendly_name: Percent Ads Today
+    unit_of_measurement: '%'
+    entity_id: sensor.pihole
diff --git a/weblinks.yaml b/weblinks.yaml
new file mode 100644
index 0000000..99870e2
--- /dev/null
+++ b/weblinks.yaml
@@ -0,0 +1,4 @@
+entities:
+  - name: Forecast
+    url: !secret wunderground_forecast_url
+    icon: mdi:web
diff --git a/wemo.yaml b/wemo.yaml
index ec5bd90..2adb38e 100644
--- a/wemo.yaml
+++ b/wemo.yaml
@@ -1,2 +1,2 @@
 static:
-  - !secret wemo_ip
+  - !secret wemo_kitchen_ip
-- 
GitLab