Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


How to use camera with motion detection with HC2?


wickman

Recommended Posts

it's possible to integrate HC2 with an ip-camera by specifying URL:s for the video stream and controlling it with left/right/up/down URL:s etc. This is one-way communication from HC2 to the camera.

 

Now, some cameras can be armed/disarmed, which means that it will start to record when it detects motion. The idea is that this should trigger an alarm in HC2. My idea is to have a scene which can arm/disarm the camera and then, when the camera detects motions it should trigger a scene in HC2.

 

Has anyone figured out how to trigger a scene in HC2 when the camera detects motion? Is there any kind of support for this? 

 

Also, is it possible to arm/disarm your camera through HC2?

Link to comment
Share on other sites

It is not supported from Fibaro. However, you could possibly make a VD crontroling it through the cameras ip address. Have not seen it done yet.

Link to comment
Share on other sites

It is possible. I made a VD for my old Foscam camera, but with my new Hikvision camera (DS 2CD2135FWD-I 3MP) this works too. In the virtual device, I can see if the camera sees movement or not at the moment, and when the camera has seen movement for the last time. you can also start a scene of the camera der movement. I also saw VDs on the forums with which you can put the camera on arm / disarm.

Please login or register to see this attachment.

Edited by AvdL
Link to comment
Share on other sites

  • Topic Author
  • 15 hours ago, AvdL said:

    It is possible. I made a VD for my old Foscam camera, but with my new Hikvision camera (DS 2CD2135FWD-I 3MP) this works too.

     

    Thanks, that sound cool.  

     

    I assume you need to call some rest-api on your camera to get alarm status information or how did you go about it?

    Link to comment
    Share on other sites

     

    I based my virtual device on the LUA code of annhan91 in this topic:  

    Please login or register to see this link.

     

     

    Create a virtual device with 2 labels. One with the ID: stream, and one with the ID: LastTriggerTime.

    In the main loop you put the following LUA script. You must enter your IP address, password, username of your camera.

     

     


    local id = fibaro:getSelfId()

    function encode(data) local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; return ((data:gsub('.', function(x) local r,b='',x:byte() for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end return r; end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x) if (#x < 6) then return '' end local c=0 for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end return b:sub(c+1,c+1) end)..({ '', '==', '=' })[#data%3+1]) end 

    enter = "\r\n";
    USER="XXX" --(ADMIN account)
    PASSWORD="XXXX" --(ADMIN account)
    local ip="XXX.XXX.XXX.XXX" --(IP adres camera)
    local port="XXX" -- (Port camera)

     


    local  tcpSocket = Net.FTcpSocket(ip,port) 
    tcpSocket:setReadTimeout(500)
    tcpSocket:write("GET /ISAPI/Event/notification/alertStream HTTP/1.1" .. enter);
    tcpSocket:write("Authorization: Basic " .. encode(USER..":"..PASSWORD) .. enter .. enter);
    local nhan=tcpSocket:read()
    nhan=nhan .. tcpSocket:read()
    local tam= tcpSocket:read()
    tcpSocket:disconnect()

    local status=tostring(tam:match("<activePostCount>(.+)</activePostCount>")or " ")
    fibaro:debug(status)

    --bijwerken labels--
    if  status > "0" then --motion detected
      
        time = os.date("%H:%M:%S | %B %d");
        fibaro:debug(time);
        fibaro:call(id, "setProperty", "ui.LastTriggerTime.value", time ); 
        fibaro:call(id, "setProperty", "ui.stream.value", "Motion detected"); 
          fibaro:call(id, "setProperty", "currentIcon", 1017) --WIJZIGEN 1017 = icon ID motion
          
      
     else  --No motion
          fibaro:call(id, "setProperty", "ui.stream.value", "Safe"); 
          fibaro:call(id, "setProperty", "currentIcon", 1018) --WIJZIGEN 1018 = icon ID no motion
      end

    fibaro:debug(status)

     

    Edited by AvdL
    • Like 2
    Link to comment
    Share on other sites

    My Foscam camera has relay outputs for alarm so I believe it is also possible to connect UBS module to that output and have alarm trigger that way which is much better because then it reduces traffic between HC and camera :-) 

     

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...