Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106353

Need some help with Variable URL and senser template

$
0
0

@Alaric wrote:

Hi,
As a newbee, I’m struggling (get stuck) with reading data from an URL that needs variables. After many tries and reading the documentation and inspiration from [Templates in command line sensor + Octopus Energy API], I would like to put my question for help in here

Currently my code is: (in configuration.yaml)

- sensor:
- platform: rest
    name: solar_inverter
    method: GET
    resource_template: >
      {% set startTime = (as_timestamp(now()) - (300)) | timestamp_custom('%Y-%m-%d %H:%m:%s', True) %}
      {% set endTime = (as_timestamp(now()))| timestamp_custom('%Y-%m-%d %H:%m:%s', True) %}
      https://monitoringapi.solaredge.com/equipment/<siteid>/<serialnr>/data?startTime={{starttime}}&endTime={{endtime}}&api_key=<api_key>

the url needs to be like this: https://monitoringapi.solaredge.com/equipment/{{site_id}}/{{serial}}/data?startTime=2020-05-21 00:20:00&endTime=2020-05-21 11:25:00&api_key={{API_KEY}}

Currenlty I have url data between “<>” hardcoded , serialnr, siteid and api_key

this results in an error:

Invalid state encountered for entity id: {entity_id}. "
homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity id: sensor.solar_inverter. State max length is 255 characters.'

I want to read a JSON element from the return data

value_template: '{{ value_json.data.telemetries.inverterMode }}'

But when I add this beneath the previous code, I don’see anything.
How Can I “debug” the URL ( in order to see if it has the correct format).

the goal is to trigger an alarm if the return value equals “FAULT”.

many thanks in advance
What is the thing I’m missing here.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 106353

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>