Help with HA Action recorder.get_statistics

I am trying to get use the HA Call Action Node but I cannot work out how to compile the data, I can get a dynamic start and end date using a function, but how to get the data is a mystery to me, this where I am with this.

   "start_time": startTime,
   "end_time": endTime,
   "statistic_ids":[
       "sensor.e_current_consumed",
       "sensor.temp_out"
   ],
   "period":"hour",
   "types":["mean","sum"],
   "units":{"sensor.e_current_consumed": "kWh","sensor.temp_out": "°C"}
}

I used the example in the Node, but this is all I get

object

_msgid: "6d86bf9646514c2f"
payload: 1774543768212
topic: ""
startTime: "2026-03-19T16:49:28.215Z"
endTime: "2026-03-26T16:49:28.2
``

Please can someone put me out of my misery, I have tried loads of combinations, but I just haven't got anywhere

Moved this to General category, as is not a project for sharing yet.

There are some HA users on this forum, you will have to wait till one reads this, or you could post the question in the HA forum.

Thanks, rather stupidly I put it in the wrong place, that's what comes of trying to emulate the wife, who can do more than one thing at a time. I shall stick to being a man in future.

Did you add an output to the action node and set it to results?

Aside from using get_statistics in an action node there is the get history node. I use that for getting the history of an entity.

I find it easier to use because you can set a relative time period rather than have to calculate the start and stop times.

Yes I was using the History Node, but I add a strange issue that I couldn't resolve too.
I have been sending a string as a startDate and endDate, which works but it gives me just a few results, which is only 1 day.
The format must be incorrect, but how should I be doing this.

My string I am sending, is for example
"2026-03-20T00:00:00.000Z"
"2026-03-27T23:59:59.999Z"

But that can't be right, so can you help with the correct format, I have tried lots of different ways

I have just had the EUREKA moment.

You have to send the dates

{
  "startDate": "2026-03-20T23:30:00+00:00",
  "endDate":   "2026-03-26T00:00:00+00:00"
}

Wow my brain is not quite done yet!!!

1 Like