Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homebridge Verification #24

Open
bwp91 opened this issue Jul 26, 2023 · 32 comments
Open

Homebridge Verification #24

bwp91 opened this issue Jul 26, 2023 · 32 comments
Labels
bug Something isn't working

Comments

@bwp91
Copy link

bwp91 commented Jul 26, 2023

Gonna close your issue in the verified repo for now, and start one here, so that a new issue can be created in the verified repo once the plugin is ready.

@bwp91 bwp91 added the bug Something isn't working label Jul 26, 2023
@bwp91
Copy link
Author

bwp91 commented Jul 26, 2023

@richierockskool when you make updates to this plugin, are you editing the ts files or js files?

@richierockskool
Copy link
Owner

richierockskool commented Jul 26, 2023 via email

@bwp91
Copy link
Author

bwp91 commented Jul 26, 2023

so if you are only editing the js files why keep the ts files in the first place?
delete them all
and delete the tsconfig file etc

@richierockskool
Copy link
Owner

richierockskool commented Jul 26, 2023 via email

@bwp91
Copy link
Author

bwp91 commented Jul 26, 2023

well looks like your inkbirdPlatform.js doesn't use this file so i think just delete the settings.ts file

Also looks like your platform file exports as es module, so you will need this in your package json (replacing any existing properties with these names)

  "type": "module",
  "main": "src/inkbirdPlatform.js",

@richierockskool
Copy link
Owner

richierockskool commented Jul 26, 2023 via email

@bwp91
Copy link
Author

bwp91 commented Jul 26, 2023

yea but it’s not working right now is it?

@richierockskool
Copy link
Owner

richierockskool commented Jul 26, 2023 via email

@richierockskool
Copy link
Owner

richierockskool commented Jul 26, 2023 via email

@bwp91
Copy link
Author

bwp91 commented Jul 26, 2023

the build command is meant to convert the typescript files to js. if you are simply using js files then the build command is not needed. just delete the line from your package json file.

I personally also do not use typescript, all my plugin files are js. You can see an example here

https://github.com/bwp91/homebridge-meross/blob/latest/package.json

I only have two scripts in my package json, a personal one to rebuild the package json, and a lint command. no build command

@richierockskool
Copy link
Owner

richierockskool commented Jul 26, 2023 via email

@richierockskool
Copy link
Owner

richierockskool commented Jul 26, 2023 via email

@bwp91
Copy link
Author

bwp91 commented Jul 26, 2023

Now must do a rebuild the InkbirdPlatform.js to reflect all the functions for accessories that were in Platform.ts

So you were using some of the ts files? you can't half and half use the js or ts files, either:

  • you have no js files in your project, edit the ts files directly, and include all the build scripts, or
  • use js files, with no dependency on ts files, and discount the build scripts

but what you cannot do is a mixture of both. i think this might be your general issue

@bwp91
Copy link
Author

bwp91 commented Jul 26, 2023

so for example if you browse my repos, you can determine that I don't use ts at all, all my files are in js. there are no ts files at all. so no 'building' is required.

the homebridge plugin template uses ts which is why most of the existing plugins are written in ts (i have a personal distaste). but if you look at some examples you will see that these repos do not include any js files.

@bwp91
Copy link
Author

bwp91 commented Jul 26, 2023

so you need to basically choose right now if you want to continue with your plugin in typescript or javascript, and then stick to one with your development.

@richierockskool
Copy link
Owner

richierockskool commented Jul 26, 2023 via email

@bwp91
Copy link
Author

bwp91 commented Jul 26, 2023

i made a pr which you could look into. i can't pretend that it will make everything magically start working, but you can see what i am aiming towards, from your feedback/replies on this issue

@bwp91
Copy link
Author

bwp91 commented Jul 26, 2023

#25

@richierockskool
Copy link
Owner

richierockskool commented Jul 26, 2023 via email

@richierockskool
Copy link
Owner

Good news all those changes are done and the plugin still loads with no errors, but no start function on the platform and accessories are not loading.

@bwp91
Copy link
Author

bwp91 commented Jul 28, 2023

You need to put your plugin setup code into a callback for the didFinishLaunching event, maybe this is the missing piece here.

See the template:
https://github.com/homebridge/homebridge-plugin-template/blob/d0bca523f5cd56f68d9d1e9b21ae20389bbcb2e5/src/platform.ts#L29

@richierockskool
Copy link
Owner

richierockskool commented Jul 28, 2023 via email

@richierockskool
Copy link
Owner

richierockskool commented Jul 28, 2023 via email

@richierockskool
Copy link
Owner

richierockskool commented Jul 28, 2023 via email

@richierockskool
Copy link
Owner

richierockskool commented Jul 29, 2023 via email

@bwp91
Copy link
Author

bwp91 commented Jul 29, 2023

the build command should not start the plugin. it builds the plugin.

For a homebridge plugin, the build command converts the typescript code to javascript.

since you are using raw javascript, you do not need to build.

@richierockskool
Copy link
Owner

richierockskool commented Jul 29, 2023 via email

@richierockskool
Copy link
Owner

richierockskool commented Jul 29, 2023 via email

@bwp91
Copy link
Author

bwp91 commented Jul 29, 2023

well here you are simple setting this.devices to 2 so it’s not a proper object with a name property

i mean it’s not an array with objects with name properties

@richierockskool
Copy link
Owner

richierockskool commented Jul 29, 2023 via email

@richierockskool
Copy link
Owner

richierockskool commented Jul 30, 2023 via email

@richierockskool
Copy link
Owner

richierockskool commented Aug 5, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants