This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

Network scan IP Camera (Dahua)

Hi,

I am building an app for Dahua camera's. It seems to work all but I would like to implement the list_devices function so that only Dahua Camera's will be shown. This means I need to scan the network somehow and identify what is a Dahua camera. Anyone thoughts how to do this?

Marcel

Comments

  • If you happen to be using `node-dahua-api`, I guess you could try and connect to an IP-address and see if it doesn't emit an `error` event.

    From what I can infer from the code (not at all tested, just to get you going):

    const ipcamera = require('node-dahua-api');
    
    const checkForDahua = async (ip) => {
      const client = new ipcamera.dahua({
        host : ip,
        ... /* other options */
      });
      return new Promise((resolve, reject) => {
        dahua.once('error',   reject);
        dahua.once('connect', () => resolve(client));
      });
    };
    class DahuaDriver extends Homey.Driver {
      ...
      async onPairListDevices(data, callback) {
        let cameras = [];
        for (let i = 2; i < 255; i++) {
          try {
            let client = await checkForDahua('192.168.1.' + i);
            cameras.push(client);
          } catch(e) {
          }
        }
        return callback(null, cameras);
      }
    }

  • Hi Robert,

    Thanks. This is almost the same what I tried but this is taking relative long. So I first want to scan all the ip address an look for a manufacturer that is dahua and then do this on the limited set of ip addresses. But I am not sure how to find the manufacture (as for example you will see in Advanced IP Scanner). 

    Unfortunately I cannot use the api as I am on windows and they use net-keepalive which is not supported under windows.
  • RuudvBRuudvB Member
    Hi,

    I am building an app for Dahua camera's. 

    Marcel
    Cool! I have one which I would like to connect to homey. The model I own is a SD22204T-GN which get perfectly recognized by the app TinyCam Pro.
    If you need testing, just let me know.
  • RuudvB said:
    Hi,

    I am building an app for Dahua camera's. 

    Marcel
    Cool! I have one which I would like to connect to homey. The model I own is a SD22204T-GN which get perfectly recognized by the app TinyCam Pro.
    If you need testing, just let me know.
    I have the same :) I just start with basic things... When someone on the doorbel rings the camera point to the front door :)
  • That is great news, i also have a few outside :)
  • Mmh, I am a step further. I need to find the mac addresses in the local network. This could be done with arp -a but I am not sure this works on a homey? Anyone suggestions?
  • @MarcelTimmermans you can resolve IP-addresses to MAC using `Homey.ManagerArp.getMac()`, which I guess you can run against the network subnet Homey is in.
  • @MarcelTimmermans you can resolve IP-addresses to MAC using `Homey.ManagerArp.getMac()`, which I guess you can run against the network subnet Homey is in.
    YES, That will work! Thanks!
  • edited June 2018
    Solved the issue, case closed ;)


Sign In or Register to comment.