nitaybz / homebridge-network-presence

Homebridge plugin that provides occupancy sensor for devices presence in your network
MIT License
41 stars 6 forks source link

“Anyone” Sensor #5

Closed nano9g closed 3 years ago

nano9g commented 3 years ago

I’ve been using homebridge-people-x for a long time and one of its nice features is an “Anyone” sensor that triggers when any defined device is found. This makes it easier to create automations around everyone leaving and the first person coming home. Would it be possible to add similar functionality to homebridge-network-presence? Thank you!

nitaybz commented 3 years ago

Good idea... will definitely add it!

gdotp01 commented 3 years ago

This would be great to add. If it was I cou,d move across to using it rather than the “people” plugin that I’ve currently got but is no longer being maintained.

nitaybz commented 3 years ago

I did it! try v1.1.1 + add it (anyoneSensor) in the plugin settings/config

nano9g commented 3 years ago

Thanks for adding this, but I’m getting an error after updating and enabling the sensor.

TypeError: Cannot read property 'toLowerCase' of undefined
    at /usr/lib/node_modules/homebridge-network-presence/lib/network.js:148:77
    at Array.find (<anonymous>)
    at /usr/lib/node_modules/homebridge-network-presence/lib/network.js:148:51
    at Array.forEach (<anonymous>)
    at NetworkPresence.removeCachedDevices (/usr/lib/node_modules/homebridge-network-presence/lib/network.js:143:19)
    at NetworkPresence.init (/usr/lib/node_modules/homebridge-network-presence/lib/network.js:8:35)
    at HomebridgeAPI.emit (events.js:327:22)
    at HomebridgeAPI.signalFinished (/usr/lib/node_modules/homebridge/src/api.ts:251:10)
    at Server.start (/usr/lib/node_modules/homebridge/src/server.ts:158:14)
    at cli (/usr/lib/node_modules/homebridge/src/cli.ts:80:10)
    at Object.<anonymous> (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)

In case it’s helpful, here’s my config for the plugin:

  {
      "platform": "NetworkPresence",
      "debug": true,
      "interval": 10,
      "threshold": 15,
      "anyoneSensor": true,
      "devices": [
          {
              "name": "Phone1",
              "ip": "192.168.1.10",
              "threshold": 15
           },
           {
              "name": "Phone2",
              "ip": "192.168.1.11",
              "threshold": 15
           }
      ]
  }
nitaybz commented 3 years ago

sorry... I missed something... try v1.1.2

nano9g commented 3 years ago

That fixed the error. Thanks again for adding this so quickly!