require() NPM in Espruino WiFi for HomeKit project #7528
Replies: 1 comment
-
Posted at 2020-12-23 by @MaBecker Hi Espruino has a page that describes how to handle modules. Posted at 2020-12-28 by M.Montore Hi MaBe, I already checked the page you linked before, however it is not helping me. As I said, I can not convert the package to an actual file .js that I can upload to the Espruino. Thanks again Posted at 2020-12-31 by @gfwilliams Hi - I think the issue you've got is it's a multi-file typescript library. You may have some luck installing it and then using just the I'm afraid there's a very good chance that there's just too much code to fit on an Espruino device. I'm sure you could make an Espruino device into a HomeKit device, but you may have to implement it from scratch I'm afraid (at least Posted at 2021-01-04 by M.Montore Hi Gordon, I was afraid that would be the case. I tried what you said about "index.js" but it didn't work in the end. I will have to do it from scratch as you suggest. Thanks a lot for the help anyways. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2020-12-23 by M.Montore
I am currently working on a HomeKit project with Espruino WiFi and I'm running some tests first.
There is a git that has a great example (https://github.com/homebridge/HAP-NodeJS-examples/tree/master/light-example-javascript). The project has a "light.js" program and "package.json". In the terminal (linux), I just install the necessary dependencies with "npm install" and I execute the application "node src/light.js". It works perfectly, I find the extension in Apple HomeKit App in my phone, I can edit the light parameters, everything.
However, when I try to do the same inside the Espruino Web IDE, I can not access to the module in require("hap-nodejs"). In the terminal, the npm does everything for me, but here I know I need to introduce the .js file in the module section in Espruino Web IDE, but "hap-nodejs" is not a .js file. I need to transform the "package.json" into my "hap-nodejs.js" so I can use it as a private module. I tried to find a way to do it but nothing seems to work. I also downloaded the .tgz file from "https://www.npmjs.com/package/hap-nodejs", and try to find what I need from there. But it is the same in the end, another package and directories containing the dependencies needed.
My question is: How can I get the module I need (hap-nodejs) to execute "light.js" inside the Espruino?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions