#------------------------------------------- # 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 ### Building out some Historical stats for tweeting. ##################### sensor: - 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 # - platform: rest # name: July 4th Countdown # resource: http://api.wolframalpha.com/v1/result?appid=JIUY8U-4V8KY45VT1&i=How%20many%20days%20until%204th%20July%202018 # value_template: "{{ (value|replace(' days', '')) | int }}" # unit_of_measurement: Days # scan_interval: 43200``` group: tweet_stats: entities: - sensor.doorbell_presses - sensor.landscaping_light_time - sensor.hvac_time - sensor.speech_time - sensor.tv_time - sensor.bolt_charging_time ############################################################# 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 # - service: script.tweet_engine # data_template: # tweet: >- # {% set handle = trigger.event.data.value1 %} # {% set location = trigger.event.data.location %} # {% set phrases = [ # "Thanks for the Follow " ~ handle ~ "! Chirp the Bird from " ~ location ~ "!!", # "Hey " ~ handle ~ "! Thanks for the Follow from " ~ location ~ " !", # "Sending a #Chirp to " ~ handle ~ " in " ~ location ~ "!", # "New follower " ~ handle ~ " from " ~ location ~ ", I just sounded a chirp in the house.", # "Boom! The " ~ location ~ " follow from " ~ handle ~ " makes me sound a chirp in the house.", # "Wanna know who is super cool? "~ handle ~" IS!!! Thanks for making me CHIRP!", # "If the AMP (http://amzn.to/2j18dlT) is on & I get a new follower like " ~ handle ~ ", I sound a chirp!" # ] %} # {% set hashtags = [ # "#ThanksForTheFollow", # "#FollowBack", # "#ChirpTheHouse", # "#FollowMe", # "#MakingitChirp", # "(http://www.vmwareinfo.com/2017/12/giving-house-twitter-account.html)", # "(http://www.vmwareinfo.com/2017/11/building-digital-cuckoo-clock-with-home.html)" # ] %} # {{ phrases|random ~ " " ~ hashtags|random }} - 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" ] %} {{ pictures|random }} - alias: 'Random House stats' hide_entity: True trigger: - platform: time hours: '/3' minutes: 01 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(10,59) | random | int }}:00' - service: script.tweet_engine_setup data_template: pick: >- {% set pick = [ "minecraft", "solar", "solar", "robot", "robot","robot","robot","robot","robot","robot","robot", "door", "door", "door", "weather", "weather", "weather", "weather", "weather", "weather", "internet", "internet", "internet", "internet", "internet", "stocks", "stocks", "night", "night", "TV", "TV" ] %} {{ pick|random }}