From 5c68565758f305789015afbb0180f62e3bb4e79d Mon Sep 17 00:00:00 2001 From: ccostan Date: Sun, 25 Mar 2018 11:58:56 -0400 Subject: [PATCH] Quick update to Solar stats maybe @dale3h --- config/packages/twitter.yaml | 19 ++++++++++++++++++- config/shell_scripts/HAUpdate.sh | 26 ++++++++++++++++---------- config/shell_scripts/gitpull.sh | 12 ++++++++++++ config/shell_scripts/gitupdate.sh | 12 ++++++------ 4 files changed, 52 insertions(+), 17 deletions(-) create mode 100755 config/shell_scripts/gitpull.sh diff --git a/config/packages/twitter.yaml b/config/packages/twitter.yaml index 717a773a..5ee4adf9 100755 --- a/config/packages/twitter.yaml +++ b/config/packages/twitter.yaml @@ -23,6 +23,23 @@ notify: ### Building out some Historical stats for tweeting. ##################### sensor: + - platform: sql + db_url: sqlite:///config/home-assistant_v2.db + queries: + - name: "Solar 24h" + column: 'solar_kwh' + unit_of_measurement: 'kWh' + query: >- + SELECT ROUND(SUM(solar_kwh), 2) AS solar_kwh + FROM ( + SELECT AVG(state) AS solar_kwh + FROM states + WHERE entity_id = 'sensor.solar_now' + AND state != 'unknown' + AND last_updated >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 24 HOUR) + GROUP BY HOUR(last_updated) + ) AS total_kwh; + - platform: history_stats name: Doorbell Presses entity_id: binary_sensor.skybell_stone_door_button @@ -129,7 +146,7 @@ group: - sensor.sensor_count - sensor.script_count - sensor.binary_sensor_count - - sensor.automation_count + - sensor.automation_count ############################################################# diff --git a/config/shell_scripts/HAUpdate.sh b/config/shell_scripts/HAUpdate.sh index 0a9d9ad0..925ba7a6 100755 --- a/config/shell_scripts/HAUpdate.sh +++ b/config/shell_scripts/HAUpdate.sh @@ -1,12 +1,18 @@ -## These scripts are run from /home/pi +# ## These scripts are run from /home/pi +# +# #!/bin/bash +# +# cd /home/hass/.homeassistant +# source /srv/hass/hass_venv/bin/activate +# +# echo "Processing update" +# pip3 install --upgrade homeassistant +# +# hass --script check_config +# exit #!/bin/bash - -cd /home/hass/.homeassistant -source /srv/hass/hass_venv/bin/activate - -echo "Processing update" -pip3 install --upgrade homeassistant - -hass --script check_config -exit +cd /home/hass/docker_files +docker-compose down +docker-compose pull +docker-compose up -d diff --git a/config/shell_scripts/gitpull.sh b/config/shell_scripts/gitpull.sh new file mode 100755 index 00000000..cd17b9dd --- /dev/null +++ b/config/shell_scripts/gitpull.sh @@ -0,0 +1,12 @@ +#!/bin/bash +cd /home/hass/docker_files +docker-compose exec home-assistant python -m homeassistant --config /config --script check_config + +cd /home/hass/docker_files/homeassistant +git pull origin master + +cd /home/hass/docker_files +docker-compose exec home-assistant python -m homeassistant --config /config --script check_config + +cd ~ +exit \ No newline at end of file diff --git a/config/shell_scripts/gitupdate.sh b/config/shell_scripts/gitupdate.sh index 06606526..f119e740 100755 --- a/config/shell_scripts/gitupdate.sh +++ b/config/shell_scripts/gitupdate.sh @@ -1,16 +1,16 @@ -## These scripts are run from /home/pi - #!/bin/bash +cd /home/hass/docker_files +docker-compose exec home-assistant python -m homeassistant --config /config --script check_config -cd /home/hass/.homeassistant -source /srv/hass/hass_venv/bin/activate -hass --script check_config +cd /home/hass/docker_files/homeassistant git add . git status -echo -n "Enter the Description for the Change: " [Minor Update] +echo -n "Enter the Description for the Change: [Minor Edit] " read CHANGE_MSG +CHANGE_MSG=${CHANGE_MSG:-Minor Edit} git commit -m "${CHANGE_MSG}" git push origin master +cd ~ exit