From 181bf3c2146755ad8ff1a478047aa4796ae8cad1 Mon Sep 17 00:00:00 2001 From: Jeffrey Stone Date: Fri, 10 Apr 2020 12:41:46 -0400 Subject: [PATCH] Tweaking twitter content --- config/packages/twitter.yaml | 89 ++++++++++++++------- config/templates/twitter_great_content.yaml | 31 +++++++ config/templates/twitter_promos.yaml | 48 +++++++---- config/templates/twitter_selfpromos.yaml | 35 ++++++++ config/templates/twitter_stats.yaml | 11 ++- 5 files changed, 169 insertions(+), 45 deletions(-) create mode 100755 config/templates/twitter_great_content.yaml create mode 100755 config/templates/twitter_selfpromos.yaml diff --git a/config/packages/twitter.yaml b/config/packages/twitter.yaml index f796ec4..8891563 100755 --- a/config/packages/twitter.yaml +++ b/config/packages/twitter.yaml @@ -45,7 +45,7 @@ automation: initial_state: true trigger: - platform: time - at: '13:00:00' + at: '14:00:00' action: - delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00' - service: script.twitter_snark @@ -59,6 +59,16 @@ automation: action: - delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00' - service: script.twitter_stats + + - id: tweet_some_stats2 + alias: Tweet Some Stats2 + initial_state: true + trigger: + - platform: time + at: '14:00:00' + action: + - delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00' + - service: script.twitter_stats - id: tweet_some_promos alias: Tweet Some Promos @@ -70,6 +80,31 @@ automation: - delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00' - service: script.twitter_promos + - id: tweet_some_promos2 + alias: Tweet Some Promos2 + initial_state: true + trigger: + - platform: time + at: '13:00:00' + action: + - delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00' + - service: script.twitter_selfpromos + + # The whole purpose of this automation is to tweet out some links to great Home Assistant content. This is not sponsored in any way. + # I just wanted a way to give back to those I have borrowed from. Tweets ever Friday. + - id: tweet_some_great_content + alias: Tweet Some Great Content + initial_state: true + trigger: + - platform: time + at: '13:00:00' + condition: + - condition: time + weekday: fri + action: + - delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00' + - service: script.twitter_great_content + - id: bot_info alias: Bot Info initial_state: true @@ -93,26 +128,26 @@ automation: {{ [ "/config/www/tweet_images/robot1.jpg", "/config/www/tweet_images/robot2.jpg"] | random }} - - id: net_speed_report - initial_state: true - alias: Network Speed Report - trigger: - - platform: time - at: '11:15:00' - action: - - service: script.twitter_notify_image - data_template: - tweet: >- - {{ [ "According to my latest speed tests Anchorage House is getting - {{ states.sensor.internet_test_down.attributes.max_value }} Mbps down and {{ states.sensor.internet_test_up.attributes.max_value }} - Mbps up thanks to #ATTFiber. ", "How fast is your internet? I just checked - am Im seeing {{ states.sensor.internet_test_down.attributes.max_value }} Mbps down and {{ states.sensor.internet_test_up.attributes.max_value }} - Mbps up. Beat that. ", "My speed is monitored using @home_assistant and https://github.com/thejeffreystone/speedtest_to_mqtt - and is {{ states.sensor.internet_test_down.attributes.max_value }} Mbps down and {{ states.sensor.internet_test_up.attributes.max_value }} - Mbps up." ] | random }} - image: >- - {{ [ "/config/www/tweet_images/speed.jpg", - "/config/www/tweet_images/fiber-optic.jpg"] | random }} + # - id: net_speed_report + # initial_state: true + # alias: Network Speed Report + # trigger: + # - platform: time + # at: '11:15:00' + # action: + # - service: script.twitter_notify_image + # data_template: + # tweet: >- + # {{ [ "According to my latest speed tests Anchorage House is getting + # {{ states.sensor.internet_test_down.attributes.max_value }} Mbps down and {{ states.sensor.internet_test_up.attributes.max_value }} + # Mbps up thanks to #ATTFiber. ", "How fast is your internet? I just checked + # am Im seeing {{ states.sensor.internet_test_down.attributes.max_value }} Mbps down and {{ states.sensor.internet_test_up.attributes.max_value }} + # Mbps up. Beat that. ", "My speed is monitored using @home_assistant and https://github.com/thejeffreystone/speedtest_to_mqtt + # and is {{ states.sensor.internet_test_down.attributes.max_value }} Mbps down and {{ states.sensor.internet_test_up.attributes.max_value }} + # Mbps up." ] | random }} + # image: >- + # {{ [ "/config/www/tweet_images/speed.jpg", + # "/config/www/tweet_images/fiber-optic.jpg"] | random }} - id: rex_manning_day_tweet_1 alias: Rex Manning Day Tweet One @@ -393,14 +428,14 @@ automation: - platform: time at: '09:00:00' action: - - service: script.text_notify - data_template: - who: "jeff" - title: "Covid-19 Update" - message: "Yesterday in the US there was {{ states.sensor.covid_pv_new_cases.state }} new cases of COVID-19 reported and {{ states.sensor.covid_pv_new_dead.state }} more deaths. We now have a total of {{ states.sensor.covid_pv_confirmed.state }} people that have been infected and {{ states.sensor.covid_pv_dead.state }} that have died. So far {{ states.sensor.covid_pv_recovered.state }} have recovered, but {{ states.sensor.covid_pv_critical.state }} are in critical condition." + # - service: script.text_notify + # data_template: + # who: "jeff" + # title: "Covid-19 Update" + # message: "Yesterday in the US there was {{ states.sensor.covid_pv_new_cases.state }} new cases of COVID-19 reported and {{ states.sensor.covid_pv_new_dead.state }} more deaths. We now have a total of {{ states.sensor.covid_pv_confirmed.state }} people that have been infected and {{ states.sensor.covid_pv_dead.state }} that have died. So far {{ states.sensor.covid_pv_recovered.state }} have recovered, but {{ states.sensor.covid_pv_critical.state }} are in critical condition." - service: script.twitter_notify data_template: - message: "Yesterday in the US there was {{ states.sensor.covid_pv_new_cases.state }} new cases of COVID-19 reported and {{ states.sensor.covid_pv_new_dead.state }} more deaths. We now have a total of {{ states.sensor.covid_pv_confirmed.state }} people that have been infected and {{ states.sensor.covid_pv_dead.state }} that have died. So far {{ states.sensor.covid_pv_recovered.state }} have recovered, but {{ states.sensor.covid_pv_critical.state }} are in critical condition. #washyourhands" + message: "Yesterday in the US there were {{ states.sensor.covid_pv_new_cases.state }} new cases of COVID-19 reported and {{ states.sensor.covid_pv_new_dead.state }} more deaths. We now have a total of {{ states.sensor.covid_pv_confirmed.state }} people that have been infected and {{ states.sensor.covid_pv_dead.state }} that have died. So far {{ states.sensor.covid_pv_recovered.state }} have recovered, but {{ states.sensor.covid_pv_critical.state }} are in critical condition. #worldometers" - id: new_ha_notification alias: New HA Notification diff --git a/config/templates/twitter_great_content.yaml b/config/templates/twitter_great_content.yaml new file mode 100755 index 0000000..904e253 --- /dev/null +++ b/config/templates/twitter_great_content.yaml @@ -0,0 +1,31 @@ + > + {# Twitter Great Content #} + {%- macro getRandomPromo() -%} + {{- [ + "Want to get YouTube Certified in Home Assistant? @ccostan has the courses to get you there. Subscribe at https://www.youtube.com/channel/UC301G8JJFzY0BZ_0lshpKpQ ", + "Checkout one of my favorite Home Assistant Youtubers @ccostan at https://www.youtube.com/channel/UC301G8JJFzY0BZ_0lshpKpQ ", + "Don't miss @Dr_Zzs next live stream and besure to follow him on Youtube at https://www.youtube.com/channel/UC7G4tLa4Kt6A9e3hJ-HO8ng ", + "Looking for some great Home Assistant content? @JuanMTech has you covered. Subscribe at https://www.youtube.com/user/Jfelipe83M ", + "Want some Home Assistant and Home Automation content? @hasscasts has what you want at https://hasscasts.com", + "Need some How-To's to juice up your Home Assistant skills? @juanMTech has something for everyone at https://www.juanmtech.com" + ] | random -}} + {%- endmacro -%} + {%- macro getTags() -%} + #homeassistant #youcandoit #spreadtheword #givingback + {%- endmacro -%} + + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getRandomPromo() }} + {{ getTags() }} + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} + diff --git a/config/templates/twitter_promos.yaml b/config/templates/twitter_promos.yaml index 717e2f5..c13f19d 100755 --- a/config/templates/twitter_promos.yaml +++ b/config/templates/twitter_promos.yaml @@ -1,27 +1,39 @@ > {# Twitter Promos #} + {%- macro getRandomIntro() -%} + {{- [ + "Do you want your house to be a #smarthome? ‏", + "Your house can be a #smarthome too. ", + "Transform your home into a #smarthome. ", + "You get a #smarthome and you get a smarthome and you get a smarthome. ", + "Looking to automate your house? ", + "Want to get into Home Automation? " + ] | random -}} + {%- endmacro -%} + {%- macro getRandomLead() -%} + {{- [ + "All you need is #home_assistant, and these config files ->‏", + "Just grab @home_assistant and checkout ", + "Just grab #home_assistant and for inspiration checkout ", + "It is easy. Install #home_assistant, and add some config files like ", + "You can't go wrong with #home_assistant. For an example of what you can do checkout " + ] | random -}} + {%- endmacro -%} {%- macro getRandomPromo() -%} {{- [ - "Your house can be a #smarthome too. All you need is @home_assistant, and some config files. I suggest https://github.com/CCOSTAN/Home-AssistantConfig#logo cc: @ccostan ‏", - "Your house can be a #smarthome too. All you need is @home_assistant, and some config files. I suggest https://github.com/skalavala/mysmarthome ", - "Your house can be a #smarthome too. All you need is @home_assistant, and some config files. I suggest https://github.com/thejeffreystone/home-assistant-configuration cc: @thejeffreystone ", - "Your house can be a #smarthome too. All you need is @home_assistant, and some config files. I suggest https://github.com/arsaboo/homeassistant-config ", - "Your house can be a #smarthome too. All you need is @home_assistant, and some config files. I suggest https://github.com/Vasiley/Home-Assistant-Main ", - "Your house can be a #smarthome too. All you need is @home_assistant, and some config files. I suggest https://github.com/JamesMcCarthy79/Home-Assistant-Config ", - "Your house can be a #smarthome too. All you need is @home_assistant, and some config files. I suggest https://github.com/bruhautomation/BRUH3-Home-Assistant-Configuration cc: @BRUHautomation ", - "Your house can be a #smarthome too. All you need is @home_assistant, and some config files. I suggest https://github.com/isabellaalstrom/home-assistant-config cc: @teachingbirds ", - "Your house can be a #smarthome too. All you need is @home_assistant, and some config files. I suggest https://github.com/JuanMTech/Home_Assistant_files cc: @JuanMTech ", - "Want to get YouTube Certified in Home Assistant? @ccostan has you covered. Subscribe at https://www.youtube.com/channel/UC301G8JJFzY0BZ_0lshpKpQ ", - "Want to get YouTube Certified in Home Assistant? @thejeffreystone has you covered. Subscribe at https://www.youtube.com/channel/UCipZJ6748kd8TbelSxcvcVg ", - "Want to get YouTube Certified in Home Assistant? @Dr_Zzs has you covered. Subscribe at https://www.youtube.com/channel/UC7G4tLa4Kt6A9e3hJ-HO8ng ", - "Want to get YouTube Certified in Home Assistant? @JuanMTech has you covered. Subscribe at https://www.youtube.com/user/Jfelipe83M ", - "Want to get YouTube Certified in Home Assistant? @bhautomation has you covered. Subscribe at https://www.youtube.com/channel/UCSKQutOXuNLvFetrKuwudpg ", - "You can watch videos about how I came to be and all the cool things I'm learning to do at https://www.youtube.com/channel/UCipZJ6748kd8TbelSxcvcVg ", - "Anchorage House's Automation was built under the guiding principles of The Three Laws of Home Automation -> https://github.com/thejeffreystone/home-assistant-configuration#anchorage-houses-three-laws-of-home-automation" + "https://github.com/CCOSTAN/Home-AssistantConfig#logo cc: @ccostan ‏", + "https://github.com/skalavala/mysmarthome ", + "https://github.com/thejeffreystone/home-assistant-configuration cc: @thejeffreystone ", + "https://github.com/arsaboo/homeassistant-config ", + "https://github.com/Vasiley/Home-Assistant-Main ", + "https://github.com/JamesMcCarthy79/Home-Assistant-Config ", + "https://github.com/bruhautomation/BRUH3-Home-Assistant-Configuration cc: @BRUHautomation ", + "https://github.com/isabellaalstrom/home-assistant-config cc: @teachingbirds ", + "https://github.com/JuanMTech/Home_Assistant_files cc: @JuanMTech ", ] | random -}} {%- endmacro -%} {%- macro getTags() -%} - #homeassistant #youcandoit #promo #spreadtheword + #homeassistant #youcandoit #spreadtheword #givingback {%- endmacro -%} {# a macro that removes all newline characters, empty spaces, and returns formatted text #} @@ -32,6 +44,8 @@ {# a macro to call all macros :) #} {%- macro mother_of_all_macros() -%} + {{ getRandomIntro() }} + {{ getRandomLead() }} {{ getRandomPromo() }} {{ getTags() }} {%- endmacro -%} diff --git a/config/templates/twitter_selfpromos.yaml b/config/templates/twitter_selfpromos.yaml new file mode 100755 index 0000000..ca27dc2 --- /dev/null +++ b/config/templates/twitter_selfpromos.yaml @@ -0,0 +1,35 @@ + > + {# Twitter Self Promos #} + {%- macro getRandomPromo() -%} + {{- [ + "Be sure to my follow my Github Repo -> https://github.com/thejeffreystone/home-assistant-configuration", + "Be sure to subscribe to my Youtube channel https://www.youtube.com/channel/UCipZJ6748kd8TbelSxcvcVg for videos on Home Assistant.", + "Want to know how to add USPS Notifications to your Home Assistant? @thejeffreystone made a video -> https://www.youtube.com/watch?v=TjVeoAKn-r0", + "You can watch videos about how I came to be and all the cool things I'm learning to do at https://www.youtube.com/channel/UCipZJ6748kd8TbelSxcvcVg ", + "You can bring a little Disney #imagineering into your home using @home_assistant. Check out this video @thejeffreystone posted -> https://www.youtube.com/watch?v=Tm9ZXtk5P-s #homemadedisney", + "Anchorage House's Automation was built under the guiding principles of The Three Laws of Home Automation -> https://jeffreystone.net/2020/04/02/the-three-laws-of-home-automation/", + "You can read about how I came to be and all the cool things I'm learning to do at https://jeffreystone.net ", + "Be sure to follow along at https://jeffreystone.net so you can keep up today with the latest updates to my Home Asissitant Configuration", + "Want to know how I was migrated from Hassbian to Home Assistant? Now you can at https://jeffreystone.net/2020/04/05/migrating-from-hassbian-to-hassio/", + "Did you see the post about how I can turn into Disney's Haunted Mansion on command using #home_assistant? Visit https://jeffreystone.net/2020/04/04/how-i-turned-my-anchorage-house-into-disneys-haunted-mansion-using-home-assistant/ #homemadedisney" + ] | random -}} + {%- endmacro -%} + {%- macro getTags() -%} + #homeassistant #lookwhatidid + {%- endmacro -%} + + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getRandomPromo() }} + {{ getTags() }} + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} + diff --git a/config/templates/twitter_stats.yaml b/config/templates/twitter_stats.yaml index ed25160..5b314d6 100755 --- a/config/templates/twitter_stats.yaml +++ b/config/templates/twitter_stats.yaml @@ -21,7 +21,16 @@ "The wind blows an average of {{ states.sensor.wind_speed_stats.attributes.mean | round}} mph here at Anchorage House.", "The Washing Machine uses an an average of {{ states.sensor.washer_power_stats.attributes.mean | round}} watts here at Anchorage House.", "I am currently managing {{ states.sensor.lights_count.state }} lights and {{ states.sensor.tracker_count.state }} devices.", - "Amazon Polly enables me to sound more lifelike by incorporate breathing into my speech. #AWS" + "Amazon Polly enables me to sound more lifelike by incorporating breathing into my speech using #SAML. #AWS", + "According to my latest speed tests Anchorage House is getting + {{ states.sensor.internet_test_down.attributes.max_value }} Mbps down and {{ states.sensor.internet_test_up.attributes.max_value }} + Mbps up thanks to #ATTFiber. ", + "How fast is your internet? I just checked + am Im seeing {{ states.sensor.internet_test_down.attributes.max_value }} Mbps down and {{ states.sensor.internet_test_up.attributes.max_value }} + Mbps up. Beat that. ", + "My speed is monitored using @home_assistant and https://github.com/thejeffreystone/speedtest_to_mqtt + and is {{ states.sensor.internet_test_down.attributes.max_value }} Mbps down and {{ states.sensor.internet_test_up.attributes.max_value }} + Mbps up." ] | random -}} {%- endmacro -%} {%- macro getTags() -%}