From a7ff07858b964f21f25e832abe27c6add6f320f9 Mon Sep 17 00:00:00 2001
From: Erick Hitter <services@ethitter.com>
Date: Sun, 16 Oct 2016 14:11:14 -0700
Subject: [PATCH] Sync with upstream

d6cf76e
---
 automations/kitchen-nightlight-on-am.yaml    |  3 ++
 automations/kitchen-nightlight-on-pm.yaml    |  3 ++
 automations/living-room-sunset-on.yaml       | 19 +++++---
 configuration.yaml                           |  8 +---
 customizations/sensors.yaml                  | 34 ++++++++++---
 groups.yaml                                  | 50 +++++++++++---------
 influxdb.yaml                                | 18 +++++++
 scenes/master-bath-dash-on.yaml              |  4 +-
 secrets.yaml                                 |  1 +
 sensors/apcupsd.yaml                         |  7 +++
 sensors/{pihole.yaml => pihole-0001-ha.yaml} |  0
 sensors/pihole-0002-failover.yaml            |  4 ++
 sensors/statistics-eth1-received.yaml        |  3 --
 sensors/statistics-eth1-sent.yaml            |  3 --
 sensors/statistics-ups-load.yaml             |  3 ++
 sensors/template.yaml                        | 13 +++++
 16 files changed, 122 insertions(+), 51 deletions(-)
 create mode 100644 influxdb.yaml
 rename sensors/{pihole.yaml => pihole-0001-ha.yaml} (100%)
 create mode 100644 sensors/pihole-0002-failover.yaml
 delete mode 100644 sensors/statistics-eth1-received.yaml
 delete mode 100644 sensors/statistics-eth1-sent.yaml
 create mode 100644 sensors/statistics-ups-load.yaml

diff --git a/automations/kitchen-nightlight-on-am.yaml b/automations/kitchen-nightlight-on-am.yaml
index 951099f..cf79801 100644
--- a/automations/kitchen-nightlight-on-am.yaml
+++ b/automations/kitchen-nightlight-on-am.yaml
@@ -13,6 +13,9 @@ trigger:
 condition:
   condition: and
   conditions:
+    - condition: state
+      entity_id: group.presence
+      state: 'home'
     - condition: state
       entity_id: sun.sun
       state: 'below_horizon'
diff --git a/automations/kitchen-nightlight-on-pm.yaml b/automations/kitchen-nightlight-on-pm.yaml
index ad1e138..fe1a77f 100644
--- a/automations/kitchen-nightlight-on-pm.yaml
+++ b/automations/kitchen-nightlight-on-pm.yaml
@@ -13,6 +13,9 @@ trigger:
 condition:
   condition: and
   conditions:
+    - condition: state
+      entity_id: group.presence
+      state: 'home'
     - condition: state
       entity_id: sun.sun
       state: 'below_horizon'
diff --git a/automations/living-room-sunset-on.yaml b/automations/living-room-sunset-on.yaml
index b63f895..b5c4117 100644
--- a/automations/living-room-sunset-on.yaml
+++ b/automations/living-room-sunset-on.yaml
@@ -2,16 +2,21 @@ alias: 'Turn on living room at sunset'
 trigger:
   platform: sun
   event: sunset
-  offset: "-00:60:00"
+  offset: "-00:45:00"
 condition:
-  condition: or
+  condition: and
   conditions:
     - condition: state
-      entity_id: light.endtable
-      state: 'off'
-    - condition: state
-      entity_id: light.corner_table
-      state: 'off'
+      entity_id: group.presence
+      state: 'home'
+    - condition: or
+      conditions:
+      - condition: state
+        entity_id: light.endtable
+        state: 'off'
+      - condition: state
+        entity_id: light.corner_table
+        state: 'off'
 action:
   service: scene.turn_on
   entity_id: scene.lr_relax
diff --git a/configuration.yaml b/configuration.yaml
index 4491e89..3d44089 100644
--- a/configuration.yaml
+++ b/configuration.yaml
@@ -38,13 +38,7 @@ recorder:
   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
+influxdb: !include influxdb.yaml
 
 # Enables support for tracking state changes over time.
 history:
diff --git a/customizations/sensors.yaml b/customizations/sensors.yaml
index 4ce614b..2b7e655 100644
--- a/customizations/sensors.yaml
+++ b/customizations/sensors.yaml
@@ -135,9 +135,31 @@ 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
+sensor.pihole_2:
+  friendly_name: Ads Blocked (Backup)
+sensor.ups_status:
+  friendly_name: Status
+sensor.ups_load:
+  friendly_name: Load
+sensor.ups_time_left:
+  friendly_name: Time left
+sensor.ups_time_on_battery:
+  friendly_name: Time on battery
+sensor.ups_last_transfer:
+  friendly_name: Last transfer
+sensor.ups_transfer_count:
+  friendly_name: Transfer count
+sensor.ups_battery:
+  friendly_name: Battery level
+sensor.ups_battery_voltage:
+  friendly_name: Battery voltage
+sensor.ups_battery_nominal_voltage:
+  friendly_name: Battery nominal voltage
+sensor.ups_input_voltage:
+  friendly_name: Input voltage
+sensor.ups_nominal_input_voltage:
+  friendly_name: Nominal input voltage
+sensor.ups_nominal_output_power:
+  friendly_name: Nominal output power
+sensor.ups_load_mean:
+  friendly_name: Load mean
diff --git a/groups.yaml b/groups.yaml
index 6268207..8174a02 100644
--- a/groups.yaml
+++ b/groups.yaml
@@ -28,6 +28,7 @@ sensor_view:
     - sensor.speedtest_upload
     - sensor.fastcom_download
     - sensor.pihole_queries_today
+    - sensor.pihole_2_queries_today
     - sun.sun
 status_view:
   name: Status
@@ -37,11 +38,14 @@ status_view:
     - group.time_date
     - group.sensor_pi
     - group.sensor_apc
-    - group.sensor_battery_levels
     - sensor.pihole
+    - sensor.pihole_2
     - sensor.pihole_percent_ads_today
+    - sensor.pihole_2_percent_ads_today
     - sensor.pihole_queries_today
+    - sensor.pihole_2_queries_today
     - sensor.pihole_domains_blocked
+    - sensor.pihole_2_domains_blocked
 weather_view:
   name: Weather
   view: yes
@@ -55,7 +59,7 @@ misc_view:
   entities:
     - group.scripts_misc
     - group.misc_misc
-    - media_player.nexus_player
+    - group.sensor_battery_levels
 locks:
   name: Locks
   entities:
@@ -161,7 +165,6 @@ presence:
     - device_tracker.eh_nexus_6
     - device_tracker.cl_samsung_s5
     - device_tracker.cl_iphone_5
-    - device_tracker.green_keys
 time_date:
   name: Time & Date
   entities:
@@ -180,8 +183,8 @@ sensor_pi:
     - sensor.swap_free
     - sensor.last_boot
     - sensor.since_last_boot
-    - 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.received_eth1
+    - sensor.sent_eth1
 sensor_apc:
   name: APC
   entities:
@@ -192,28 +195,12 @@ sensor_apc:
     - sensor.ups_last_transfer
     - sensor.ups_transfer_count
     - sensor.ups_battery
+    - sensor.ups_battery_voltage
     - 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:
-    - sensor.living_room_alarm_battery_level
-    - sensor.master_bedroom_alarm_battery_level
-    - sensor.front_door_battery_level
-    - sensor.slider_battery_level
-    - sensor.master_bedroom_window_battery_level
-    - sensor.dining_area_window_battery_level
-    - sensor.office_window_battery_level
-    - sensor.motion_sensor_above_slider_battery_level
-    - sensor.motion_sensor_over_utility_closet_battery_level
-    - sensor.kitchen_motion_sensor_battery_level
-    - sensor.office_motion_sensor_near_closet_battery_level
-    - sensor.office_motion_sensor_far_wall_battery_level
-    - sensor.office_cabinet_battery_level
-    - sensor.green_keys_battery_level
+    - sensor.ups_load_mean
 scripts_misc:
   name: Lock Actions
   entities:
@@ -232,6 +219,23 @@ misc_misc:
     - scene.all_lights_off
     - script.restart_dash_button_shm
     - script.restart_dash_button_hac
+sensor_battery_levels:
+  name: Sensor Battery Levels
+  entities:
+    - sensor.living_room_alarm_battery_level
+    - sensor.master_bedroom_alarm_battery_level
+    - sensor.front_door_battery_level
+    - sensor.slider_battery_level
+    - sensor.master_bedroom_window_battery_level
+    - sensor.dining_area_window_battery_level
+    - sensor.office_window_battery_level
+    - sensor.motion_sensor_above_slider_battery_level
+    - sensor.motion_sensor_over_utility_closet_battery_level
+    - sensor.kitchen_motion_sensor_battery_level
+    - sensor.office_motion_sensor_near_closet_battery_level
+    - sensor.office_motion_sensor_far_wall_battery_level
+    - sensor.office_cabinet_battery_level
+    - sensor.green_keys_battery_level
 wunderground:
   name: Wunderground
   entities:
diff --git a/influxdb.yaml b/influxdb.yaml
new file mode 100644
index 0000000..1fc81c4
--- /dev/null
+++ b/influxdb.yaml
@@ -0,0 +1,18 @@
+host: !secret influxdb_host
+database: !secret influxdb_db
+username: !secret influxdb_user
+password: !secret influxdb_password
+ssl: true
+verify_ssl: true
+whitelist:
+  - sensor.master_bedroom_window
+  - sensor.slider
+  - sensor.above_slider
+  - sensor.above_utility_closet
+  - sensor.front_door
+  - sensor.dining_area_window
+  - sensor.kitchen
+  - sensor.office_window
+  - sensor.office_near_closet
+  - sensor.office_far_wall
+  - sensor.office_cabinet
diff --git a/scenes/master-bath-dash-on.yaml b/scenes/master-bath-dash-on.yaml
index 096e8db..2583a76 100644
--- a/scenes/master-bath-dash-on.yaml
+++ b/scenes/master-bath-dash-on.yaml
@@ -8,5 +8,5 @@ entities:
     color_temp: 450
   light.master_bath_3:
     state: off
-  automation.brightness_master_bath_sync:
-    state: off
+  # automation.brightness_master_bath_sync:
+  #  state: off
diff --git a/secrets.yaml b/secrets.yaml
index 00397fd..5ad6ca6 100644
--- a/secrets.yaml
+++ b/secrets.yaml
@@ -21,5 +21,6 @@ influxdb_user:
 influxdb_password:
 influxdb_db:
 pi_hole_host:
+pi_hole_backup_host:
 pi_hole_admin:
 monit_admin:
diff --git a/sensors/apcupsd.yaml b/sensors/apcupsd.yaml
index 3d8a487..dc92c1a 100644
--- a/sensors/apcupsd.yaml
+++ b/sensors/apcupsd.yaml
@@ -2,6 +2,7 @@ platform: apcupsd
 resources:
   - bcharge
   - linev
+  - battv
   - loadpct
   - nominv
   - nombattv
@@ -11,3 +12,9 @@ resources:
   - timeleft
   - tonbatt
   - lastxfer
+  - cumonbatt
+  - xonbatt
+  - xoffbatt
+  - model
+  - serialno
+  - battdate
diff --git a/sensors/pihole.yaml b/sensors/pihole-0001-ha.yaml
similarity index 100%
rename from sensors/pihole.yaml
rename to sensors/pihole-0001-ha.yaml
diff --git a/sensors/pihole-0002-failover.yaml b/sensors/pihole-0002-failover.yaml
new file mode 100644
index 0000000..9b9ae34
--- /dev/null
+++ b/sensors/pihole-0002-failover.yaml
@@ -0,0 +1,4 @@
+platform: pi_hole
+host: !secret pi_hole_backup_host
+ssl: true
+verify: true
diff --git a/sensors/statistics-eth1-received.yaml b/sensors/statistics-eth1-received.yaml
deleted file mode 100644
index 2e242db..0000000
--- a/sensors/statistics-eth1-received.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-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
deleted file mode 100644
index 2a0e2e7..0000000
--- a/sensors/statistics-eth1-sent.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-platform: statistics
-name: eth1 Data Sent
-entity_id: sensor.sent_eth1
diff --git a/sensors/statistics-ups-load.yaml b/sensors/statistics-ups-load.yaml
new file mode 100644
index 0000000..c7c85a0
--- /dev/null
+++ b/sensors/statistics-ups-load.yaml
@@ -0,0 +1,3 @@
+platform: statistics
+name: UPS Load
+entity_id: sensor.ups_load
diff --git a/sensors/template.yaml b/sensors/template.yaml
index 7bba152..0bfc692 100644
--- a/sensors/template.yaml
+++ b/sensors/template.yaml
@@ -13,3 +13,16 @@ sensors:
     friendly_name: Percent Ads Today
     unit_of_measurement: '%'
     entity_id: sensor.pihole
+  pihole_2_queries_today:
+    value_template: '{{ states.sensor.pihole_2.attributes.queries_today | round(0) }}'
+    friendly_name: DNS Queries Today (Backup)
+    entity_id: sensor.pihole_2
+  pihole_2_domains_blocked:
+    value_template: '{{ states.sensor.pihole_2.attributes.domains_blocked | round(0) }}'
+    friendly_name: Domains Blocked (Backup)
+    entity_id: sensor.pihole_2
+  pihole_2_percent_ads_today:
+    value_template: '{{ states.sensor.pihole_2.attributes.percentage_today | round(1) }}'
+    friendly_name: Percent Ads Today (Backup)
+    unit_of_measurement: '%'
+    entity_id: sensor.pihole_2
-- 
GitLab