ebaauw / homebridge-lib

Utility Library for Homebridge Plugins
Apache License 2.0
94 stars 12 forks source link

Problem with creating eve Service 'weather' and 'outlet' #5

Closed ctschach closed 6 years ago

ctschach commented 6 years ago

When I try to create a HK service with "eve weather" or "eve outlet" I get the following error - all other eve services work fine. Any idea what could go wrong here?

Create Service Weather /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Service.js:75 if (existing.UUID === characteristic.UUID) { ^

TypeError: Cannot read property 'UUID' of undefined at Service.(anonymous function).Service.addCharacteristic (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Service.js:75:42) at new Service.(anonymous function) (/home/oscar/src/homebridge-knx/node_modules/homebridge-lib/lib/CustomHomeKitTypes.js:47:14) at serviceArray (/home/oscar/src/homebridge-knx/lib/servicedata.js:30:16) at Plugin.registry [as initializer] (/home/oscar/src/homebridge-knx/index.js:145:18) at Server. (/usr/lib/node_modules/homebridge/lib/server.js:160:14) at Array.forEach () at Server._loadPlugins (/usr/lib/node_modules/homebridge/lib/server.js:138:22) at new Server (/usr/lib/node_modules/homebridge/lib/server.js:56:24) at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:26:16) at Object. (/usr/lib/node_modules/homebridge/bin/homebridge:17:22)

ebaauw commented 6 years ago

Hard to tell without seeing your code.

CustomHomeKitTypes is the abstract superclass for EveHomeKitTypes and MyHomeKitTypes. You wouldn't call createService() (nor createCharacteristic()) from your plugin. Instead, you instantiate the final subclass with the homebridge api passed to your platform constructor:

const eve = new EveHomeKitTypes(homebridge)

And then you'd simply instantiate the service:

const service = new eve.Service.Weather(name)
ctschach commented 6 years ago

Hmmm....could it be possible, that there is an error in the Service definition for "Outlet"?

In the Service "Outlet" you define the following Characteristic: eve.Characteristic.Current However, I can't find this in the list of Characteristics. The only thing I could find is "ElectricCurrent".

Is this a problem?

ebaauw commented 6 years ago

That loos like a problem, indeed. Not at all happy that this only surfaces when instantiating the service, not when defining the class.

ctschach commented 6 years ago

Okay, glad you see it as a problem and it's not me :-)

On the first sight, the weather service looks fine, but it still gives me some trouble.

ctschach commented 6 years ago

Okay, same for "Weather" - it's CurrentRelativeHumidity and not just Humidity.

ctschach commented 6 years ago

I did fixe those two problems and send you a pull request. Would be great if you could update this and we could get this into NPM, so that building "my" plugin works properly :-)

ebaauw commented 6 years ago

Done