This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
Closed
Noob question around importing devices
AndrewChittams
Member
in Archive
Hi All,
I am new to coding with NodeJS and I have been working on my lighting driver, but have a question about importing the devices into Homey. I have followed the example in the developers library, but have gotten a bit lost when trying to import multi devices.
I have a command that lists all the lighting devices which I have feed into an array.
Is there a method that I can import all the devices in one go? or do I need to inject them one at a time?
Any help would be very appreciated
I am new to coding with NodeJS and I have been working on my lighting driver, but have a question about importing the devices into Homey. I have followed the example in the developers library, but have gotten a bit lost when trying to import multi devices.
I have a command that lists all the lighting devices which I have feed into an array.
Is there a method that I can import all the devices in one go? or do I need to inject them one at a time?
Any help would be very appreciated
This discussion has been closed.
Comments
Not exactly sure what you mean.. Do you have a code example?
I think I see now! I have been using the pairing method.
I should be using the init method! (insert emoticon head slap) now I can register all 25 devices in one go.
devices_data.forEach(function(device_data){
initDevice( device_data );
})
but how do I structure the devices_data array? as now I am getting errors
Driver init();
https://github.com/freemann/com.sony.bravia.androidtv/blob/master/drivers/tv/driver.js#L159
Device init;
https://github.com/freemann/com.sony.bravia.androidtv/blob/master/drivers/tv/driver.js#L107
I can see how the init (); is being passed from homey the device and you testing to see if the device is on and the status of the device is being passed back to homey.
What I am trying to do is add multiple new devices, I think I am correct in saying this is done via the pair(); function.
I have a command that lists all the lighting devices, there light levels and state
tree //ANDY_XMS/254/56
320-Applications:
Is there away to add all these devices to homey in one go, or do I need to loop through each one, add them to honey one at a time?
And for each device use Homey.addDevice (allmost at the bottom of the page here: https://developers.athom.com/library/drivers/pairing/)
and replace the 'list_devices' with 'add_devices'
}
Thanks for everyone help I have worked out the array syntax which was stopping me from adding multiple units, with this I can now import the 25 unit into the devices array and then into homey.