Home-AssistantConfig/config/packages/space.yaml

136 lines
5.2 KiB
YAML
Raw Normal View History

2018-01-02 00:00:45 +00:00
#-------------------------------------------
# Space Related Packages
# @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
#-------------------------------------------
#------ISS----------------------------------
homeassistant:
customize:
binary_sensor.iss:
icon: mdi:satellite-variant
friendly_name: ISS Visibility
2018-01-07 15:35:32 +00:00
2018-01-02 00:00:45 +00:00
hidden: False
homebridge_hidden: true
sensor.launch_window:
hidden: False
icon: mdi:rocket
friendly_name: Rocket Launch Window
#-------------------------------------------
binary_sensor:
- platform: iss
show_on_map: False
#-------------------------------------------
sensor:
2018-01-06 18:38:58 +00:00
- platform: moon
2018-01-02 00:00:45 +00:00
- platform: rest
scan_interval: 1800
2018-01-02 00:00:45 +00:00
resource: https://launchlibrary.net/1.2.2/launch/next/10
# resource: https://raw.githubusercontent.com/cribbstechnologies/ha_config/master/www/test_launch.json
name: launch window
# if the current timestamp is in the launch window
# this sensor will return the UTC timestamp of the launch
value_template: >-
{%- for launch in value_json.launches %}
{% if launch.location.id == 16 or launch.location.id == 17 %}
{% if strptime(launch.isostart, '%Y%m%dT%H%M%SZ').strftime('%Y-%m-%d') == now().strftime('%Y-%m-%d') %}
{% set utc_offset_string = now().strftime('%z') %}
{% set utc_offset_direction = utc_offset_string[:1] %}
{% set utc_offset_hours = now().strftime('%z')[-4:] %}
{% set utc_offset_seconds = (utc_offset_hours| int /100) * 60 * 60 %}
{% if utc_offset_direction == '-' %}
{{ launch.wsstamp - utc_offset_seconds}}
{% else %}
{{ launch.wsstamp + utc_offset_seconds}}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
automation:
- alias: Launch Window Approaching
trigger:
- platform: state
entity_id: sensor.launch_window
condition:
condition: and
conditions:
- condition: template
value_template: "{{states('sensor.launch_window') != 'unknown'}}"
- condition: template
value_template: "{{as_timestamp(now()) < (states('sensor.launch_window') | float)}}"
action:
- wait_template: >-
{{as_timestamp(now()) >= ((states('sensor.launch_window') | float) - 1800)}}
2018-01-02 00:00:45 +00:00
- service: script.notify_engine
data_template:
value1: 'There will be a rocket Launch today - I will notify you later when the launch window starts'
- wait_template: >-
{{as_timestamp(now()) >= ((states('sensor.launch_window') | float) - 300)}}
2018-01-02 00:00:45 +00:00
- service: script.notify_engine
data_template:
value1: 'Go Outside! There is a Rocket Launch very soon!'
2018-01-02 00:00:45 +00:00
- service: script.tweet_engine
data_template:
tweet: 'There is a Rocket launch happening right now! I can see it if I look closely. @BrianCribbs #SpaceX #Space'
# This automation was also moved to a macro in the speech_engine.
# It's a random fact now.
- alias: 'ISS is above Me -Tweet'
trigger:
- platform: state
entity_id:
- binary_sensor.iss
to: 'on'
from: 'off'
action:
2018-03-17 16:47:27 +00:00
- service: script.tweet_engine_image
2018-01-02 00:00:45 +00:00
data_template:
2018-03-17 16:47:27 +00:00
tweet: >-
2018-01-02 00:00:45 +00:00
{{ [
"The ISS is above me right now!",
"The International Space Station flys by once a day & that time is NOW! (For me)",
2018-01-06 04:07:40 +00:00
"I can look up RIGHT NOW and see the International Space Station.",
2018-02-11 15:40:13 +00:00
"The #ISS just flew by and there is 1 Starman driving a #Tesla and {{states.binary_sensor.iss.attributes.number_of_people_in_space}} people in",
2018-01-07 15:35:32 +00:00
"The #ISS just flew by and there are {{states.binary_sensor.iss.attributes.number_of_people_in_space}} people in",
2018-01-02 00:00:45 +00:00
"The International Space Station Rocks! And it's above me RIGHT NOW!"
] | random + " #Space"}}
2018-03-17 16:47:27 +00:00
image: >-
{{ [
"/config/www/custom_ui/floorplan/images/branding/space.png",
"/config/www/custom_ui/floorplan/images/branding/space2.png",
"/config/www/custom_ui/floorplan/images/branding/starman.png"
] | random }}
2018-01-02 00:00:45 +00:00
- alias: 'Full Moon -Tweet'
trigger:
- platform: state
entity_id: sensor.moon
to: 'Full Moon'
action:
- delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00'
2018-03-17 16:47:27 +00:00
- service: script.tweet_engine_image
2018-01-02 00:00:45 +00:00
data_template:
2018-03-17 16:47:27 +00:00
tweet: >-
2018-01-02 00:00:45 +00:00
{{ [
"There is a Full Moon out tonight!",
"Wish my solar panels picked up Moon rays. Full Moon out tonight.",
"Turn down the lights, there is a Full Moon out tonight.",
"Get out your telescopes, it'll be a Full Moon out tonight!"
] | random + "#Space"}}
2018-03-17 16:47:27 +00:00
image: >-
{{ [
"/config/www/custom_ui/floorplan/images/branding/moon.png",
"/config/www/custom_ui/floorplan/images/branding/moon2.png",
"/config/www/custom_ui/floorplan/images/branding/moon3.png",
"/config/www/custom_ui/floorplan/images/branding/starman.png"
] | random }}