###################################
## Garadget Stuff -  [Garadget](http://amzn.to/2jQLpVQ) - Garage Door opener/sensor
###################################

- alias: 'Wind Speed Garage Door Check'
#  hide_entity: True
  trigger:
    - platform: numeric_state
      entity_id: sensor.dark_sky_wind_speed
      above: 20

  condition:
    - condition: or
      conditions:
        - condition: template
          value_template: "{{ states('cover.large_garage') == 'opened' }}"
        - condition: template
          value_template: "{{ states('cover.small_garage') == 'opened'}}"

  action:
    - service: script.notify_engine
      data_template:
        value1: 'Check Garage Doors:'
        value2: "Small: {{ states('cover.small_garage')}}"
        value3: "Large: {{ states('cover.large_garage')}}"

    - service: input_boolean.turn_on
      entity_id: input_boolean.alert_mode

    - service: script.speech_engine
      data_template:
        value1: >
          "The winds are picking up outside.  The wind speed is {{ states('sensor.dark_sky_wind_speed')|round}} miles per hour.  For safety, please close the garage doors.
          {% if is_state('cover.large_garage', 'open') -%}
            The Large Garage Door is open
          {% endif -%}
          {% if is_state('cover.small_garage', 'open') -%}
            {% if is_state('cover.large_garage', 'open') -%}and
            {%- endif %} The small Garage Door is open.
          {% endif %}"

    - service: script.tweet_engine_image
      data_template:
        tweet: >
          {{ [
          "Wind speed is {{ states('sensor.dark_sky_wind_speed')|round}} miles per hour.  For safety, I'm going to close the @garadget doors.",
          "Getting pretty windy! {{ states('sensor.dark_sky_wind_speed')|round}}MPH. Time to ask @Garadget to close the garage doors."
          ] | random + "(http://amzn.to/2jQLpVQ)"}}
        image: >-
          {{ [
          "/config/www/custom_ui/floorplan/images/branding/windy.png"
          ] | random }}
