I tested and created a working integration based on the following code snippet provided by Homey Support:
import { HomeyAPI } from 'homey-api';
const homeyApi = await HomeyAPI.createLocalAPI({
address: 'http://192.169.1.123', // Replace this with Homey Pro's IP address
token: 'ba78f646-4a0f-4869-95cd-c7040bc4e63b:21b9f8d2...', // Replace this with your API Key
});
// Get all devices
const devices = await homeyApi.devices.getDevices();
for(const device of Object.values(devices)) {
console.log(device.name); // Prints the device's name
}
However, when I try to connect over HTTPS the application returns the following error:
FetchError: request to https://<homey-ip>.homey.homeylocal.com:<homey-port>/api/manager/system/ping failed, reason: getaddrinfo EAI_AGAIN <homey-ip>.homey.homeylocal.com
I configured my wifi router as follows:
Gave Homey-Pro a static IP address
Port forward(NAT/PAT): external 5679, internal: 443
<homey-ip>.homey.homeylocal.com resolves to a local IP address, so you shouldn’t use the external (port-forwarded) port, just https://<homey-ip>.homey.homeylocal.com (unless you used your external IP address as <homey-ip>, but if you did that you have to make sure that your router supports hairpin NAT).
Also, if you did use your local IP address, you need to disabled DNS rebinding protection in your router, otherwise it will not accept external hostnames that resolve to internal addresses (yes, to make your local Homey connection more secure with HTTPS you need to downgrade the overall security of your network )