mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-02-13 05:20:27 +00:00
215 lines
9.4 KiB
YAML
Executable File
215 lines
9.4 KiB
YAML
Executable File
######################################################################################################
|
|
###Script to send notifications to Twitter as @BearStoneHA.
|
|
## Publish on Facebook as well - https://www.facebook.com/BearStoneHA/
|
|
## Enhancements by @dale3h
|
|
######################################################################################################
|
|
|
|
tweet_engine_setup:
|
|
sequence:
|
|
- service: script.tweet_engine_image
|
|
data_template:
|
|
tweet: >-
|
|
{%- macro minecraft() -%}
|
|
{{ [
|
|
"There are {{states.sensor.bear_stone.state}} #Minecraft users online at the momemt. #KidStat"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro solar() -%}
|
|
{{ [
|
|
"I am keeping track of the current #Tesla stock price. It is {{ states.sensor.tesla.state | round }} dollars. #Solar",
|
|
"The #ChevyBolt has been charging for about {{states.sensor.bolt_charging_time.attributes.value}}inutes in the last 7 days."
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro robot() -%}
|
|
{{ [
|
|
"Beep. Bop. Beep. Boop. I am a #roBOT run by @CCostan",
|
|
"The #ChevyBolt has been charging for about {{states.sensor.bolt_charging_time.attributes.value}}inutes in the last 7 days.",
|
|
"I have spoken for about {{states.sensor.speech_time.attributes.value}}inutes in the last 24 hours.",
|
|
"When you add it all up, I have spoken for about {{states.sensor.speech_time.attributes.value}}inutes in the last 24 hours!",
|
|
"The #Docker Host has been running for {{states.sensor.since_last_boot_templated.state}} (http://www.vmwareinfo.com/2018/02/journey-to-docker.html)",
|
|
"The #Docker Host for Home Assistant is using {{states.sensor.disk_use_percent_.state}}% of the hard drive currently. (http://www.vmwareinfo.com/2018/02/journey-to-docker.html)",
|
|
"My Home Assistant Database is currently using {{states.sensor.database_sensor.state}} MBs. To get this #Stat for your HA, visit (https://github.com/robmarkcole/HASS-filesize-sensor)",
|
|
"I am running Home Assistant version {{states.sensor.ha_installed_version.state}} (https://github.com/CCOSTAN/Home-AssistantConfig)",
|
|
"Home Assistant has been running for {{states.sensor.ha_uptime.state}}. (https://github.com/CCOSTAN/Home-AssistantConfig)"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro door() -%}
|
|
{{ [
|
|
"The number of Doorbell presses yesterday was {{states.sensor.doorbell_presses.state}}",
|
|
"{{states.sensor.doorbell_presses.state}} people came to the door today and pressed the bell.",
|
|
"{{states.sensor.doorbell_presses.state}} doorbell presses occurred in the last 24 hours."
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro weather() -%}
|
|
{{ [
|
|
"The #Landscaping lights where on for about {{states.sensor.landscaping_light_time.attributes.value}} yesterday.",
|
|
"I keep the average humidity of the house at {{states.sensor.downstairs_thermostat_humidity.state}} percent. Outside is {{states.sensor.dark_sky_humidity.state}} #Nest (http://amzn.to/2BWNk5N)",
|
|
"Outside is {{states.sensor.dark_sky_temperature.state}}. I keep the average temperature at {{states.sensor.downstairs_thermostat_temperature.state}}. #Weather (http://amzn.to/2BWNk5N)",
|
|
"I know that it will be {{states.sensor.dark_sky_minutely_summary.state}} So I will adjust the Heating/Cooling, irrigation and lighting accordingly. #Nest #Rachio #Hue",
|
|
"The current UV index is {{states.sensor.dark_sky_uv_index.state}} and the Moon is {{states.sensor.moon.state}}. #Space",
|
|
"Average Cloud Coverage: {{states.sensor.dark_sky_cloud_coverage.state}}%, Average Temp: {{states.sensor.dark_sky_temperature.state}}°F #Solar (http://www.vmwareinfo.com/2018/01/going-green-to-save-some-green-in-2018.html)"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro internet() -%}
|
|
{{ [
|
|
"So far, I have prevented {{states.sensor.pihole_ads_blocked_today.state}} ads from hitting the network via Pi-hole! http://www.pi-hole.net",
|
|
"Pi-hole (http://www.pi-hole.net) has serviced {{states.sensor.pihole_dns_queries_today.state}} DNS requests today! #PiZero",
|
|
"Average internet stats are Download: {{states.sensor.speedtest_download.state}} Mbit/s & Upload {{states.sensor.speedtest_upload.state}} Mbit/s.",
|
|
"My @getspectrum internet download speed is about {{states.sensor.speedtest_download.state}} Mbit/s and I am a #cordcutter. @TabloTV",
|
|
"Yesterday we watched about {{states.sensor.tv_time.attributes.value}}inutes of television. @YouTube & @TabloTV on the @Roku"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro stocks() -%}
|
|
{{ [
|
|
"I am keeping track of the current #Tesla stock price. It is {{ states.sensor.tesla.state | round }} dollars. #Solar",
|
|
"I am keeping track of the current #Bitcoin prices. It is {{ states.sensor.bitcoin.state | round }} dollars. #BTC"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro night() -%}
|
|
{{ [
|
|
"Todays Sleep Number is {{states.sensor.sleepnumber_carlo_stacey_sleepnumber.state}}. Wifi connected Bed FTW! #SleepStat (http://amzn.to/2D10BcQ)",
|
|
"Our Sleep Number is {{states.sensor.sleepnumber_carlo_carlo_sleepnumber.state}}. Wifi connected Bed! #SleepStat (http://amzn.to/2D10BcQ)"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro tv() -%}
|
|
{{ [
|
|
"The {{states.media_player.living_room_ultra.attributes.friendly_name}} #Roku is playing #{{states.media_player.living_room_ultra.attributes.app_name}}.",
|
|
"The {{states.media_player.upstairs_living_room.attributes.friendly_name}} #Roku is playing #{{states.media_player.upstairs_living_room.attributes.app_name}}. (http://amzn.to/2lYZEup)"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- set tweet_macros = {
|
|
"minecraft": minecraft,
|
|
"solar": solar,
|
|
"robot": robot,
|
|
"door": door,
|
|
"weather": weather,
|
|
"internet": internet,
|
|
"stocks": stocks,
|
|
"night": night,
|
|
"tv": tv,
|
|
} -%}
|
|
|
|
{{ tweet_macros[pick]() }}
|
|
|
|
image: >-
|
|
{%- macro minecraft_image() -%}
|
|
{{ [
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro solar_image() -%}
|
|
{{ [
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro robot_image() -%}
|
|
{{ [
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro door_image() -%}
|
|
{{ [
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro weather_image() -%}
|
|
{{ [
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro internet_image() -%}
|
|
{{ [
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro stocks_image() -%}
|
|
{{ [
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro night_image() -%}
|
|
{{ [
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro TV_image() -%}
|
|
{{ [
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png"
|
|
]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{%- set image_macros = {
|
|
"minecraft": minecraft_image,
|
|
"solar": solar_image,
|
|
"robot": robot_image,
|
|
"door": door_image,
|
|
"weather": weather_image,
|
|
"internet": internet_image,
|
|
"stocks": stocks_image,
|
|
"night": night_image,
|
|
"tv": tv_image,
|
|
} -%}
|
|
|
|
{{ image_macros[pick]() }}
|
|
|
|
tweet_engine_image:
|
|
sequence:
|
|
- service: mqtt.publish
|
|
data_template:
|
|
topic: 'ifttt/message'
|
|
payload: >-
|
|
{{ tweet }}
|
|
retain: true
|
|
|
|
- service: notify.BearStoneHA
|
|
data_template:
|
|
message: >-
|
|
{{ tweet }} #IOT #SmartHome
|
|
data:
|
|
media: >-
|
|
{{ image }}
|
|
|
|
tweet_engine:
|
|
sequence:
|
|
- service: mqtt.publish
|
|
data_template:
|
|
topic: 'ifttt/message'
|
|
payload: >-
|
|
{{ tweet }}
|
|
retain: true
|
|
|
|
- service: notify.BearStoneHA
|
|
data_template:
|
|
message: >-
|
|
{{ tweet }} #IOT #SmartHome
|
|
|
|
|
|
|
|
|
|
# - service: ifttt.trigger
|
|
# data_template: {"event":"facebook_tweet", "value1":"{{ tweet }}", "value2":"{{ value2 }}", "value3":"{{ value3 }}"}
|
|
|
|
# - service: ifttt.trigger
|
|
# data_template:
|
|
# event: >-
|
|
# facebook_tweet
|
|
# value1: >
|
|
# {{states.sensor.ifttt_formatted_message.state}} #IOT #SmartHome
|