Get value from sensor on another HASS server

Hi, i’m struggin finding a way for make a template helper work. Essentially i want to clone and update a sensor on another home assistance server on the same local network. I create a tempalte helper in the gui with this config:

- platform: rest
  resource: http://192.168.99.8:8123/api/states/sensor.solar_panel_to_grid_w
  scan_interval: 60
  value_template: "{{ value_json }}"
  headers:    
      Authorization: 'Bearer xxxxxxxxxxxx'
      content-type: 'application/json'```

but i get a undefined value_json error. if i use the same data in a curl request i get this:

{"entity_id":"sensor.solar_panel_to_grid_w","state":"2413.0","attributes":{"unit_of_measurement":"W","icon":"mdi:solar-power","friendly_name":"Solar Panel To Grid W"},"last_changed":"2024-06-29T11:13:57.687217+00:00","last_reported":"2024-06-29T11:13:57.687217+00:00","last_updated":"2024-06-29T11:13:57.687217+00:00","context":{"id":"01J1HV7AXPDRD8AX4Y9VCP3NPJ","parent_id":null,"user_id":null}}%

Please clarify what you mean.

That is not a Template sensor AND the field in the Template Helper only accepts templates, not YAML configuration.

What you have posted is a REST sensor. It must be add to your configuration under the sensor integration. If you already have a sensors.yaml file, you can put it in there; otherwise place it in configuration.yaml under the top-level heading sensor.

FYI, you will need to change value_json to value_json.state. The value_template defines the state of the sensor and the whole value_json will exceed it’s 255 character limit.

1 Like

Ouch! totally misunderstood the template helper sense. I put all in the config file and is working now, thanks for your help, i spent 3 hours on this…