You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I want to use custom characteristics in my plugin ("homebridge-homematicip"). Since I'm quite new to TypeScript I would like to know what is the best way to implement a custom Characteristic on plugin-level. Here is my code:
Unfortunately, when I try to transpile this, I get the following error:
error TS1362: 'Characteristic' cannot be used as a value because it was exported using 'export type'.
This is true, since homebridge exports those classes as a type only. I could include hap-nodejs as a direct dependency, but this might lead to conflicts as you stated in several places. If I just remove the dependency after transpiling, I get the logs shown below.
So my question: What is the best way of doing this? I have seen several plugins just creating the characteristics at runtime, but can't you just do it like this above somehow? You mentioned something like this above yourself in another issue:
I had the same issue when I was rewriting my plugin to TypeScript and I couldn’t solve the problem.
I saw some time ago that there’s an upcoming effort to provide an API for custom characteristics although there’s a lot of work right now for Homebridge developers and it has been proponed.
Custom characteristics solve the “switches hell” pretty well.
Describe Your Problem:
Hi. I want to use custom characteristics in my plugin ("homebridge-homematicip"). Since I'm quite new to TypeScript I would like to know what is the best way to implement a custom Characteristic on plugin-level. Here is my code:
Unfortunately, when I try to transpile this, I get the following error:
error TS1362: 'Characteristic' cannot be used as a value because it was exported using 'export type'.
This is true, since homebridge exports those classes as a type only. I could include hap-nodejs as a direct dependency, but this might lead to conflicts as you stated in several places. If I just remove the dependency after transpiling, I get the logs shown below.
So my question: What is the best way of doing this? I have seen several plugins just creating the characteristics at runtime, but can't you just do it like this above somehow? You mentioned something like this above yourself in another issue:
homebridge/homebridge#1453 (comment)
You can also look at the full source code for my plugin over here:
https://github.com/marcsowen/homebridge-homematicip
Thanks a lot for your help!
Logs:
Environment:
The text was updated successfully, but these errors were encountered: