Closed Krillle closed 4 years ago
@Krillle, this is normally a case in whiuch homebridge is not able to read the config.json file. Please be sure to have the file in the .homebridge directory of the user that launch the homebridge program or to specify the config.json location in the command line. Will add a control in the startup of the plugin in order to signal this misconfiguration.
Yes, I know. And also in case there is no section for Fibaro defined. Means the plugin is installed, but no in use. This occurs for example if you have two instances of homebridge running on same raspberry pi. One fore Fibaro, in my case second instance for my Tesla.
Problem is here:
let pollerPeriod = this.config.pollerperiod ? parseInt(this.config.pollerperiod) : defaultPollerPeriod;
This crashes if no pollerPeriod is found in config file.
https://github.com/ilcato/homebridge-Fibaro-HC2/blob/dd926384229b97a3518e421ec4407683e084d7ba/src/index.ts#L117
If no configuration section for Fibaro is found, the plugin should abort:
if (!(config)) { log ("No Fibaro configuration found"); return; }
No @Krillle the error says that this.config
is null, so homebridge was not able to instantiate a config object for the plugin. I will check this case and exit the constructor without crashing.
Give me 15 minutes and try with the new version.
I send a pull request with my proposal.
this.config
is null in a valid context, in case home bridge is started with the fibaro-hc2 plugin installed, while it is not in use. Means no section for fibaro plugin in config.json.
This is a valid scenario. The plugin should not crash homebridge then.
please do
You changed already. I would have done same way.
Yes, but this create a TS compilation problem. Will fix it.
@Krillle, can you try?
@Krillle, were you able to test it?
Thanks for coming back to it. Unfortuately i didn't find the time yet.
@Krillle, any news?
@Krillle, any chance to have this tested by you? It works for me. I will close the issue the next week.
Yes it works for me now. Thank you for fixing. Btw I learned that the new parameter -x is doing the same thing.
ok
When starting Homebridge where Fibaro-HC2 plugin is installed but not in use (e.g. in a second instance on the same device, to not exceed the number of devices) Homebridge crashes with the exception "Cannot read property 'pollerperiod' of null":
Plugin should abort when no parameters are found.