jeroenterheerdt / ring-hassio

A Home Assistant add-on for live streaming from Ring devices.
MIT License
131 stars 93 forks source link

Turnon / turnoff #14

Open jeroenterheerdt opened 4 years ago

jeroenterheerdt commented 4 years ago

implement turn_on / turn_off services (https://www.home-assistant.io/integrations/camera/)? auto close setting: 15 minutes max? card setting: click to enable image + on-click toggle or call service?

Devqon commented 4 years ago

What are your ideas on this? I currently use an automation to start the addon, but also would like to start the stream when requesting the camera stream from lovelace for example.

Currently I have this:

# packages/doorbell.yaml
camera:
  - platform: generic
    name: Ring Livestream
    stream_source: !secret ring_stream_url
    still_image_url: !secret ring_stream_url

sensor:
  - platform: rest
    name: ring_addon_state
    resource: !secret ring_addon_url
    headers:
      Authorization: !secret long_lived_access_token_ring
      Content-Type: application/json
    value_template: "{{value_json['data']['state']}}" 

switch:
  - platform: template
    switches:
      ring_live_stream:
        value_template: "{{ is_state('sensor.ring_addon_state', 'started') }}"
        turn_on:
          service: hassio.addon_start
          data:
            addon: !secret ring_addon
        turn_off:
          service: hassio.addon_stop
          data:
            addon: !secret ring_addon

automation:
  - alias: Turn on Ring livestream
    trigger:
      - platform: state
        entity_id:
          - binary_sensor.voordeur_motion
          - binary_sensor.voordeur_ding
        to: 'on'
    action:
      service: switch.turn_on
      entity_id: switch.ring_live_stream
  - alias: Turn off Ring livestream
    trigger:
      - platform: state
        entity_id: sensor.ring_addon_state
        to: 'started
        for:
          # 10 minutes is the hardcoded duration in the addon
          minutes: 10
    action:
      service: switch.turn_off
      entity_id: switch.ring_live_stream

# lovelace/doorbell.yaml
icon: 'mdi:doorbell-video'
path: doorbell
badges: []
cards:
  - type: entities
    entities:
      - entity: sensor.voordeur_last_ding
      - entity: sensor.voordeur_last_motion
    show_header_toggle: false
  - type: entities
    entities:
      - switch.ring_live_stream
  - type: picture-glance
    title: Voordeur
    entities:
      - entity: binary_sensor.voordeur_motion
      - entity: binary_sensor.voordeur_ding
    aspect_ratio: 0%
    camera_image: camera.ring_livestream
    camera_view: live
    image: 'https://demo.home-assistant.io/stub_config/kitchen.png'

what is your setup?

jeroenterheerdt commented 4 years ago

yeah, so.... really I have no actual answer here. I would like to do the same: start the addon when the stream is requested from lovelace, but I don't see any way of doing it. if you figure it out, let me know.

jeroenterheerdt commented 3 years ago

@Devqon I never got the REST sensor to work, maybe something to do with NGINX that I am using, are you using that as well?

Toolhead commented 3 years ago

Cannot get the sensor working either. Really do not know if the word "Bearer" should be in there, or the "[" and "]" also. Tried every possible combo, I think.

nytram-md commented 3 years ago

I too am not sure.

I've tried "Bearer RING LIVE" and "Bearer LONGKEY" Long key been the multi character/numeric key generated.

A clearer description on this would be appreciated on this bit.

Thanks in advance

Martyn

bkr1969 commented 2 years ago

From where do you get the ring_addon_url?