Accessing camera stream externally

I use the following link to access by cameras.

http:///api/camera_proxy_stream/camera.frontdoor?token=<generated_one_time_token>
I pick up the token as an attribute and pass it to the url which is emailed to me.
This one_time_token expires within a few minutes so if I don’t check it right away, it becomes invalid.

I could use
http:///api/camera_proxy_stream/camera.frontdoor?api_password=<API_password>
but I don’t like having my password exposed in the url

Is it possible to use a “Long-Lived Access Token” The link on that page shows how to pass it in as a header but not how to use it in the url.

2018-10-10_16-48-06

token should be possible but i have not figured out how yet

I removed the lagacy (Depricated) api password from ha but now the camera proxy does not work any more
Did you solved the above issue?

have you figured out?

1 Like

Also looking for an answer on this as I would like to include camera feeds in my HA-Dashboard without passing user/pass.

1 Like

If you run in local network you can probably use allowed networks configuration.

I figured it out using an extra template sensor.

- platform: template
    sensors:
      cam.###token:
        value_template: "{{ state_attr('camera.###', 'access_token') }}"

I don’t know how to write it in an homeassistant automation,
but using NodeRed it is possible to add the token to the rest of the url before sending it in a notification.
example_url: https://hass.#####.##/api/camera_proxy_stream/camera.###?token=+sensor.cam.###token
When the token updates, the sensor value updates also. No need voor http password.

I’m using it with html5 notifications on android/chrome to send me an image when movement is detected. When i click the image in the notification, it shows the livestream of the camera.

@Jplmn, could you share an example of your html5 notification in NodeRed? I’m currently doing the same thing using the normal yaml automation but it doesn’t seem like api_password is working anymore to view the live feed… I end up getting a 401 unauthorized error…

1 Like

I would also like to see an example please!

i tried to do ur template sensor, and i can see the value of the token correctly in developer tool states
but i cant figure out how to add it to nodered for it to successfully access the image.

this is my code in nodered html5 notification which doesnt seem to work

{
“message”: “Deck Door is OPEN!”,
“target”: [
“person a phone”,
“person b phone”
],
“data”: {
“image”: “http://xxxx.xxxx.org:8123/api/camera_proxy_stream/camera.living_room_camera?token=+sensor.cam_livingtoken
}
}

not sure if someone is still interested but maybe it helps a noob like me :wink:
I was also not able to send a notification with a picture, so I tried it as Jplmn suggested.
As I’m an absolut beginner, I will explain as a beginner how I did it

modify configuration.yaml and add

sensor: !include sensors.yaml

created a sensors.yaml in the config folder (this is just to keep things clear, can be done directly in the configuration.yaml as well)

modify sensors.yaml

   - platform: template
     sensors:
        cam_token:
           value_template: "{{ state_attr('camera.garten', 'access_token') }}"

open node red:

  1. event: sate node (tigger)
  2. switch (do sort between different values ( on/off , im my case)
  3. current state node: Entity ID: sensor.cam_token, State Location is set to msg.token
  4. function node:
msg.payload =
{
   "data": {
      "title": "Haustür",
      "message": "Jemand hat geklingelt",
      "data": {
         "image": "http://XXXX.duckdns.org:8123/api/camera_proxy/camera.garten?token="+msg.token
      }
   }
}
return msg;
  1. call service node: Domain: notify, Service: mobile_app_my_phone

That’s it, it works perfect.

Why do not simply get attributes.entity_picture from current state node of camera entity and add it to url?
No extra sensor creation needed :sunglasses:

Would you like to elaborate on how to do this for the less knowledgeable like myself?
An example would be nice.

Sure, here you go:

[
    {
        "id": "f08876ae.9612a8",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "81462ff.125bfd",
        "type": "api-call-service",
        "z": "f08876ae.9612a8",
        "name": "Motion detection notification",
        "server": "9eef096.9ae42f8",
        "version": 1,
        "debugenabled": false,
        "service_domain": "notify",
        "service": "mobile_app_mi_8_pro",
        "entityId": "",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 680,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "9fb296ce.be4b08",
        "type": "api-current-state",
        "z": "f08876ae.9612a8",
        "name": "Camera",
        "server": "9eef096.9ae42f8",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "camera.yihack_v4",
        "state_type": "str",
        "state_location": "",
        "override_payload": "none",
        "entity_location": "token",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 340,
        "y": 160,
        "wires": [
            [
                "f7811ac0.57c8e8"
            ]
        ]
    },
    {
        "id": "f7811ac0.57c8e8",
        "type": "function",
        "z": "f08876ae.9612a8",
        "name": "Get token",
        "func": "msg.payload = \n{\n    \"data\": {\n        \"title\": \"Your title\",\n        \"message\": \"Your message\",\n        \"data\": {\n            \"image\": \"https://domain.com\"+msg.token.attributes.entity_picture\n        }\n    }\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 480,
        "y": 160,
        "wires": [
            [
                "81462ff.125bfd"
            ]
        ]
    },
    {
        "id": "7fd94a30.560ab4",
        "type": "inject",
        "z": "f08876ae.9612a8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 180,
        "y": 160,
        "wires": [
            [
                "9fb296ce.be4b08"
            ]
        ]
    },
    {
        "id": "9eef096.9ae42f8",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "addon": true
    }
]

Thanks, I’ll give this a go.

That worked lovely, Thanks a million.

Came across this and wanted to point out for anyone else looking at this in the future, that you dont even need to specify the token if you are using home assistant companion mobile app and node red on your home assistant server. The below works fine as a notification.

{ "message": "Motion Detected Outside.", "data": { "image": "/api/camera_proxy/camera.front_door_camera" } }

anyone ever figure out how to make this work with a single url from his original question? I am trying to do the same thing, but I haven’t been able to figure it out yet. The camera token works, but it changes every 5 minutes, so I was hoping to be able to use a long lived one to pull into frigate for some object detection.

@broyuken1
Did you figure this out in the end?

No, I gave up on it. I’ll give it another shot when I replace my cameras with something local instead of ring

without nodered:

service: notify.notify
data:
  title: Centralina Allarme
  message: >-
    test
  data:
    ttl: 0
    priority: high
    image: >-
      /api/camera_proxy/camera.camera_hub_g3_120c?token={{state_attr('camera.camera_hub_g3_120c',
      'access_token') }}
    clickAction: >-
      /api/camera_proxy/camera.camera_hub_g3_120c?token={{state_attr('camera.camera_hub_g3_120c',
      'access_token') }}