Closed bab200 closed 1 year ago
Hi.
what firmware version do you run? Please provide sample code that you use if possible.
Please try to log into the SysAp GUI and just trigger some actuator (e.g. turn light on/off). After that log out and restart your script. There is a bug in the AP where communication stalls.
I'm running the API1 on 3.1.1
when running the js script and call the api via node-fetch:
const fetch = require('node-fetch');
fetch('http://127.0.0.1:8080/info')
.then(response => response.text())
.then(body => console.log(body));
this is what comes out - tried 127.0.01:8080, as well as the raspberry's IP (192.168.88.21:8080)
pi@raspberrypi:~ $ node freeathome.js
(node:1599) UnhandledPromiseRejectionWarning: FetchError: request to http://127.0.0.1:8080/info failed, reason: connect ECONNREFUSED 127.0.0.1:8080
at ClientRequest.--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1599) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Please post the code you use to run the free@home API. It seems the HTTP API is not listening (check with netstat -tulpn
).
the API does not start - do I need to disable to HTTP API as I run a v1 access point?
I checked and it did return the following error:
pi@raspberrypi:~ $ systemctl status freeathome-api.service ● freeathome-api.service - freeathome API Service Loaded: loaded (/etc/systemd/system/freeathome-api.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sun 2023-01-08 16:43:25 GMT; 2min 50s ago Process: 2087 ExecStart=node node_modules/freeathome-api/bin/freeathome-api (code=exited, status=1/FAILURE) Main PID: 2087 (code=exited, status=1/FAILURE) CPU: 409ms
Jan 08 16:43:25 raspberrypi systemd[1]: freeathome-api.service: Scheduled restart job, restart counter is at 5. Jan 08 16:43:25 raspberrypi systemd[1]: Stopped freeathome API Service. Jan 08 16:43:25 raspberrypi systemd[1]: freeathome-api.service: Start request repeated too quickly. Jan 08 16:43:25 raspberrypi systemd[1]: freeathome-api.service: Failed with result 'exit-code'. Jan 08 16:43:25 raspberrypi systemd[1]: Failed to start freeathome API Service.
when starting it manually, I get to Sending Capability Announcement Message Sub
pi@raspberrypi:~ $ node node_modules/freeathome-api/bin/freeathome-api 08/01/2023, 16:49:09 - INFO: Starting free@home API 08/01/2023, 16:49:14 - INFO: Connected as installer@busch-jaeger.de/freeathome-api 08/01/2023, 16:49:14 - INFO: Websocket Server started 08/01/2023, 16:49:14 - INFO: Webserver Started 08/01/2023, 16:49:14 - INFO: Sent Authenticator 08/01/2023, 16:49:14 - INFO: Received Local Key 08/01/2023, 16:49:14 - INFO: Sent New Session Request 08/01/2023, 16:49:14 - INFO: Sent Login SASL Message 08/01/2023, 16:49:14 - INFO: Received SASL Challenge 08/01/2023, 16:49:14 - INFO: Sent SASL Challenge Response 08/01/2023, 16:49:14 - INFO: Received SASL Login Confirmation 08/01/2023, 16:49:14 - INFO: Successfully Authenticated 08/01/2023, 16:49:14 - INFO: Announced Capabilities to System Access Point 08/01/2023, 16:49:14 - INFO: Requested Master Data Structure from System Access Point 08/01/2023, 16:49:17 - INFO: Received Master Update from System Acccess Point 08/01/2023, 16:49:18 - INFO: Sent Subscription Request 08/01/2023, 16:49:18 - INFO: Sent Subscription Confirmation 08/01/2023, 16:49:18 - INFO: Detected Access Point firmware >= 3.0.1 - Sending Capability Announcement Message Sub.
if I change the config file to debug true however, I see all information and can see changes of actuars etc.
Check that the WorkingDirectory in your system file is correct and you are executing with the correct user / permissions.
Check on what port the Webserver is listen with netstat -tulpn
Thanks a lot Henry. Finally got it up and running.
my /etc/systemd/system/freeathome-api.service looks like this
[Unit] Description=freeathome API Service After=network-online.target
[Service] WorkingDirectory=/home/pi ExecStart=/usr/bin/node node_modules/freeathome-api/bin/freeathome-api
[Install] WantedBy=multi-user.target
Hi,
I have an f@h sysap 1 and would want to extract status out of the sysap. I've been able to get this script to run and if I set the config to debug true I see the script running.
I tried to execute a js to getAllDevices - but just not able to. Is there any good place to learn how to run the script? trigger the API?