# Receive lan webhook with camera snapshot (surveillance station) in home assistant

**URL:** https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961
**Category:** General
**Tags:** home-assistant
**Created:** [26 August 2022 10:28 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961 "2022-08-26T10:28:21Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [26 August 2022 10:28 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/1 "2022-08-26T10:28:21Z")

</div>

Hi all

I'm struggling to workout how to get node red to receive a webhook notification from surveillance station with snapshot . I have found several node pallets but they seem to be for wan

Has anyone set this up or something similar they can share ?

Thank you

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [26 August 2022 10:35 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/2 "2022-08-26T10:35:23Z")

</div>

> [@djseek](#):
>
> struggling to workout how to get node red to receive a webhook

A webhook simply calls an HTTP endpoint.

node-red can do endpoints: [Node-RED Cookbook : Node-RED](https://cookbook.nodered.org/#http-endpoints)

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [26 August 2022 11:00 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/3 "2022-08-26T11:00:46Z")

</div>

Thank you. I'll just have to workout how to process the snapshot . I have other notifications working with snapshots but that's from my doorbell.

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [27 August 2022 07:26 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/4 "2022-08-27T07:26:08Z")

</div>

So I know how to setup surveillence station to post to a url:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/4/44837727ddcda7d9da10d648157d5263b49a7708.png)

I see http in - it says it's relevant to /endpoint - i'm not sure where the endpoint is configured.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/4/f42906a50f5ba42d6353896b3d94ee467b6e47c2.png)

what sort of response would i need to send? a 200 success?

thank you for the help

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [27 August 2022 07:42 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/5 "2022-08-27T07:42:38Z")

</div>

> [@djseek](#):
>
> it says it's relevant to /endpoint

You mean relative - as in related.

e.g. - if your node-red editor is at `http://192.168.0.2:1880` then `/motion_porch` (as a relative URL) would be at `http://192.168.0.2:1880/motion_porch`

> [@djseek](#):
>
> what sort of response would i need to send? a 200 success?

Probably - but that happens automatically.

To see what is going on, simply return the HTTP request and view what was sent using a debug node...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c7e21181af7be057d43199fc56b84d21365fb298.png)

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [27 August 2022 08:08 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/6 "2022-08-27T08:08:27Z")

</div>

Thank you very much. I should be able to get this going now.

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [27 August 2022 09:32 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/7 "2022-08-27T09:32:24Z")

</div>

i'm running node red within home assistant (add on). So i am using my home assistant URL though that is not working as i'm guessing it's expecting auth.

do you know how I can get it auth'd? would it be via long lived auth token? I see node red has one already to access home assistant. so not sure how to access it

thank you again

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [27 August 2022 09:49 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/8 "2022-08-27T09:49:38Z")

</div>

> [@djseek](#):
>
> i'm running node red within home assistant (add on).

I believe HA adds a slug to the path - open the HTTP-IN node settings editor, I think there is a tooltip or info comment on the edit panel telling you the URL to use

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [27 August 2022 10:04 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/9 "2022-08-27T10:04:22Z")

</div>

not that I can see

> payload  
> For a GET request, contains an object of any query string parameters. Otherwise, contains the body of the HTTP request.  
> reqobject  
> An HTTP request object. This object contains multiple properties that provide information about the request.
> 
> - `body` - the body of the incoming request. The format will depend on the request.
> - `headers` - an object containing the HTTP request headers.
> - `query` - an object containing any query string parameters.
> - `params` - an object containing any route parameters.
> - `cookies` - an object containing the cookies for the request.
> - `files` - if enabled within the node, an object containing any files uploaded as part of a POST request.
> 
> resobject  
> An HTTP response object. This property should not be used directly; the `HTTP Response` node documents how to respond to a request. This property must remain attached to the message passed to the response node.
> 
> ### [Details](http://homeassistant.local:8123/api/hassio_ingress/WtipjhnV2vdfpwnz6cY_5NQO7rVwcDjTJfnC1JPnVLg/#)
> 
> The node will listen on the configured path for requests of a particular type. The path can be fully specified, such as `/user`, or include named parameters that accept any value, such as `/user/:name`. When named parameters are used, their actual value in a request can be accessed under `msg.req.params`.
> 
> For requests that include a body, such as a POST or PUT, the contents of the request is made available as `msg.payload`.
> 
> If the content type of the request can be determined, the body will be parsed to any appropriate type. For example, `application/json` will be parsed to its JavaScript object representation.
> 
> **Note:** this node does not send any response to the request. The flow must include an HTTP Response node to complete the request.
> 
> Notificationdebug 5

Found this thread and going through it now: [HTTP In URL when using Node Red with HASS Supervisor - Node-RED - Home Assistant Community](https://community.home-assistant.io/t/http-in-url-when-using-node-red-with-hass-supervisor/210483) but i think i'll be stuck on auth

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [27 August 2022 10:11 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/10 "2022-08-27T10:11:08Z")

</div>

~~That is the help info. I said on the edit dialog.~~ scratch that, I just spotted your earlier screenshot...

> [@djseek](#):
>
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/4/f42906a50f5ba42d6353896b3d94ee467b6e47c2.png)

So that means your URL would be `http://192.168.0.2:1880/endpoint/motion_porch`

  

PS: It is always helpful to mention "home assistant" in your post (as often the answer is different)

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [27 August 2022 10:22 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/11 "2022-08-27T10:22:53Z")

</div>

Hmm i've tried with and without user/pass on the url and the web request from surveillance station (test) is failing.

[http://user:password@192.168.0.2:1880/endpoint/porch](http://user:password@192.168.0.2:1880/endpoint/porch) ( set it as /porch and porch on the http in) and yeah failing hmm .

once i've got this working this will bring a lot of powerful options. but it aint easy 🙂

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [27 August 2022 10:24 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/12 "2022-08-27T10:24:32Z")

</div>

Is that IP address actually the IP of your node-red server? I wrote that as a demo URL

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [27 August 2022 10:45 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/13 "2022-08-27T10:45:59Z")

</div>

No I am changing it when posting here . I am using correct ip address .

However it's my home assistant ip address thag could be the issue. I don't know how to get my node red server address. As it's within home assistant (supervised add on on virtual machine in Synology)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [27 August 2022 10:51 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/14 "2022-08-27T10:51:28Z")

</div>

> [@djseek](#):
>
> No I am changing it when posting here . I am using correct ip address

Understand. However, the IP address of the device is likely different to the internal IP address inside the container. You might have to head over to the HA forums for advice.

---

<div class="post-metadata">

### Author: ![PdeJ](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PdeJ](https://discourse.nodered.org/u/PdeJ)
#### Post date: [27 August 2022 21:22 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/15 "2022-08-27T21:22:31Z")

</div>

I have Node Red on a raspberry pi +B accessing a raspberry pi Zero W bearing a picamera 2 running MotionEYE which displays the static image of initial movement in Video as well as the video the ui Dashboard. If you think my experience would assist, I'll put up some more information.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/f/cf76b382c354ecb9c04a38d86c980bf8e18d4667.jpeg)

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [27 August 2022 21:32 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/16 "2022-08-27T21:32:22Z")

</div>

Oh my yes please do. My end goal is to have access to the alert snapshot. As they are just emailed to me now. And also to use it in notification actions.  
Is your node red running on supervisor?  
Thank you

---

<div class="post-metadata">

### Author: ![PdeJ](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@PdeJ](https://discourse.nodered.org/u/PdeJ)
#### Post date: [27 August 2022 22:24 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/17 "2022-08-27T22:24:26Z")

</div>

Node red not running on supervisor.

A Call to a Web Hook can be set in MotionEYE either in the Motion Notifications or the File Storage settings.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/852ccfe0f7fd85f53f89de18a7f093a3df50e488.png)

Note the addition of **?%f** to the webhook. This has the effect of appending the file name to the url. In m case it has a unique date and time of the recording.

In Node Red  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/b/3b8c69e584569c5a0fbf1917284de1e1dfa0a9e5.png)

For Static image of initial movement in Video  
[http://192.168.1.22:8765/movie/1/preview/\*plus\_unique\_date/and\_time.mp4](http://192.168.1.22:8765/movie/1/preview/*plus_unique_date/and_time.mp4)\*

For Video  
[http://192.168.1.22:8765/movie/1/playback/\*plus\_unique\_date/and\_time.mp4](http://192.168.1.22:8765/movie/1/playback/*plus_unique_date/and_time.mp4)\*

For pictures  
[http://192.168.1.22:8765/picture/1/preview/\*plus\_unique\_date/and\_time.mpg](http://192.168.1.22:8765/picture/1/preview/*plus_unique_date/and_time.mpg)\*

The output from the Web Hook can be used for finding the unique name of the image or video, so that it can be appended to the playback http address. This can be done using JSONATA in a **Change node**

**e.g.** For pictures the msg.payload from _Http request,_ an **Http In** (set to POST and url /webhookfile) is set to the value in a **Change node**  
$replace(req.\_parsedUrl.query,"/var/lib/motioneye/Camera1","[http://192.168.n.n:8765/picture/1/preview](http://www.google.com/url?q=http%3A%2F%2F192.168.1.22%3A8765%2Fpicture%2F1%2Fpreview&sa=D&sntz=1&usg=AOvVaw3rsXVJ4Csjd0xoBnSzQ35f)")

and for the Static image of initial movement

$replace(req.\_parsedUrl.query,"/var/lib/motioneye/Camera1","[http://192.168.n.n:8765/movie/1/preview](http://192.168.n.n:8765/movie/1/preview)")

On my pi MotionEYE stores the images at "/var/lib/motioneye/Camera1", but yours may be at a different location.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd18df05c079a2f4a1e2eb3486e8b861b33c6faf.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/4/f4d7fe5b05244e0311c73808b24b900ff1bde22a.png)

an Http request can then be made to download an image or mp4.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/36d722468615c90c6a5b6a860b4a9482e123e452.png)

You will need node-red-node-base64

The ui\_template can be used for displaying a static image

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6b7dd7f09f8679c6b01da94df3d5e8ed718da323.png)

_In Summary:_ An Http Request (set to: GET, and payload as Send as request body, with Return as a binary buffer) is processed by Base64 (Action : Encode as Base64) and output in a ui Template (set to: Reload last value on refresh - so that the image persists in the dashboard on refresh). Using the following Template

```auto
<style>

    img{

        object-fit:contain;

    }

</style>

<img src="data:image/png;base64,{{msg.payload}}" />

the image fills the desired grid pattern set by Size.

```

**Just noticed I have inconsistencies in the above please ignore the Webhook is sometimes denoted as Webhook\_img....so long as they are the same in MotionEYE and on Node red they can be called whatever you wish.**

I have the template displaying the static picture which when clicked displays the video so contains additional code.

```auto
<style>
    img {
        object-fit: contain;
    }
</style>

<img src = "data:image/png;base64,{{msg.payload}}" ng-hide = "showToggle" ng-click = "send({payload:msg.vid});showToggle=!showToggle" />

<video controls id="video" width="100%" heigth="100%" playsinline poster ></video>

<script>
    (function(scope) {
        // Watch for messages being send to this template node
        scope.$watch('msg', function (msg) {      
            if (msg) {
                var video = document.getElementById('video');
                video.src = msg.payload;
                video.play();
            }       
         }); 
    })(scope); 
</script>
```

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [27 August 2022 22:26 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/18 "2022-08-27T22:26:54Z")

</div>

thank you so much - this will be a massive help once I workout how to call node red on supervisor within home assistant. i really appreciate it.

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [27 August 2022 23:48 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/19 "2022-08-27T23:48:56Z")

</div>

I just had to use the default node red port and it worked. entered my ha creds .bingo!

---

<div class="post-metadata">

### Author: ![djseek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/djseek/32/67001_2.png) [@djseek](https://discourse.nodered.org/u/djseek)
#### Post date: [28 August 2022 00:03 UTC](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961/20 "2022-08-28T00:03:06Z")

</div>

now I just have to work out how to auth into node red. i am not getting test failed but now auth failed. Using the format [http://user:pass@192.168.1.1:1880](http://user:pass@192.168.1.1:1880) gives failed auth.

I am running node red in supervisor - and i'm not sure how to get access to settings.js to edit the http auth settings.

[Next page](https://discourse.nodered.org/t/receive-lan-webhook-with-camera-snapshot-surveillance-station-in-home-assistant/66961.md?page=2)
