Closed andypmuc closed 1 month ago
Hi @andypmuc.
The docs you request are out of scope for this project. It s basic NPM packaging that is troubling you here. You cannot use this on its own. You can install it and use it in your own Javascript application.
You need to install the package into an existing npm based project. The following should get you going, but please take a look at npm docs for more details about managing a Javascript project.
(The following is an example on a Linux/Unix machine, but should be translatable to Windows)
mkdir my-project
cd my-project
npm init my-project
npm install blaubergventojs
You will now have a package.json in your folder with a reference to blaubergventojs. Afterwards create a javascript file called fx. example.mjs and add the highlevel example from the README in this project.
import { BlaubergVentoResource, FunctionType, Parameter, DataEntry } from 'blaugbergventojs'
const resource = new BlaubergVentoResource();
// Find all devices on the local network
const devices = await resource.findAll();
// Change a device and save it
let device = devices.contents[0];
device.speed = 1;
device = await resource.save(device);
Run it: node example.mjs
.
Because the folder has a package.json, node will use the dependencies from there and import should work.
This should give you the general idea.
OK, thanks anyway. I run it on Windows, and maybe that is the reason, why it is a little bit different.
I had to use
npm init
Then import did work, I used VS Code and it helped me there a little bit
import pkg from 'blaubergventojs';
const resource = new pkg.BlaubergVentoResource();
// Find all devices on the local network
const devices = await resource.findAll();
// Change a device and save it
let device = devices.content[0];
console.log (device.on);
console.log (device.mode);
console.log (device.manualSpeed);
It told me, that this is a common JS module, which cannot be imported like it is in your documentation.
Then contents is without s -> let device = devices.content[0];
At least I discovered that error in your documentation ;-)
Now it is working and maybe I propose some changes that I can use weekly schedule as high level command. Tried it yesterday as low level and it did work. I also need to find out, how I integrate it in OpenHAB.
Maybe you put it something like this as well. I struggled a little bit with the data entries.
const pkt3 = new pkg.Packet(addresses[0].id, '1111', pkg.FunctionType.WRITEREAD, [pkg.DataEntry.of(pkg.Parameter.WEEKLY_SCHEDULE, 0)])
const rsp3 = await client.send(pkt3, addresses[0].ip);
console.log (rsp3.packet.dataEntries[0].value[0]);
Sorry, I am not a profession programmer and have some trouble.
I installed it first without the -g option and it did work, then with the -g option
Content of
Also Tried it with
import { BlaubergVentoClient, FunctionType, Parameter, DataEntry } from 'blaugbergventojs'
and also with the path before blauberg vento.
When I use .js file I end up with
Could you improve the docs. I also like to integrated it in Openhab, which is also Java. I would assume the error I get there ist the same.