208 lines
11 KiB
YAML
Executable File
208 lines
11 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 tweet(topic) -%}
|
|
{% set tweets = {
|
|
"minecraft": [
|
|
"There are {{ states('sensor.bear_stone') }} #Minecraft users online at the momemt. #KidStat"
|
|
],
|
|
|
|
"solar": [
|
|
"I am keeping track of the current #Tesla stock price. It is {{ states('sensor.tesla')|round }} dollars. #Solar",
|
|
"The #ChevyBolt has been charging for about {{ states.sensor.bolt_charging_time.attributes.value|replace('m', '') }} minutes in the last 7 days."
|
|
],
|
|
|
|
"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|replace('m', '') }} minutes in the last 7 days.",
|
|
"I have spoken for about {{ states.sensor.speech_time.attributes.value|replace('m', '') }} minutes in the last 24 hours.",
|
|
"When you add it all up, I have spoken for about {{ states.sensor.speech_time.attributes.value|replace('m', '') }} minutes in the last 24 hours!",
|
|
"The #Docker Host has been running for {{ states('sensor.since_last_boot_templated') }} (http://www.vmwareinfo.com/2018/02/journey-to-docker.html)",
|
|
"The #Docker Host for Home Assistant is using {{ states('sensor.disk_use_percent_') }}% 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') }} 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') }} (https://github.com/CCOSTAN/Home-AssistantConfig#logo)",
|
|
"Home Assistant has been running for {{ states('sensor.ha_uptime') }}. (https://github.com/CCOSTAN/Home-AssistantConfig#logo)",
|
|
"My Home Assistant has been tested by Travis-CI and {{states('sensor.ccostanhomeassistantconfig_state')}}. (https://github.com/CCOSTAN/Home-AssistantConfig#logo)",
|
|
"{{((states.sensor.sensor_count.state | int) + (states.sensor.binary_sensor_count.state | int))}} sensors feed my Smart Home #data. (https://github.com/CCOSTAN/Home-AssistantConfig#logo)",
|
|
"{{states.sensor.automation_count.state}} automations and {{states.sensor.script_count.state}} scripts make my home smart (https://github.com/CCOSTAN/Home-AssistantConfig#logo)",
|
|
"Nevermind me. I am just keeping track of {{states.sensor.lights_count.state}} lights and {{states.sensor.devices_count.state}} devices in the house. (https://github.com/CCOSTAN/Home-AssistantConfig#logo)"
|
|
],
|
|
|
|
"door": [
|
|
"The number of Doorbell presses yesterday was {{ states('sensor.doorbell_presses') }}",
|
|
"{{ states('sensor.doorbell_presses') }} people came to the door today and pressed the bell.",
|
|
"{{ states('sensor.doorbell_presses') }} doorbell presses occurred in the last 24 hours."
|
|
],
|
|
|
|
"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') }} percent. Outside is {{ states('sensor.dark_sky_humidity') }} #Nest (https://github.com/CCOSTAN/Home-AssistantConfig#nest)",
|
|
"Outside is {{ states('sensor.dark_sky_temperature') }}. I keep the average temperature at {{ states('sensor.downstairs_thermostat_temperature') }}. #Weather (https://github.com/CCOSTAN/Home-AssistantConfig#nest)",
|
|
"I know that it will be {{ states('sensor.dark_sky_minutely_summary') }} 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') }} and the Moon is {{ states('sensor.moon') }}. #Space"
|
|
],
|
|
|
|
"cloud": [
|
|
"Average Cloud Coverage: {{ states('sensor.dark_sky_cloud_coverage') }}%, Average Temp: {{ states('sensor.dark_sky_temperature') }}°F #Solar (http://www.vmwareinfo.com/2018/01/going-green-to-save-some-green-in-2018.html)"
|
|
],
|
|
|
|
"internet": [
|
|
"So far, I have prevented {{ states('sensor.pihole_ads_blocked_today') }} 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') }} DNS requests today! #PiZero",
|
|
"Average internet stats are Download: {{ states('sensor.speedtest_download') }} Mbit/s & Upload {{ states('sensor.speedtest_upload') }} Mbit/s.",
|
|
"My @getspectrum internet download speed is about {{ states('sensor.speedtest_download') }} Mbit/s and I am a #cordcutter. @TabloTV"
|
|
],
|
|
|
|
"stocks": [
|
|
"I am keeping track of the current #Tesla stock price. It is {{ states('sensor.tesla')|round }} dollars. #Solar",
|
|
"I am keeping track of the current #Bitcoin prices. It is {{ states('sensor.bitcoin')|round }} dollars. #BTC"
|
|
],
|
|
|
|
"night": [
|
|
"Todays Sleep Number is {{ states('sensor.sleepnumber_carlo_stacey_sleepnumber') }}. Wifi connected Bed FTW! #SleepStat (https://github.com/CCOSTAN/Home-AssistantConfig#nest)",
|
|
"Our Sleep Number is {{ states('sensor.sleepnumber_carlo_carlo_sleepnumber') }}. Wifi connected Bed! #SleepStat (https://github.com/CCOSTAN/Home-AssistantConfig#nest)"
|
|
],
|
|
|
|
"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 }}. (https://github.com/CCOSTAN/Home-AssistantConfig#logo)",
|
|
"Yesterday we watched about {{ states.sensor.tv_time.attributes.value|replace('m', '') }} minutes of television. @YouTube & @TabloTV on the @Roku"
|
|
]
|
|
} %}
|
|
|
|
{{ tweets[topic]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{{ tweet(pick) }}
|
|
|
|
image: >-
|
|
{%- macro image(topic) -%}
|
|
{% set images = {
|
|
"minecraft": [
|
|
"/config/www/custom_ui/floorplan/images/branding/minecraft-icon.png"
|
|
],
|
|
|
|
"solar": [
|
|
"/config/www/custom_ui/floorplan/images/branding/batteries.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/car.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/bear_stone_car.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/charge.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/solar.png"
|
|
],
|
|
|
|
"robot": [
|
|
"/config/www/custom_ui/floorplan/images/branding/servers5.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/servers4.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/robot.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/keyboard.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad4.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/repo_ad.png"
|
|
|
|
],
|
|
|
|
"door": [
|
|
"/config/www/custom_ui/floorplan/images/branding/door.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/camera.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad3.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/repo_ad4.png"
|
|
],
|
|
|
|
"weather": [
|
|
"/config/www/custom_ui/floorplan/images/branding/windy.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/moon.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/repo_ad4.png"
|
|
],
|
|
|
|
"cloud": [
|
|
"/config/www/custom_ui/floorplan/images/branding/clouds.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/clouds2.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/solar.png"
|
|
],
|
|
|
|
"internet": [
|
|
"/config/www/custom_ui/floorplan/images/branding/servers.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/servers2.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/servers3.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/servers4.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/servers5.png"
|
|
],
|
|
|
|
"stocks": [
|
|
"/config/www/custom_ui/floorplan/images/branding/stock.png"
|
|
],
|
|
|
|
"night": [
|
|
"/config/www/custom_ui/floorplan/images/branding/sleeping.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/indoor_light.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/bed.png"
|
|
],
|
|
|
|
"tv": [
|
|
"/config/www/custom_ui/floorplan/images/branding/tv.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/tv2.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/tv3.png",
|
|
"/config/www/custom_ui/floorplan/images/branding/tv4.png"
|
|
]
|
|
} %}
|
|
|
|
{{ images[topic]|random }}
|
|
{%- endmacro -%}
|
|
|
|
{{ image(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
|