#-------------------------------------------
# @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# Conico Cameras via Alexa Media Player
#-------------------------------------------
######################################################################
##  Conico Camera - https://amzn.to/2Kl1eHo
######################################################################


######################################################################
##  Show Camera on Echo Shows for 20 minutes after garage door opens.
##  Show Image based on where Home Assistant thinks we are.
######################################################################

automation:
  - alias: 'Garage Camera on Alexa Shows'
    id: 4373df2a-77f2-4e19-be7c-46c7b27ca583
    mode: single
    trigger:
      - platform: state
        entity_id:
          - cover.large_garage_door
          - cover.small_garage_door
        from: 'closed'
        to: 'open'

      - platform: state
        entity_id: binary_sensor.mcu1_gpio12 #interior Garage Doors
        from: 'off'
        to: 'on'

    action:
      - choose:
          - conditions: "{{ is_state('binary_sensor.sleepnumber_carlo_stacey_is_in_bed','on') }}"
            sequence:
              - service: media_player.play_media
                data:
                  entity_id: media_player.stacey_bedroom
                  media_content_id: 'show garage camera'
                  media_content_type: custom
              - delay: '00:10:00'
              - service: media_player.play_media
                data:
                  entity_id: media_player.stacey_bedroom
                  media_content_id: 'hide garage camera'
                  media_content_type: custom

          - conditions: "{{ is_state('switch.kitchen_accent_1','on') }}"
            sequence:
              - service: media_player.play_media
                data:
                  entity_id: media_player.alarm_panel_1
                  media_content_id: 'show garage camera'
                  media_content_type: custom

        default:
          - service: media_player.play_media
            data:
              entity_id: media_player.kitchen_show
              media_content_id: 'show garage camera'
              media_content_type: custom
          - delay: '00:20:00'
          - service: media_player.play_media
            data:
              entity_id: media_player.stacey_bedroom
              media_content_id: 'hide garage camera'
              media_content_type: custom

          - service: script.garage_lights_off