Nested JSON in Homey Script - working on Volt Time Cloud Charger script

Maybe someone is able to help here.
I’m busy creating a Homey Script that serves to read all data from a Volt Time Source 2 EV charger and exposes all this data to later control the charger via other scripts - and to use it in advanced flow logic. I’m quite far already, but this is the problem I run into;
I’m using the data provided by Volt Time Cloud itself in the API docs - so I don’t expose any personal information;

Consider this response structure:

  "data": {
      "id": 596411,
      "identity": "VTT_0001",
      "connection_status": "offline",
      "status": "Available",
      "error": "NoError",
      "error_info": null,
      "created_at": "2023-11-01T09:17:10.000000Z",
      "updated_at": "2023-11-02T14:15:11.000000Z",
      "connectors": [
              "id": 1655489,
              "charger_id": 596411,
              "connector_id": 1,
              "status": "Available",
              "error": "NoError",
              "error_info": null,
              "created_at": "2023-11-01T09:44:32.000000Z",
              "updated_at": "2023-11-01T10:15:36.000000Z"

I’m able to directly read any direct child by (after storing it in the variable ‘body’) adressing it as:

await tag (‘status’ ,[0].status); - this returns me the status exactly.

However; this does not work for the nested ‘connectors’ . and this is where it gets specific and weird;
I do get the expected data in postman - including the connectors child data.

If I however log the exact data homey is using from the query - it summarizes the child with
[ [Object] ]
, so I get;

“data”: {
“id”: 596411,
“identity”: “VTT_0001”,
“connection_status”: “offline”,
“status”: “Available”,
“error”: “NoError”,
“error_info”: null,
“created_at”: “2023-11-01T09:17:10.000000Z”,
“updated_at”: “2023-11-02T14:15:11.000000Z”,
“connectors”: [ [Object] ]

Now - obviously - even when using the correct syntax - I don’t get any data from the connectors child. instead it gives me: TypeError: Cannot read properties of undefined (reading ‘connectors’).

I’m not so knowledgeable that I have a strategy to work around this particular problem. Can someone point me in the right direction ? breaking up in a flow with response cards and additional logic and is - unless I can help it - not the way to go. I want the script to be as independent as can be.

Thanks in advance,


I don’t see how, because should be an array for that to work, and your example is showing that is an object.

I don’t know what you think the “correct syntax” is, but to access (say) the status of the first connector, the accessor is:[0].status

Robert, you know how sometimes when you are looping through repetitive work - you seem to miss the obvious ? Thanks for pointing out something I completely overlooked. My example of fetching the data was actually based upon earlier points in my script that did work. And almost every call in this API results in an array to begin with. So that is where my blind spot was - I missed the fact that data is not an array here - as opposed to every earlier resultset.
Thanks ! it’s working - expecting to finish this script soon and then I’ll be able to get all data from the charger - and control it too - via homeyscript.

1 Like

VoltTime Charger

  • first version of script is available