I am attempting to write a function in Nodejs that returns all of the devices that are in my network. I am using this code:
var fs = require('fs');
var axios = require('axios');
var token = await fs.readFileSync("../hue_token.txt").toString();
token = token.replace(/(\r\n|\n|\r)/gm, "");
var lightResp = await axios.get(`http://192.168.1.58/api/${token}/lights`, {
});
var stringedResp = Object.values(lightResp);
this.logger.info("Here is the lightResp:\n" + stringedResp);
But all that gets returned is:
200,OK,[object Object],[object Object],[object Object],[object Object]
Here is a small sample of what it should look like:
{
"4": {
"state": {
"on": false,
"bri": 254,
"alert": "select",
"mode": "homeautomation",
"reachable": true
},
"swupdate": {
"state": "noupdates",
"lastinstall": "2021-08-20T16:38:24"
},
"type": "Dimmable light",
"name": "Hue white lamp 1",
"modelid": "--",
"manufacturername": "Signify Netherlands B.V.",
"productname": "Hue white lamp",
"capabilities": {
"certified": true,
"control": {
"mindimlevel": 5000,
"maxlumen": 840
},
"streaming": {
"renderer": false,
"proxy": false
}
},
"config": {
"archetype": "classicbulb",
"function": "functional",
"direction": "omnidirectional",
"startup": {
"mode": "safety",
"configured": true
}
},
"uniqueid": "--",
"swversion": "1.88.1",
"swconfigid": "A0DE501E",
"productid": "Philips-LWB014-1-A19DLv3"
}
I am not sure what I am missing to further breakout the objects that get returned. I tried iterating through the objects with a for loop and couldn't get anything returned either.