Closed jslettengren closed 2 years ago
Complete script if that is of help:
#!/usr/bin/env node
import { Connection, Products, Product, Gateway } from "klf-200-api";
import { readFileSync } from "fs";
async function enable_HSM() {
const myFingerprint = "AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD";
const myCA = readFileSync("/app/velux-cert.pem");
/*
Create connection using IP
*/
const conn = new Connection('192.168.1.200', myCA, myFingerprint);
/*
Login with WLAN password
*/
await conn.loginAsync('mypassword');
try {
const gw = new Gateway(conn);
await gw.enableHouseStatusMonitorAsync();
} finally {
await conn.logoutAsync();
}
}
enable_HSM();
Can you provide the docker file? I would assume that there is no difference between running in a docker container or running on the physical machine.
And can you also give it a try to await
the call to enable_HSM();
. Maybe that is a race condition that leads to the situation that the connection object is already destroyed when the callback is called.
So I'm doing this from within a running docker image from demidyuk/domoticz (https://github.com/stas-demydiuk/domoticz-docker/blob/master/Dockerfile.x86-64).
I run the docker image using this docker-compose.yml:
version: '3'
services:
domoticz:
container_name: domoticz
image: demydiuk/domoticz:latest
restart: unless-stopped
volumes:
- /some/path/data:/config
- /some/path/keys:/config/keys
- /etc/localtime:/etc/localtime:ro
privileged: true
labels:
- traefik.http.routers.home.rule=Host(`host.name`)
- traefik.http.routers.home.tls=true
- traefik.http.routers.home.tls.certresolver=lets-encrypt
- traefik.port=8080
environment:
- PUID=1000
- PGID=1000
tty: true
devices:
- `/dev/ttyACM0:/dev/ttyACM0`
- /dev/ttyUSB0:/dev/ttyUSB0
networks:
- web
networks:
web:
external: true
After bashing into the docker container (docker exec -it <container name> bash
), I have installed nodejs, tsc, klf-200-api, etc... My goal is to write a docker file of my own that setups the whole environment, but I'm not quite there yet.
I did try your suggestion to await the call to enable_HSM(), but that gives me another error:
enable_house_status_monitor.ts:44:1 - error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.
I did try to set some compiler options according to the error message, but that just gave me other error messages. As you can see, I'm not skilled enough to figure this out on my own. Any more ideas?
I can't reproduce that error.
I'm trying to run this from within a docker container, and I get an error which I don't fully understand. It is during the call to loginAsync.
await conn.loginAsync('mypassword');
The error message is as follows:Am I missing some dependencies? Or something else?
I did have this all working in a non-dockerized environment. I hope to get it running also from within a docker container.