home-assistant-configuration/config/packages/twitter.yaml

524 lines
22 KiB
YAML
Executable File

###############################################################################
# @author : Jeffrey Stone
# @date : 07/15/2019
# @package : Twitter
# @description : Just the tweet stuff - @anchoragehouse2
###############################################################################
automation:
- id: first_day_info
alias: First Day Info
initial_state: true
trigger:
- platform: time
at: '00:10:00'
condition:
- condition: template
value_template: >
{% set day=states("sensor.date").split('-')[2] | int %}
{%- if day == 1 -%}
true
{%- endif -%}
action:
- delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00'
- service: script.twitter_notify_image
data_template:
tweet: >-
Its a new month, so this is a good time to remind you that I am powered by #homeassistant. Find my code at https://github.com/thejeffreystone/home-assistant-configuration
image: >-
image: >-
{{ [ "/config/www/tweet_images/robot1.jpg",
"/config/www/tweet_images/robot2.jpg"] | random }}
- id: tweet_some_snark
alias: Tweet Some Snark
initial_state: true
trigger:
- platform: time
at: '08: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
- id: tweet_some_snark2
alias: Tweet Some Snark Again
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_snark
- id: tweet_some_stats
alias: Tweet Some Stats
initial_state: true
trigger:
- platform: time
at: '08: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_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_recent_content
# alias: Tweet Recent Contents
# initial_state: true
# trigger:
# - platform: time
# at: '08:00:00'
# action:
# - delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00'
# - service: script.twitter_recent_content
# data:
# who: slackerlabs
# - id: tweet_follow_me
# alias: Tweet Follow Me
# initial_state: true
# trigger:
# - platform: time
# at: '08:00:00'
# action:
# - delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00'
# - service: script.twitter_follow_me
# data:
# who: 'slackerlabs'
# - 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
# data:
# who: slackerlabs
# - id: tweet_some_promos3
# alias: Tweet Some Promos3
# 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_sl
# 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
# data:
# who: 'slackerlabs'
- id: bot_info
alias: Bot Info
initial_state: true
trigger:
- platform: time
at: '10:00:00'
condition:
- condition: template
value_template: >
{% set day=states("sensor.date").split('-')[2] | int %}
{%- if day == 15 -%}
true
{%- endif -%}
action:
- delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00'
- service: script.twitter_notify_image
data_template:
tweet: >-
You can #homeautomation content related to Anchorage House at -> Blog: https://slacker-labs.com | #smarthome Videos: https://www.youtube.com/channel/UCipZJ6748kd8TbelSxcvcVg | #homeassistant Config: https://github.com/thejeffreystone/home-assistant-configuration
image: >-
{{ [ "/config/www/tweet_images/robot1.jpg",
"/config/www/tweet_images/robot2.jpg"] | random }}
- id: thejeffreystone_info
alias: thejeffreystone Info
initial_state: true
trigger:
- platform: time
at: '10:00:00'
condition:
- condition: template
value_template: >
{% set day=states("sensor.date").split('-')[2] | int %}
{%- if day == 20 -%}
true
{%- endif -%}
action:
- delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00'
- service: script.twitter_notify_image
data_template:
who: 'thejeffreystone'
tweet: >-
You can find my #homeassistant content at -> Blog: https://slacker-labs.com | Videos: https://www.youtube.com/channel/UCipZJ6748kd8TbelSxcvcVg | Config: https://github.com/thejeffreystone/home-assistant-configuration
image: "/config/www/tweet_images/sl_logo.png"
- id: slackerlabs_info
alias: SlackerLabs Info
initial_state: true
trigger:
- platform: time
at: '10:00:00'
condition:
- condition: template
value_template: >
{% set day=states("sensor.date").split('-')[2] | int %}
{%- if day == 1 -%}
true
{%- endif -%}
action:
- delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00'
- service: script.twitter_notify_image
data_template:
who: 'slackerlabs'
tweet: >-
You can find my #homeassistant content at -> Blog: https://slacker-labs.com | Videos: https://www.youtube.com/channel/UCipZJ6748kd8TbelSxcvcVg | Config: https://github.com/thejeffreystone/home-assistant-configuration
image: "/config/www/tweet_images/sl_logo.png"
- id: rex_manning_day_tweet_1
alias: Rex Manning Day Tweet One
initial_state: true
trigger:
- platform: time
at: '08:00:00'
condition:
- condition: state
entity_id: calendar.anchorage_holidays
state: "on"
- condition: template
value_template: >
{%- set event=states.calendar.anchorage_holidays.attributes.message %}
{%- if event == 'Rex Manning Day' %}
true
{%- endif -%}
action:
- service: script.twitter_notify
data_template:
message: >-
Happy Rex Manning Day! https://www.youtube.com/watch?v=30fw5My1QJM #damntheman #savetheempire
- id: rex_manning_day_tweet_2
alias: Rex Manning Day Tweet Two
initial_state: true
trigger:
- platform: time
at: '13:00:00'
condition:
- condition: state
entity_id: calendar.anchorage_holidays
state: "on"
- condition: template
value_template: >
{%- set event=states.calendar.anchorage_holidays.attributes.message %}
{%- if event == 'Rex Manning Day' %}
true
{%- endif -%}
action:
- service: script.twitter_notify
data_template:
message: >-
We mustn't dwell. No, not today. We can't. Not on Rex Manning day! https://www.youtube.com/watch?v=szvt8iWJ0oo #damntheman #savetheempire
- id: Halloween Countdown Tweet
alias: Halloween Countdown Tweet
initial_state: true
trigger:
- platform: time
at: '13:00:00'
condition:
- condition: template
value_template: >
{% set month= now().month | int %}
{%- if month == 10 -%}
true
{%- endif -%}
- condition: template
value_template: >
{%- set event=states.sensor.halloween_countdown.state | int %}
{%- if event > 0 %}
true
{%- endif -%}
- condition: template
value_template: >
{%- set event=states.sensor.halloween_countdown.state | int %}
{%- if event < 31 %}
true
{%- endif -%}
action:
- delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00'
- service: script.twitter_notify_image
data_template:
tweet: >-
{{ [ "There are only {{states.sensor.halloween_countdown.state}} days until Halloween.",
"Halloween is only {{states.sensor.halloween_countdown.state}} days away. It might not be enough time. ",
"Halloween is coming. {{states.sensor.halloween_countdown.state}} days and counting.",
"Only {{states.sensor.halloween_countdown.state}} days until Halloween.",
"You have {{states.sensor.halloween_countdown.state}} days until you need a Halloween costume.",
"Only {{states.sensor.halloween_countdown.state}} days until Halloween. But who is counting. amirite?",
"Would it be cliche if I went as a haunted house for Halloween? Asking for a another house.",
"Just in case I wanted to be HAL 9000 for Halloween I ordered some Pod Bay Doors. They need to get here in {{states.sensor.halloween_countdown.state}} days."
] | random }}
image: >-
{{ [ "/config/www/tweet_images/halloween/potion.jpg",
"/config/www/tweet_images/halloween/Halloween-house.jpg",
"/config/www/tweet_images/halloween/halloween.gif",
"/config/www/tweet_images/halloween/halloween.jpg",
"/config/www/tweet_images/halloween/halloween2.jpg",
"/config/www/tweet_images/halloween/halloween3.jpg",
"/config/www/tweet_images/halloween/Halloweenpumpkins.jpg"] | random }}
- id: Christmas Countdown Tweet
alias: Christmas Countdown Tweet
initial_state: true
trigger:
- platform: time
at: '19:00:00'
condition:
- condition: template
value_template: >
{% set month= now().month | int %}
{%- if month == 12 -%}
true
{%- endif -%}
- condition: template
value_template: >
{%- set event=states.sensor.christmas_countdown.state | int %}
{%- if event > 1 %}
true
{%- endif -%}
- condition: template
value_template: >
{%- set event=states.sensor.christmas_countdown.state | int %}
{%- if event < 31 %}
true
{%- endif -%}
action:
- service: script.twitter_notify_image
data_template:
tweet: >-
{{ [ "There are only {{states.sensor.christmas_countdown.state}} days until Christmas.",
"Christmas is only {{states.sensor.christmas_countdown.state}} days away. It might not be enough time. ",
"Santa is coming. {{states.sensor.christmas_countdown.state}} days and counting until he is here.",
"Only {{states.sensor.christmas_countdown.state}} days until Christmas.",
"You have {{states.sensor.christmas_countdown.state}} days until we get to unwrap presents!",
"Only {{states.sensor.christmas_countdown.state}} days until Christmas. But who is counting. amirite?",
"It is beginning to look a lot like Christmas. Which checks out because it is {{states.sensor.christmas_countdown.state}} days away.",
"Have you finished your Chistmas shopping? You only have {{states.sensor.christmas_countdown.state}} days left.",
"Have you started your Chistmas shopping? You only have {{states.sensor.christmas_countdown.state}} days left."
] | random }}
image: >-
{{ [ "/config/www/tweet_images/xmas.jpg",
"/config/www/tweet_images/gift.jpg",
"/config/www/tweet_images/christmas-cookies.jpg",
"/config/www/tweet_images/christmas.jpg",
"/config/www/tweet_images/christmas-tree.jpg"] | random }}
- id: Christmas Eve Tweet
alias: Christmas Eve Tweet
initial_state: true
trigger:
- platform: time
at: '19:00:00'
condition:
- condition: state
entity_id: calendar.holidays_in_united_states
state: "on"
- condition: template
value_template: >
{%- set event=states.calendar.holidays_in_united_states.attributes.message %}
{%- if event == 'Christmas Eve' %}
true
{%- endif -%}
action:
- service: script.twitter_notify_image
data_template:
tweet: Tomorrow is Christmas. It is practically here! Santa is coming tonight! Do not forget the cookies!
image: /config/www/tweet_images/santa.png
- id: Christmas Day Tweet
alias: Christmas Day Tweet
initial_state: true
trigger:
- platform: time
at: '05:30:00'
condition:
- condition: state
entity_id: calendar.holidays_in_united_states
state: "on"
- condition: template
value_template: >
{%- set event=states.calendar.holidays_in_united_states.attributes.message %}
{%- if event == 'Christmas Day' %}
true
{%- endif -%}
action:
- service: script.twitter_notify_image
data_template:
tweet: From everyone at Anchorage House, Merry Christmas!
image: /config/www/tweet_images/merry-christmas.jpg
- id: Skylar Day Tweet
alias: Skylar Day Tweet
initial_state: true
trigger:
- platform: time
at: '08:13:00'
condition:
- condition: state
entity_id: calendar.birthdays
state: "on"
- condition: template
value_template: >
{%- set event=states. calendar.birthdays.attributes.message %}
{%- if event == "Skylar's Birthday" %}
true
{%- endif -%}
action:
# - service: script.speech_engine
# data:
# who: main
# message: >
# May I have your attention. At this very monent {{ states.sensor.birthday_skylar.attributes.years }} years ago, Skylar was born and the world has been better ever since.
- service: script.twitter_notify
data_template:
message: Today is a very special day here at Anchorage House! It is Skylar's birthday! So have some cake and play some minecraft. Live Feed from the Kitchen -> https://www.youtube.com/watch?v=JOBYJrVQm3A
- id: Freeze Warning Tweet
alias: Freeze Warning Tweet
trigger:
- platform: time
at: '08:00:00'
condition:
- condition: state
entity_id: input_boolean.freeze_warning
state: 'on'
action:
- delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00'
- service: script.twitter_notify_image
data_template:
tweet: >-
{{ [ "Appears that the temperature will be below freezing soon. I think I will stay inside.",
"The forecasted temperature may kill sensative plants, so I will let the house know. I cannot through inaction allow another to come to harm.",
"Winter is coming. Actually it is already here. I suggest sleeping with Dragon Glass.",
"When the temperature is forcasted to get near freezing, or the NWS issues a Freeze Warning I make sure the residents of Anchorage House know."
] | random }}
image: >-
{{ [ "/config/www/tweet_images/ice.jpg",
"/config/www/tweet_images/snowfall.jpg",
"/config/www/tweet_images/snowflake.jpg"] | random }}
- id: new_pull_request
alias: New Pull Request
initial_state: true
trigger:
- platform: state
entity_id: sensor.open_pull_requests
condition:
- condition: template
value_template: '{{ states.sensor.open_pull_requests.state | int > 0 }}'
action:
- service: script.text_notify
data_template:
who: "jeff"
title: "New Pull Request"
message: >-
{%- if states.sensor.open_pull_requests.state | int == 1 -%}
There is {{ states.sensor.open_pull_requests.state }} pending pull request.
{%- else -%}
There are {{ states.sensor.open_pull_requests.state }} pending pull requests.
{%- endif -%}
- service: script.twitter_notify_image
data_template:
tweet: >-
{{ [
"Look at that. There is a new pull request waiting to be merged. You can create one too by contributing to my code at https://github.com/thejeffreystone/home-assistant-configuration #coding #opensource",
"Fork Yes! Someone contributed some code to https://github.com/thejeffreystone/home-assistant-configuration and you could to. #coding #opensource.",
"Thanks for the code kind stanger. Join the fun at https://github.com/thejeffreystone/home-assistant-configuration #coding #opensource",
"Theres been an awakening. Have you felt it? I will merge it so it can become the master. https://github.com/thejeffreystone/home-assistant-configuration #coding #opensource"
] | random }}
image: >-
{{ [ "/config/www/tweet_images/code.jpg",
"/config/www/tweet_images/codeing.jpg",
"/config/www/tweet_images/code2.jpg",
"/config/www/tweet_images/computer.jpg"] | random }}
- id: national_holiday_tweet
alias: National Holiday Tweet
initial_state: true
trigger:
- platform: time
at: '07:00:00'
condition:
- condition: state
entity_id: calendar.national_holidays
state: "on"
- condition: template
value_template: >
{%- set event=states.calendar.national_holidays.attributes.message %}
{% if 'Day' in event %}
true
{%- endif -%}
- condition: template
value_template: >
{%- set event=states.calendar.national_holidays.attributes.message %}
{% if 'National' in event %}
true
{%- endif -%}
action:
- delay: '0{{ (range(1, 3)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00'
- service: script.twitter_notify
data_template:
message: >-
{{ [ "Hey, Look at that. It is {{states.calendar.national_holidays.attributes.message}}. So Happy {{states.calendar.national_holidays.attributes.message}}! #nationalholiday #themoreyouknow",
"I bet you did not know today was {{states.calendar.national_holidays.attributes.message}}. How will you celebrate? #nationalholiday #themoreyouknow",
"Happy {{states.calendar.national_holidays.attributes.message}}! #nationalholiday #themoreyouknow",
"Whats with today, today? It is {{states.calendar.national_holidays.attributes.message}}. #nationalholiday #themoreyouknow",
"Did you know today was {{states.calendar.national_holidays.attributes.message}}? Now you do. That is why I am here. Tweeting. #nationalholiday #themoreyouknow",
"I already let my residents know that today is {{states.calendar.national_holidays.attributes.message}}. But I didn't want to leave you guys out. #nationalholiday #themoreyouknow",
"I hope you have a fun {{states.calendar.national_holidays.attributes.message}}. #nationalholiday #themoreyouknow"
] | random }}
# - id: tweet_covid19_stats
# alias: Tweet Some Covid Stats
# initial_state: true
# trigger:
# - 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.twitter_notify
# data_template:
# message: >-
# COVID-19 Stats for yesterday in the US: New Infections: {{ states.sensor.covid_pv_new_cases.state }} (Daily Change:{{ (((states.sensor.covid_pv_new_cases.state |replace(",", "") | int - states.sensor.covid_old_new_count.state |replace(",", "") | int) / states.sensor.covid_pv_new_cases.state |replace(",", "") | int * 100) | round)}}%) | New Deaths: {{ states.sensor.covid_pv_new_dead.state}} (Daily Change:{{ (((states.sensor.covid_pv_new_dead.state |replace(",", "") | int - states.sensor.covid_old_dead_count.state |replace(",", "") | int) / states.sensor.covid_pv_new_dead.state |replace(",", "") | int * 100) | round)}}%) | Total Cases: {{ states.sensor.covid_pv_confirmed.state }} | Total Dead:{{ states.sensor.covid_pv_dead.state }} | Total Recovered: {{ states.sensor.covid_pv_recovered.state }} ({{ ((states.sensor.covid_pv_recovered.state |replace(",", "") | int / states.sensor.covid_pv_confirmed.state |replace(",", "") | int) * 100) | round }}%)| Critical Cases: {{ states.sensor.covid_pv_critical.state }}