From 2e90a43ba2f9b90b5bba2f1fce5904a388b0f5e2 Mon Sep 17 00:00:00 2001 From: ccostan Date: Fri, 18 May 2018 13:43:03 -0400 Subject: [PATCH] Updated with @Brianhanifin 's great streamlined light code! #358 --- config/packages/finance.yaml | 4 ++++ config/script/speech_engine.yaml | 23 +++++++---------------- config/script/tweet.yaml | 6 ++++-- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/config/packages/finance.yaml b/config/packages/finance.yaml index 76e2937a..68fcb90e 100755 --- a/config/packages/finance.yaml +++ b/config/packages/finance.yaml @@ -29,12 +29,16 @@ sensor: - from: BTC to: USD name: Bitcoin + - from: ETH + to: USD + name: Ethereum #------------------------------------------- group: finance: entities: - sensor.tesla - sensor.bitcoin + - sensor.ethereum - sensor.vmware - sensor.amazon diff --git a/config/script/speech_engine.yaml b/config/script/speech_engine.yaml index ddf17bd0..ef3a58fd 100755 --- a/config/script/speech_engine.yaml +++ b/config/script/speech_engine.yaml @@ -74,26 +74,17 @@ speech_engine: {%- macro outside_weather() -%} Outside, it is going to be {{ states('sensor.dark_sky_minutely_summary') }} {%- endmacro -%} - + {%- macro light_check() -%} {% if states.group.all_lights.state != 'off' -%} There are - {% for state in states.light if state.state == 'on' -%} - {%- if loop.last -%} - {{ loop.index }} + {%- set lights_on_count = sensor.lights_on_friendly|length + 1 -%} + {%- if lights_on_count == 1 -%} + The {{ sensor.lights_on_friendly }} is the only light on right now. + {%- else -%} + There are {{ lights_on_count }} lights on right now. + The {{ sensor.lights_on_friendly }} are on. {%- endif -%} - {%- endfor %} - lights on right now. - - {% set comma = joiner(', ') %} - The - {% for group in states.group|groupby('state') -%} - {%- for entity in group.list if entity.state == 'on' and entity.name.split(' ')[1]|lower == 'lights' and entity.name.split(' ')[0]|lower != 'all' and entity.name.split(' ')[0]|lower != 'interior' -%} - {{ ' and' if loop.last and not loop.first else comma() }} - {{ entity.name }} - {%- endfor -%} - {%- endfor -%} - . {%- endif -%} {%- endmacro -%} diff --git a/config/script/tweet.yaml b/config/script/tweet.yaml index 4f549429..5e851ddd 100755 --- a/config/script/tweet.yaml +++ b/config/script/tweet.yaml @@ -2,7 +2,7 @@ ## Script to send notifications to Twitter as @BearStoneHA. ## Publish on Facebook as well - https://www.facebook.com/BearStoneHA/ ## If you do end up using this package, please consider using one or two of the canned tweets that calls back to my main repo -## so others can bring thier homes online as well. I have an active search for #RandomFacts that helps me find new HA homes using my package online. +## so others can bring thier homes online as well. I have an active search for #Randomstats that helps me find new HA homes using my package online. ## Enhancements by @dale3h ###################################################################################################### @@ -24,7 +24,8 @@ tweet_engine_setup: "solar": [ "I am keeping track of the current #Tesla stock price. It is ${{ states('sensor.tesla')|round }}. #Solar", "The #ChevyBolt was charged for about {{ states.sensor.bolt_charging_time.attributes.value|replace('m', '') }} minutes in the last 7 days.", - "The Official Diecast P85 Model S Red (https://amzn.to/2Hkkl0S) link - Out of stock like the originals. :)" + "The Official Diecast P85 Model S Red (https://amzn.to/2Hkkl0S) link - Out of stock like the originals. :)", + "Solar power from #Tesla is the life blood of this whole operation. (https://www.vcloudinfo.com/2018/01/going-green-to-save-some-green-in-2018.html)" ], "throwback": [ "One of the most popular #SmartHome Projects I have done: (https://www.vcloudinfo.com/2017/07/visualizing-smart-home-using-home.html)", @@ -84,6 +85,7 @@ tweet_engine_setup: "stocks": [ "I am keeping track of the current #Tesla stock price. It is ${{ states('sensor.tesla')|round }}. #Solar", "I am keeping track of the current #Bitcoin prices. It is ${{ states('sensor.bitcoin')|round }}. #BTC", + "I am keeping track of the current #Ethereum prices. It is ${{ states('sensor.ethereum')|round }}. #ETH", "I am keeping track of the current #VMware stock price. It is ${{ states('sensor.vmware')|round }}. #vExpert", "I am keeping track of the current #Amazon stock prices. It is ${{ states('sensor.amazon')|round }}. #AWS" ],