351 lines
11 KiB
YAML
Executable File
351 lines
11 KiB
YAML
Executable File
#-------------------------------------------
|
|
# This is the configuration account for @BearStoneHA - My Homes 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_front_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'
|
|
entity_id: []
|
|
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'
|
|
entity_id: []
|
|
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'
|
|
entity_id: []
|
|
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'
|
|
entity_id: []
|
|
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'
|
|
entity_id: []
|
|
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'
|
|
entity_id: []
|
|
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'
|
|
entity_id: []
|
|
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'
|
|
entity_id: []
|
|
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: 'Random House stats'
|
|
hide_entity: True
|
|
trigger:
|
|
- platform: time_pattern
|
|
hours: '/2'
|
|
minutes: 45
|
|
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",
|
|
"robot",
|
|
"door",
|
|
"weather",
|
|
"cloud",
|
|
"speedtest",
|
|
"internet",
|
|
"stocks",
|
|
"night",
|
|
"tv",
|
|
"promo",
|
|
"joke"
|
|
] %}
|
|
{{ pick|random }}
|
|
|
|
- alias: 'Random YouTube Videos BearStone'
|
|
hide_entity: True
|
|
trigger:
|
|
- platform: time_pattern
|
|
hours: '/3'
|
|
minutes: 18
|
|
condition:
|
|
- condition: template
|
|
value_template: >
|
|
{%- if states.automation.random_youtube_videos_bearstone.attributes.last_triggered -%}
|
|
{{ (as_timestamp(now()) - as_timestamp(states.automation.random_youtube_videos_bearstone.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_youtube_engine_setup
|
|
data_template:
|
|
pick: >-
|
|
{% set pick = [
|
|
"ThrowBack", "S01E01", "S01E02","S01E03", "S01E04","S01E05", "S01E06","S01E07", "S01E08","S01E09", "S01E10",
|
|
"S01E11", "S01E12","S01E13", "S01E14","S01E15", "S01E16","S01E17", "S01E18","S01E19", "S01E20", "S01E21",
|
|
"S02E01", "S02E02","S02E03", "S02E04","S02E05", "S02E06","S02E07", "S02E08","S02E09", "S02E10",
|
|
"S02E11", "S02E12","S02E13", "S02E14","S02E15", "S02E16","S02E17", "S02E18","S02E19", "S02E20",
|
|
"S02E22", "S02E25", "S02E26", "S02E27", "S02E28", "S02E29"
|
|
] %}
|
|
{{ pick|random }}
|
|
|
|
- alias: 'Random YouTube Videos CCostan'
|
|
hide_entity: True
|
|
trigger:
|
|
- platform: time_pattern
|
|
hours: '/22'
|
|
minutes: 45
|
|
condition:
|
|
- condition: template
|
|
value_template: >
|
|
{%- if states.automation.random_youtube_videos_ccostan.attributes.last_triggered -%}
|
|
{{ (as_timestamp(now()) - as_timestamp(states.automation.random_youtube_videos_ccostan.attributes.last_triggered)) > 10000 }}
|
|
{%- else -%}
|
|
true
|
|
{%- endif -%}
|
|
action:
|
|
- service: script.tweet_youtube_engine_setup
|
|
data_template:
|
|
who: 'ccostan'
|
|
pick: >-
|
|
{% set pick = [
|
|
"ThrowBack", "S01E01", "S01E02","S01E03", "S01E04","S01E05", "S01E06","S01E07", "S01E08","S01E09", "S01E10",
|
|
"S01E11", "S01E12","S01E13", "S01E14","S01E15", "S01E16","S01E17", "S01E18","S01E19", "S01E20", "S01E21",
|
|
"S02E01", "S02E02","S02E03", "S02E04","S02E05", "S02E06","S02E07", "S02E08","S02E09", "S02E10",
|
|
"S02E11", "S02E12","S02E13", "S02E14","S02E15", "S02E16","S02E17", "S02E18","S02E19", "S02E20",
|
|
"S02E22", "S02E25", "S02E26", "S02E27", "S02E28", "S02E29"
|
|
] %}
|
|
{{ pick|random }}
|