-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Unknown cipher in Electron #594
Comments
That's weird, my gateway is on the same firmware, working flawlessly. I thought you might have mistyped the PSK, but if I do that, I get this error instead:
You could try restarting the gateway. |
Restarted it but still same error :/ do you have any other ideas? Is it maybe a problem that i use your lib in Electron?
|
Okay, tried it in an plain node script and it works! Removed the node_modules folder in my main project and now i get this error with npm install
|
Okay got a litle bit further. I thinks its the same problem as described here #274 . Tested it with the same code and it still outputs this
Electron v16.0.5 |
Oh, electron is definitely the reason. I'm not sure how and when the dependencies are installed/resolved there. This might be a problem if you're first installing in a Node.js context and then bundling the dependencies for Electron. If you can figure out a better way to make the module optional, I'm all ears. |
You can install the module without the preinstall check using
but I'm not sure if the module can be resolved then. |
Tried many different things today, ended up with a smal nodeJS/express script in the background to avoid the problem :D Grüße aus Freiburg |
Hey! I currently have exactly the same issue! @ItsCoding do you have an example solution for me? I can’t get it working. Thanks in advance! |
Hey @koningcool, syr for my late reply 🙈 the thing is, i didnt got it fixed :/ my workarround is just making a small express web server with plain nodejs v16. Thats it and since its working really great. Here is the code for my Express Server const Tradfri = require("node-tradfri-client");
const express = require("express");
const app = express();
const port = 25587;
const storage = require("node-persist");
const cors = require("cors");
let tradfriClient = null;
let devices = [];
let groups = [];
const getMethods = (obj) =>
Object.getOwnPropertyNames(obj).filter(
(item) => typeof obj[item] === "function"
);
const connectToGateway = async () => {
await storage.init();
const result = await Tradfri.discoverGateway();
const gateway = result.addresses[0];
tradfriClient = new Tradfri.TradfriClient(result.addresses[0], {
watchConnection: true,
});
let creds = await storage.getItem("credentials");
if (!creds) {
const { identity, psk } = await tradfriClient.authenticate(
"Quz5XDKtCokNQfdL"
);
creds = { identity, psk };
await storage.setItem("credentials", creds);
console.log("[TRADFRI] Generated PSK and identity");
}
try {
await tradfriClient.connect(creds.identity, creds.psk);
console.log("[TRADFRI] Connected to gateway");
tradfriClient
.on("device updated", (d) => {
console.log("[TRADFRI] Device updated");
devices[d.instanceId] = d;
})
.observeDevices();
tradfriClient
.on("group updated", (g) => {
console.log("[TRADFRI] Group updated");
groups[g.instanceId] = g;
})
.observeGroupsAndScenes();
} catch (e) {
console.error(e);
}
};
app.use(cors());
app.get("/", (req, res) => {
console.log("Request for devices received");
console.log(devices);
console.log(groups);
res.json({
devices: tradfriClient.devices,
groups: tradfriClient.groups,
});
});
app.get("/toggleDevice", (req, res) => {
const deviceId = req.query.deviceId;
const state = req.query.state;
// console.log(devices);
const device = devices[deviceId].lightList[0];
// console.log(tradfriClient)
let parsedState = state == "on" ? true : false;
console.log("Toggle to " + parsedState);
device.toggle(parsedState).then((lightResult) => {
res.json({ status: "ok", info: lightResult });
});
});
app.get("/setBrightness", (req, res) => {
const deviceId = req.query.deviceId;
const state = req.query.state;
// console.log(devices);
const device = devices[deviceId].lightList[0];
// console.log(tradfriClient)
console.log("Toggle to " + state);
device.setBrightness(state).then((lightResult) => {
res.json({ status: "ok", info: lightResult });
});
});
app.get("/setHue", (req, res) => {
const deviceId = req.query.deviceId;
const state = req.query.state;
// console.log(devices);
const device = devices[deviceId].lightList[0];
// console.log(tradfriClient)
console.log("Toggle to " + state);
device.setColorTemperature(state).then((lightResult) => {
res.json({ status: "ok", info: lightResult });
});
});
connectToGateway().then(() => {
app.listen(port, "localhost", () => {
console.log(`Example app listening on port ${port}`);
});
});
|
Hey mate! No shame for the late reply! Thanks for answering, Do you start this script when your Electron app also starts, and how do you start it? Thanks! |
I have it running as background service which I manually install before. But I guess you could spawn a child process through electron and await it until its started :) |
Thanks, I’ll have a look into it later today! |
@ItsCoding Are you okay with me using some/most of the code that you shared in one of my projects? |
@koningcool go ahead ;) glhf |
I've just release |
If that works, I'll do bumps in the entire dependency chain. |
Thanks! I am going to try this out in electron later today! |
@AlCalzone Hey! I just tried installing [email protected], but I am getting this strange error, I have never got this one before:
Any solutions? |
I think that is because there are no pre-compiled packages uploaded yet by you right? Also when I try to install 2.2.1 (I know that is not working in electron) I get this error:
|
It's not an error though? AFAIK in this case, the binaries should be compiled on install, instead of being downloaded. The issue is that since the last release, TravisCI is no longer working and I haven't migrated the prebuild jobs to github actions yet. |
Ahhh, okay! Currently I can’t build it local due some local issues, I will try to fix that, and when are you migrating to GitHub actions? Also what are your thoughts on this: (I got this on a earlier version) node-aead-crypto not needed on this system, since all ciphers are natively supported |
That was the preinstall check I disabled in 2.2.2. That results in the module not being installed although electron needs it (at least I think that's the underlying problem). I'll try to fix the prebuild in the coming days. Time's pretty limited right now so I wanted to get the release out there. |
Alright, I fixed some local problems and did try to build it locally, unfortunately not with succes. See below for error.
Since there is probably not an easy solution to this, I think I'll just wait until the GitHub Actions are setup, so I can use the prebuilt. |
Damn... I had the same issue and could only fix it by setting up a devcontainer with Node.js 8 🙈 I'm afraid the entire thing needs an overhaul, including migrating to N-API. |
What do you mean exactly with this? |
Not much you can do I'm afraid. I would have to rework how this module is built to make it compile on newer Node.js versions. |
Alright, in that case, keep me up to date! |
Btw, maybe consider re-opening this, since this is still an issue? |
@AlCalzone You have any updates on this? |
I'm actually working on this now. It's a bit challenging to get to work though: AlCalzone/node-aead-crypto#79 |
@JustJoostNL can you try using |
Thanks for creating some time for this issue! I appreciate that. I will try the new version in Electron later today! |
@AlCalzone Hey! I just tried using I have added this to my package.json: "overrides": {
"node-aead-crypto": "3.0.0-alpha.0"
}, So it overwrites the dependency. Any idea what goes wrong here? Thanks for you time! |
is your project public so I could have a look? |
My project is open-source, you can find it here. The function that I run is in the main.js at line 1013 |
Ok, I got a bit further... After changing that, I got your project to actually use
|
So, in short:
(the latter should not be necessary on a clean install, this just updates your package-lock and what is actually installed). If you can confirm this works for you too, I'll release v3 of the aead library. |
Can confirm this works! Thanks so much for helping! |
|
Hi, saw today that you make an API for Ikeas Smart Home :D but at the moment im not able to authenticate :/ My Gateway runs on FW 1.17.22
Only thing i get is this error message. Am i missing something?
Error: Unknown cipher
Thanks in advance 👍
The text was updated successfully, but these errors were encountered: