API REST Get command

Hi,
I would like to send a REST GET-command to my HA.
It works for one entity:

/api/states/sensor.victron_vebus_out_l1_power_246

I got following answer:

{“entity_id”:“sensor.victron_vebus_out_l1_power_246”,“state”:“3970.0”,“attributes”:{“state_class”:“measurement”,“unit_of_measurement”:“W”,“device_class”:“power”,“friendly_name”:“Leistung Haus L1”},“last_changed”:“2026-04-28T11:31:22.079562+00:00”,“last_reported”:“2026-04-28T11:31:52.071868+00:00”,“last_updated”:“2026-04-28T11:31:22.079562+00:00”}

But I want to get the state of approx. 10 different entities.
sensor.victron_vebus_out_l1_power_246
sensor.victron_vebus_out_l2_power_246
sensor.victron_vebus_out_l3_power_246
sensor.victron_system_battery_power
switch.heizpatrone_l1
switch.heizpatrone_l2
switch.heizpatrone_l3
3 more…

Of course I can call 10 times a GET command for each entity but it doesn’t make a good impression.

Someone has the same problem like me:

Any idea, how can I do this with one command?

You can’t, look at the documented commands:

That’s what you have available for the rest api.

ok, there is no information about get-command for multi-entities.
There is no other way to do this?
Can I collect all different states inside HA and ask this by one get command? If yes, how can I do this?

If any of the API’s endpoints provide an array of all of the points you want simultaneously, you can use curl in a command line sensor and dump the data in attributes. Then, you can create template sensors using the attributes to split up the data. That way, you only have one API call. This is what I do for stock prices.

You could use the websocket api.

You could also use the end point template. E.g. I have this rest_command:

template:
  url: "https://localhost/api/template"
  content_type: 'application/json'
  verify_ssl: false
  headers:
    authorization: !secret rest_commands
    content-type: 'application/json'
  method: 'post'
  payload: '{{ {"template": text|string}|to_json }}'

Using it in Developer Tools, Actions as:

action: rest_command.template
data:
  text: >-
    {% raw %}
      {{ [
          'binary_sensor.24ccc444_0ec8fd9e',
          'binary_sensor.24ccc444_0ec8fd9e_browser_dark_mode',
          'binary_sensor.24ccc444_0ec8fd9e_browser_fullykiosk'
        ]|expand
      }}
    {% endraw %}

(the “raw-endraw” block only exists to stop HA from evaluating the template before calling the command; if this template API is called outside of HA, e.g. via curl, then there should be no “raw-endraw”)

Result:

content: >-
  [<template TemplateState(<state binary_sensor.24ccc444_0ec8fd9e=on;
  type=browser_mod, browserID=24ccc444-0ec8fd9e, activityType=userInteraction,
  device_class=motion, friendly_name=24ccc444-0ec8fd9e @
  2026-04-28T17:12:52.012213+02:00>)>, <template TemplateState(<state
  binary_sensor.24ccc444_0ec8fd9e_browser_dark_mode=off; type=browser_mod,
  browserID=24ccc444-0ec8fd9e, icon=mdi:theme-light-dark,
  friendly_name=24ccc444-0ec8fd9e Browser dark mode @
  2026-04-28T17:12:09.345643+02:00>)>, <template TemplateState(<state
  binary_sensor.24ccc444_0ec8fd9e_browser_fullykiosk=off; type=browser_mod,
  browserID=24ccc444-0ec8fd9e, data=undefined, icon=mdi:alpha-f,
  friendly_name=24ccc444-0ec8fd9e Browser FullyKiosk @
  2026-04-28T17:10:57.458461+02:00>)>]

Sadly the webhook doesn’t return data, which makes sense. Recently I used a webhook to trigger an automation to send a JSON response to an endpoint on my calling system to return more complex (or composed) data.

I found a way with template call:
<>
tmpStr := ‘{{ [’ +
‘{’‘entity’‘:’‘l1_power’‘,’ +
‘’‘state’‘: states(’‘sensor.victron_vebus_out_l1_power_246’‘),’ +
‘’‘unit’‘: state_attr(’‘sensor.victron_vebus_out_l1_power_246’‘,’‘unit_of_measurement’‘)},’ +

  '{''entity'':''l2_power'','        +
   '''state'': states(''sensor.victron_vebus_out_l2_power_246''),' +
   '''unit'': state_attr(''sensor.victron_vebus_out_l2_power_246'',''unit_of_measurement'')},' +

  '{''entity'':''l3_power'','        +
   '''state'': states(''sensor.victron_vebus_out_l3_power_246''),' +
   '''unit'': state_attr(''sensor.victron_vebus_out_l3_power_246'',''unit_of_measurement'')},' +

  '{''entity'':''battery_power'','   +
   '''state'': states(''sensor.victron_system_battery_power''),' +
   '''unit'': state_attr(''sensor.victron_system_battery_power'',''unit_of_measurement'')},' +

  '{''entity'':''heizpatrone_l1'','  +
   '''state'': states(''switch.heizpatrone_l1''),' +
   '''unit'': ''on/off''},' +

  '{''entity'':''heizpatrone_l2'','  +
   '''state'': states(''switch.heizpatrone_l2''),' +
   '''unit'': ''on/off''},' +

  '{''entity'':''heizpatrone_l3'','  +
   '''state'': states(''switch.heizpatrone_l3''),' +
   '''unit'': ''on/off''}' +
  '] | tojson }}';

</>

This string I convert to JSON and send a POST command to HA:


Post(‘/api/template’)

The result is each state of sensor with his unit.

You could also use a macro and save yourself some typing/repeating, e.g.:

{% macro serialize(e,returns) -%}
  {% set unit = state_attr(e[1],'unit_of_measurement') or e[2]|default('n/a') %}
  {{ returns({'entity': e[0], 'state': states(e[1]), 'unit': unit }) }}
{% endmacro -%}
{{[
  ('l1_power', 'sensor.victron_vebus_out_l1_power_246'),
  ('l2_power', 'sensor.victron_vebus_out_l2_power_246'),
  ...
  ('heizpatrone_l3', 'switch.heizpatrone_l3','on/off')
]|map('apply',serialize|as_function)|list|to_json }}

The macro can also be placed in custom templates