Giter Site home page Giter Site logo

zoilomora / hikvision-to-mqtt Goto Github PK

View Code? Open in Web Editor NEW
17.0 3.0 4.0 84 KB

Sends alarm events from Hikvision DVR to MQTT

License: MIT License

Makefile 2.61% PHP 86.79% Dockerfile 3.52% Shell 7.08%
hikvision mqtt mosquitto homeassistant alarm

hikvision-to-mqtt's Introduction

Hikvision to MQTT

Start-up

  1. Download the project:

     git clone https://github.com/zoilomora/hikvision-to-mqtt.git
     # or
     wget https://github.com/zoilomora/hikvision-to-mqtt/archive/master.zip
    
  2. Check the docker-compose.yml to see if there are any conflicts with the ports.

  3. Start the whole environment:

     make start
    
  4. Once started you will be in a shell inside the php container, check the correct functioning of the system:

     /var/app $ console about
      -------------------- ---------------------------------------- 
       Symfony                                                      
      -------------------- ---------------------------------------- 
       Version              5.2.1                                   
       Long-Term Support    No                                      
       End of maintenance   07/2021                                 
       End of life          07/2021                                 
      -------------------- ---------------------------------------- 
       Kernel                                                       
      -------------------- ---------------------------------------- 
       Type                 ZoiloMora\HikvisionCommunicator\Kernel  
       Environment          dev                                     
       Debug                true                                    
       Charset              UTF-8                                   
       Cache directory      ./var/cache/dev (329 KiB)               
       Build directory      ./var/cache/dev (329 KiB)               
       Log directory        ./var/log (0 B)                         
      -------------------- ---------------------------------------- 
       PHP                                                          
      -------------------- ---------------------------------------- 
       Version              7.4.1                                   
       Architecture         64 bits                                 
       Intl locale          n/a                                     
       Timezone             UTC (2021-01-22T19:47:27+00:00)         
       OPcache              false                                   
       APCu                 false                                   
       Xdebug               false                                   
      -------------------- ---------------------------------------- 
    
  5. Now leave the container:

     /var/app $ exit
    
  6. You can leave the system connected:

     docker-compose up -d
    

DVR settings

  1. Use the iVMS-4200 Client to access the remote configuration of the device.

  2. Go to Event > Email and configure the fake-smpt-server as SMTP Server (default port 1025). You can enter any source and destination address, for example:

     Sender Address: <hikvision> [email protected]
     Receiver Address: <server> [email protected]
    
  3. Activate in the events that the Linkage Action: Email Linkage.

Check operation

Run a MQTT Client to monitor the topic (replace <server_id> with the IP Address of your MQTT Server):

docker run --init -it --rm efrecon/mqtt-client sub -h <server_ip> -t "alerts" -v

# Result
alerts {"type":"Motion Detected","device":{"name":"Embedded Net DVR","serial_number":"******"},"camera":{"name":"Camera 1","number":"A1"},"occurred_on":{"date":"2020-01-06 14:51:02.000000","timezone_type":3,"timezone":"Europe\/Madrid"}}

You can also see the logs of the docker containers to see what is happening:

docker-compose logs -f

# Result
mqtt_1 | 1578318663: New connection from 10.10.12.4 on port 1883.
mqtt_1 | 1578318663: New client connected from 10.10.12.4 as hikvision (p2, c1, k60).
php_1  | Published message: {"type":"Motion Detected","device":{"name":"Embedded Net DVR","serial_number":"******"},"camera":{"name":"Camera 1","number":"A1"},"occurred_on":{"date":"2020-01-06 14:51:02.000000","timezone_type":3,"timezone":"Europe\/Madrid"}}
mqtt_1 | 1578318663: Client hikvision disconnected.

hikvision-to-mqtt's People

Contributors

dependabot[bot] avatar zoilomora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hikvision-to-mqtt's Issues

hikvision-to-mqtt PHP file exits after a few seconds

Hi - I'm new to Docker so it might be me.

That being said, maybe you can help me figure out how to get this working. The hikvision-to-mqtt_php container does not start. The log says ': No such file or directory. Do you know how to fix this?

Error thrown while running command "app:event:publish-all

Program dont wont send publish message, reason:

image

Any help about this exception.

This message I recieved with some fake smtp.

 Fri, 01 Jan 2021 18:10:01 +0100 (CET)
From: "dvr" <[email protected]>
To: "server" <[email protected]>
Date: Fri, 01 Jan 2021 18:02:52 +0100
Subject: Network Video Recorder: Motion Detected On Channel D2 
X-Mailer: Mailer
X-Priority: 3
MIME-Version: 1.0
Content-type: multipart/alternative; boundary="#boundary#"

Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is an automatically generated e-mail from your NVR.

EVENT TYPE:    Motion Detected
EVENT TIME:    2021-01-01,18:02:48
NVR NAME:      Network Video Recorder
NVR S/N:       0820180614AARRC29233274WCVU
CAMERA NAME(NUM):   Camera 01(D2)  

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.