#-------------------------------------------
# Conico Cameras Configuration
# Description: Integrates Conico Cameras with Alexa Media Player
# Last Updated: 2023-11-15
#
# Features:
# - Displays garage camera feed on Echo Show devices
# - Triggers based on garage door state and occupancy changes
#
# Hardware:
# - Conico Camera: https://amzn.to/2Kl1eHo
# - Amazon Echo Show devices
#
# Integration: Alexa Media Player
#
# Original Repo: https://github.com/CCOSTAN/Home-AssistantConfig
# Blog Post: https://www.vcloudinfo.com/2019/03/integrating-smart-cameras-with-alexa-echo-shows.html
# Follow me on https://www.vcloudinfo.com/click-here
#-------------------------------------------


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' 

      - platform: state
        entity_id:
          - person.carlo
          - person.stacey
          - person.paige
          - person.justin
        to: 'not_home'
        from: 'home'    

    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
            target:
              entity_id: media_player.kitchen
            data:
              media_content_id: 'show garage camera'
              media_content_type: custom
          - delay: '00:20:00'
          - service: media_player.play_media
            target:
              entity_id: media_player.kitchen
            data:
              media_content_id: 'hide garage camera'
              media_content_type: custom

          - service: script.garage_lights_off