Logic Machine Forum
Synology surveillance Station webhook - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Synology surveillance Station webhook (/showthread.php?tid=4711)



Synology surveillance Station webhook - KoBra - 13.04.2023

I have configured the webhook on surveillance station and made a survstat.lp script to receive the webhook.

If i look in it i see this data after the test:
Code:
equire('apps') -- read POST data body = ngx.req.get_body_data() if body then -- decode data as JSON data = json.pdecode(body) -- check that data is a table if type(data) == 'table' then log(data) -- movement detected, you can check data.camera_id if you have multiple cameras if data.event_type == 'movement' then -- do something when movement happens end end end

How can i now use the movement to turn on a light?


RE: Synology surveillance Station webhook - admin - 13.04.2023

You can use grp.write inside .lp scripts, just make sure that you have require('apps') before grp.write.


RE: Synology surveillance Station webhook - KoBra - 13.04.2023

(13.04.2023, 10:12)KoBra Wrote: I have configured the webhook on surveillance station and made a survstat.lp script to receive the webhook.

If i look in it i see this data after the test:
Code:
equire('apps') -- read POST data body = ngx.req.get_body_data() if body then -- decode data as JSON data = json.pdecode(body) -- check that data is a table if type(data) == 'table' then log(data) -- movement detected, you can check data.camera_id if you have multiple cameras if data.event_type == 'movement' then -- do something when movement happens end end end

How can i now use the movement to turn on a light?

I used this from the netatmo camera topic in my .lp script
Code:
equire('apps')
-- read POST data
body = ngx.req.get_body_data()

if body then
  -- decode data as JSON
  data = json.pdecode(body)

  -- check that data is a table
  if type(data) == 'table' then
    log(data)

    -- movement detected, you can check data.camera_id if you have multiple cameras
    if data.event_type == 'movement' then
      -- do something when movement happens
    end
  end
end
I think i need to modify this part as i have no clue what i am getting in from synology


RE: Synology surveillance Station webhook - admin - 13.04.2023

You're missing the starting <? tag in your .lp file. It should be like this:
Code:
<?
require('apps')
...