Hi!
Trying to learn how to build an app for homey together with Claude trying to expand
my knowledge from Powershell and Python. ![]()
Connecting to an API, searching the data, saving it all works.
Setting up a device hits a bit of a snag though.
The data contains a certain train station and I need to add it as a device.
And it shows up and all when adding it in Homey but the last part.
Add Device doesn’t work.. The frikkin button is missing and neither me or
Claude can find the issue.
I’m guessing somethings missing in the driver.js?
'use strict';
const Homey = require('homey');
/**
* TransportBoardDriver — handles pairing and driver-level lifecycle.
*
* Pairing flow:
* 1. search_stop (custom HTML view)
* - User types a stop/station name
* - Driver calls Trafiklab Stop Lookup
* - User picks a result (rikshållplats group)
* 2. list_devices (built-in Homey template)
* - Shows the selected stop as a device to add
* - User confirms → device is created
*/
class TransportBoardDriver extends Homey.Driver {
async onInit() {
this.log('TransportBoardDriver initialised');
}
/**
* Called by the list_devices pair template to populate the device list.
*
* Stop search is handled in App Settings (settings/index.html) where the
* Homey bridge is available. Stops found there are saved to Homey settings
* under the key "savedStops". This method reads that list and presents each
* saved stop as a device the user can add.
*
* Using onPairListDevices() (not onPair + session.setHandler) is what causes
* the list_devices template to show its built-in "Add devices" button.
*/
async onPairListDevices() {
const savedStops = this.homey.settings.get('savedStops') || [];
if (!Array.isArray(savedStops) || savedStops.length === 0) {
throw new Error(
'No stops saved yet.\n\n'
+ 'Go to Apps → Trafiklab Departures → Settings, '
+ 'search for your stop, and click "Save Stop". '
+ 'Then come back here to add a device.',
);
}
return savedStops.map(stop => ({
name: stop.name,
data: {
id: stop.id,
stopId: stop.id,
},
}));
}
}
module.exports = TransportBoardDriver;
