lucavb / homebridge-hc-sr501

Homebridge plugin for the hc-sr501 motion sensor
GNU General Public License v3.0
10 stars 1 forks source link

Error: The requested accessory 'HC-SR501' was not registered by any plugin #12

Closed haen7 closed 3 years ago

haen7 commented 3 years ago

Hi, I installed the plugin using this command: sudo npm install -g --unsafe-perm homebridge-hc-sr501 but Homebridge can not find the plugin. here is the log from Homebridge:

    Error loading accessory requested in your config.json at position 6
    Error: The requested accessory 'HC-SR501' was not registered by any plugin.
    at PluginManager.getPluginForAccessory (/usr/local/lib/node_modules/homebridge/src/pluginManager.ts:198:15)
    at /usr/local/lib/node_modules/homebridge/src/server.ts:347:37
    at Array.forEach (<anonymous>)
    at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/src/server.ts:330:29)
    at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:156:12)
    at cli (/usr/local/lib/node_modules/homebridge/src/cli.ts:80:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32)
lucavb commented 3 years ago

Please post the entire config.json here and omit sensitive information.

haen7 commented 3 years ago

After I upgraded Homebridge Config UI X to v4.24.0 (latest version) I got this error:

ERROR LOADING PLUGIN homebridge-hc-sr501:
Error: Cannot find module 'hap-nodejs'
Require stack:
- /usr/local/lib/node_modules/homebridge-hc-sr501/dist/index.js
- /usr/local/lib/node_modules/homebridge/lib/plugin.js
- /usr/local/lib/node_modules/homebridge/lib/pluginManager.js
- /usr/local/lib/node_modules/homebridge/lib/api.js
- /usr/local/lib/node_modules/homebridge/lib/server.js
- /usr/local/lib/node_modules/homebridge/lib/cli.js
- /usr/local/lib/node_modules/homebridge/bin/homebridge
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)
    at Function.Module._load (internal/modules/cjs/loader.js:838:27)
    at Module.require (internal/modules/cjs/loader.js:1022:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge-hc-sr501/dist/index.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32)
    at Function.Module._load (internal/modules/cjs/loader.js:875:14)
    at Module.require (internal/modules/cjs/loader.js:1022:19)

so I installed hap-nodejs and now here is the new error:

Error: Cannot add a Characteristic with the same UUID as another Characteristic in this Service: 00000023-0000-1000-8000-0026BB765291
    at AccessoryInformation.Service._this.addCharacteristic (/usr/local/lib/node_modules/hap-nodejs/src/lib/Service.ts:194:15)
    at new AccessoryInformation (/usr/local/lib/node_modules/hap-nodejs/src/lib/gen/HomeKit.ts:4140:10)
    at new HomebridgeSR501Sensor (/usr/local/lib/node_modules/homebridge-hc-sr501/dist/index.js:19:35)
    at /usr/local/lib/node_modules/homebridge/src/server.ts:357:50
    at Array.forEach (<anonymous>)
    at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/src/server.ts:330:29)
    at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:156:12)
    at cli (/usr/local/lib/node_modules/homebridge/src/cli.ts:80:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)

My config:

{
    "bridge": {
        "name": "Homebridge",
        "username": "XX:XX:XX:XX:XX:XX",
        "port": 51826,
        "pin": "xxx-xx-xxx"
    },
    "description": "Homebridge",
    "accessories": [
        {
            "accessory": "Relay",
            "name": "Relay-1",
            "pin": 11,
            "invert": true,
            "default_state": false
        },
        {
            "accessory": "Relay",
            "name": "Relay-2",
            "invert": true,
            "default_state": false,
            "pin": 13
        },
        {
            "accessory": "Relay",
            "name": "Relay-3",
            "invert": true,
            "default_state": false,
            "pin": 15
        },
        {
            "accessory": "Relay",
            "name": "Relay-4",
            "invert": true,
            "default_state": false,
            "pin": 31
        },
        {
            "accessory": "Dht",
            "name": "dht22",
            "name_temperature": "Temperature",
            "name_humidity": "Humidity",
            "service": "dht22"
        },
        {
            "accessory": "HC-SR501",
            "name": "Motion Sensor",
            "pinId": 24
        }
    ],
    "platforms": [
        {
            "name": "Config",
            "port": 8080,
            "auth": "form",
            "theme": "auto",
            "tempUnits": "c",
            "lang": "auto",
            "sudo": true,
            "ssl": {
                "pfx": "/var/lib/homebridge/ssl/homebridge.pfx",
                "passphrase": ""
            },
            "platform": "config"
        }
    ]
}
lucavb commented 3 years ago

Alright, the hap-nodejs bug should be fixed with version 1.0.6. Thank you for reporting this bug! Could please have a look at that new version?

haen7 commented 3 years ago

Version 1.0.6 fixed The hap-nodejs error but I still get Cannot add a Characteristic error.

lucavb commented 3 years ago

Alright. Seems like they changed the way services work. This new version seems to work for me, can you give it a try?

haen7 commented 3 years ago

Great, It works perfectly with hc-sr505 PIR sensor.

608ac91f-9bd9-4af6-b166-619916167581

Thanks!

lucavb commented 3 years ago

Glad I could help :)