Home-AssistantConfig/config/packages/twitter.yaml

328 lines
12 KiB
YAML
Executable File

#-------------------------------------------
# This is the configuration account for @BearStoneHA - My Home's automated twitter account.
# @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
#-------------------------------------------
# homeassistant:
# customize_glob:
# "input_select.log_*":
# icon: mdi:bug
#
# hidden: False
#Random number - https://www.random.org/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new
notify:
- name: BearStoneHA
platform: twitter
consumer_key: !secret twitter_consumer_key
consumer_secret: !secret twitter_consumer_secret
access_token: !secret twitter_access_token
access_token_secret: !secret twitter_access_token_secret
- name: ccostan
platform: twitter
consumer_key: !secret twitter_consumer_key2
consumer_secret: !secret twitter_consumer_secret2
access_token: !secret twitter_access_token2
access_token_secret: !secret twitter_access_token_secret2
### Building out some Historical stats for tweeting. #####################
sensor:
- platform: command_line
command: 'curl https://api.github.com/repos/ccostan/home-assistantconfig'
name: GitHub Stats
scan_interval: 20000
value_template: '{{ value_json.name }}'
json_attributes:
- open_issues
# - subscribers_count
# - forks
- stargazers_count
- platform: history_stats
name: Doorbell Presses
entity_id: binary_sensor.skybell_stone_door_button
state: 'on'
type: count
end: '{{ now() }}'
duration:
hours: 24
- platform: history_stats
name: Speech time
entity_id: media_player.livingroomCC
state: 'playing'
type: time
end: '{{ now() }}'
duration:
hours: 24
- platform: history_stats
name: TV time
entity_id: media_player.living_room_ultra
state: 'playing'
type: time
end: '{{ now() }}'
duration:
hours: 24
- platform: history_stats
name: Landscaping Light time
entity_id: group.landscaping
state: 'on'
type: time
end: '{{ now() }}'
duration:
hours: 24
- platform: history_stats
name: Bolt Charging time
entity_id: sensor.carlojuice_charging_status
state: 'charging'
type: time
end: '{{ now() }}'
duration:
days: 7
### Building some interesting stats for tweeting. ###
- platform: template
sensors:
sensor_count:
friendly_name: 'Number of Sensors'
value_template: >
{%- set domains = ['sensor'] -%}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
automation_count:
friendly_name: 'Number of Automations'
value_template: >
{%- set domains = ['automation'] -%}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
script_count:
friendly_name: 'Number of Scripts'
value_template: >
{%- set domains = ['script'] -%}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
binary_sensor_count:
friendly_name: 'Number of Binary Sensors'
value_template: >
{%- set domains = ['binary_sensor'] -%}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
tracker_count:
friendly_name: 'Number of Devices'
value_template: >
{%- set domains = ['device_tracker'] -%}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
lights_count:
friendly_name: 'Number of Lights'
value_template: >
{%- set domains = ['light'] -%}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
protect_count:
friendly_name: 'Number of Smoke Detectors'
value_template: >
{% if states('group.protects') == 'on' %}
{% for e in states.group.protects.attributes.entity_id if states(e) == 'on' %}
{% if loop.last %}
{{ loop.index }}
{% endif %}
{%- endfor -%}
{% else %}
0
{% endif %}
camera_count:
friendly_name: 'Number of online Cameras'
value_template: >
{%- set domains = ['camera'] -%}
{%- for domain in domains -%}
{%- for item in states[domain] -%}
{% if loop.first %}
{{loop.length}}
{% endif %}
{%- endfor -%}
{%- endfor -%}
group:
tweet_stats:
entities:
- sensor.doorbell_presses
- sensor.landscaping_light_time
- sensor.hvac_time
- sensor.speech_time
- sensor.tv_time
- sensor.bolt_charging_time
- sensor.sensor_count
- sensor.script_count
- sensor.binary_sensor_count
- sensor.automation_count
- sensor.lights_count
- sensor.tracker_count
- sensor.protect_count
- sensor.camera_count
#############################################################
automation:
- alias: 'New Twitter follower!'
hide_entity: True
trigger:
- platform: event
event_type: new_follower
condition:
- condition: state
entity_id: group.bed
state: 'off'
action:
- service: media_player.play_media
data_template:
entity_id:
- media_player.livingroomCC
- media_player.bedroom_alarm_panel
media_content_id: "https://raw.githubusercontent.com/CCOSTAN/Home-AssistantConfig/master/config/sounds/twitter-chirp.mp3"
media_content_type: audio/mp4
- alias: 'Closed Github Issue'
hide_entity: True
trigger:
- platform: event
event_type: closed_github
action:
- service: script.tweet_engine_image
data_template:
tweet: >-
{% set repo = trigger.event.data.repo %}
{% set issue = trigger.event.data.issue %}
{% set issueurl = trigger.event.data.issueurl %}
{% set phrases = [
"New Code: " ~ issue ~ " " ~ issueurl
] %}
{% set hashtags = [
"#Github",
"#SmartHomeCode"
] %}
{{ phrases|random ~ " " ~ hashtags|random }}
image: >-
{% set pictures = [
"/config/www/custom_ui/floorplan/images/branding/repo_ad.png",
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png",
"/config/www/custom_ui/floorplan/images/branding/repo_ad3.png",
"/config/www/custom_ui/floorplan/images/branding/bearstoneflow.png",
"/config/www/custom_ui/floorplan/images/branding/repo_ad4.png"
] %}
{{ pictures|random }}
- alias: 'ThrowBack message'
trigger:
- platform: time
hours: '/28'
minutes: 13
seconds: 00
action:
- service: notify.ccostan
data_template:
message: >-
{% set phrases = [
"One of the most popular #SmartHome Projects I have done: (https://www.vcloudinfo.com/2017/07/visualizing-smart-home-using-home.html)",
"This project was one of the most popular: (https://www.vcloudinfo.com/2017/11/building-digital-cuckoo-clock-with-home.html)",
"Some of the Best Home Assistant resources around! (https://www.vcloudinfo.com/2018/04/some-of-my-favorite-home-assistant.html)",
"My Journey to Docker #ThrowBack - (https://www.vcloudinfo.com/2018/02/journey-to-docker.html)",
"My Popular DIY Motion Sensor #ThrowBack - (https://www.vcloudinfo.com/2017/11/yet-another-inexpensive-motion-sensor.html)",
"Build your own DIY Outdoor Smart Home LED strips - (https://www.vcloudinfo.com/2017/08/diy-outdoor-smart-home-led-strips.html)",
"Breakdown of the entire smart home - (https://www.vcloudinfo.com/2017/07/my-smart-home-look-at-parts-that-make.html)",
"Build your own Home Alarm System - (https://www.vcloudinfo.com/2017/06/building-my-home-alarm-system-hardware.html)",
"Adding a Mixer and AMP to this Text to Speech solution changed the Smart Home COMPLETELY! (https://www.vcloudinfo.com/2017/07/giving-voice-to-smart-home.html)",
"Some of my favorite #Docker Containers that I am using - (https://www.vcloudinfo.com/2018/06/rolling-out-some-new-docker-containers.html)",
"Be Sure to follow all of my Twitter Accounts! @CCostan and my HOUSE bot @BearStoneHA!",
"If you are not subscribed to my Smart Home YouTube channel, come join us now! (https://YouTube.com/ccostan)",
"My Full Smart Home diagram and #IOT icon set that you can download to build your own! - (https://www.vcloudinfo.com/2018/07/the-bear-stone-home-assistant-icon.html),"
"Be sure to like me on Facebook and join our HA group! (https://www.facebook.com/groups/HomeAssistant/) (https://www.facebook.com/VMwareInfo/) (https://www.facebook.com/BearStoneHA/)",
"You can see how ALL of this is done by browsing my GitHub Repository (https://github.com/CCOSTAN/Home-AssistantConfig#logo)",
"10 year safety check. If you haven't done it yet, you need to! (https://www.vcloudinfo.com/2017/06/psa-check-out-your-smoke-detectors-once.html)",
"Breaking down the Home Assistant Flag Sensor (https://www.vcloudinfo.com/2019/02/breaking-down-the-flag-sensor-in-home-assistant.html)"
] %}
{% set hashtags = [
"#Throwback"
] %}
{{ phrases|random ~ " " ~ hashtags|random ~ " #IOT #SmartHome" }}
data:
media: >-
{% set pictures = [
"/config/www/custom_ui/floorplan/images/branding/throwback.png"
] %}
{{ pictures|random }}
- alias: 'Random House stats'
hide_entity: True
trigger:
- platform: time
hours: '/2'
minutes: 45
seconds: 00
condition:
- condition: template
value_template: >
{%- if states.automation.random_house_stats.attributes.last_triggered -%}
{{ (as_timestamp(now()) - as_timestamp(states.automation.random_house_stats.attributes.last_triggered)) > 10000 }}
{%- else -%}
true
{%- endif -%}
action:
- delay: '0{{ range(0,2) | random | int }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}'
- service: script.tweet_engine_setup
data_template:
pick: >-
{% set pick = [
"solar", "solar", "solar",
"robot", "robot", "robot", "robot", "robot", "robot", "robot", "robot", "robot","robot","robot","robot","robot","robot",
"door", "door", "door",
"weather", "weather", "weather", "weather", "weather",
"cloud",
"internet", "internet", "internet", "internet", "internet", "internet", "internet",
"stocks", "stocks", "stocks", "stocks",
"night", "night",
"tv", "tv", "tv",
"throwback",
"promo", "promo"
] %}
{{ pick|random }}