I’ve been reading through the documentation Discovery - Homey Apps SDK to set up discovery of devices, I can see the device advertise itself with avahi-browse:
oh2th@pi ~: avahi-browse -r _go-e_go-eCharger_V4._tcp
hostname = [go-echarger_123456.local]
address = [192.168.4.16]
port = [80]
txt = ["serial=123456" "friendly_name=123456" "manufacturer=go-e" "devicetype=go-eCharger_V4" "version=054.7" "protocol=2"]
However Homey does not discover it no matter what I do. What am a missing? The sample plugwise reference is a bit too complex to figure this out.
And yes, I know there is an app for go-e Chargers, however that one doesn’t use the new go-e api.
.homeycompose/discovery/go-eCharger_V4.json:
{
"type": "mdns-sd",
"mdns-sd": {
"name": "go-e_go-eCharger_V4",
"protocol": "tcp"
},
"id": "{{txt.serial}}"
}
drivers/go-e-charger-gemini/driver.compose.json:
{
"name": {
"en": "go-e Charger Gemini"
},
"class": "other",
"capabilities": [
"measure_current",
"meter_power",
"alarm_generic",
"measure_power",
"measure_temperature",
"onoff",
"measure_voltage"
],
"platforms": [
"local"
],
"connectivity": [
"lan"
],
"images": {
"small": "{{driverAssetsPath}}/images/small.png",
"large": "{{driverAssetsPath}}/images/large.png",
"xlarge": "{{driverAssetsPath}}/images/xlarge.png"
},
"discovery": "go-e_go-eCharger_V4",
"pair": [
{
"id": "list_devices",
"template": "list_devices",
"navigation": {
"next": "add_devices"
}
},
{
"id": "add_devices",
"template": "add_devices"
}
]
}
drivers/go-e-charger-gemini/driver.js:
'use strict';
const { Driver } = require('homey');
class MyDriver extends Driver {
/**
* onInit is called when the driver is initialized.
*/
async onInit() {
this.log('MyDriver has been initialized');
}
/**
* onPairListDevices is called when a user is adding a device
* and the 'list_devices' view is called.
* This should return an array with the data of devices that are available for pairing.
*/
async onPairListDevices() {
this.log('MyDriver searching mDNS');
const discoveryStrategy = this.getDiscoveryStrategy();
const discoveryResults = discoveryStrategy.getDiscoveryResults();
const devices = Object.values(discoveryResults).map(discoveryResult => {
return {
name: discoveryResult.txt.friendly_name,
data: {
id: discoveryResult.id,
hostname: discoveryResult.hostname,
address: discoveryResult.address,
port: discoveryResult.port,
devicetype: discoveryResult.txt.devicetype,
},
};
});
return devices;
}
}
module.exports = MyDriver;