Help Implementing Energy-Charts API

Hi Community,

id like to implement some data from www.energy-charts.info API. (For example: Energy-Charts API)

But i have no idea where to start… I think the RESTful Sensor would work. Can someone help me getting the Traffic Signal implemented into HA?

Thanks

‘some’ data? What is it that you are after, which data and what target use ? Graph only?

I want to catch this Graph to work with the data in HASS: Energy-Charts

And here is the API for that graph: Energy-Charts API

This will put the data in a sensor with attributes
you should then use a graph tool like apexchars to get the data displayed…you can rename it along your wishes of course

rest:          
  - authentication: basic
    scan_interval: 200
    verify_ssl: false
    headers:
      Content-Type: application/json
      User-Agent: Home Assistant
      Accept-Encoding: identity
    resource: https://api.energy-charts.info/traffic_signal?country=de
    sensor:             
      - name: Energy Charts 1
        unique_id: energy_charts_1
        value_template: "OK"
        json_attributes_path: $.0
        json_attributes:
            - data
            - xAxisValues
1 Like

very simple chart, for you to tweak tune (check other posts on Apex as this is not my ‘thing’)

type: custom:apexcharts-card
header:
  title: EnergyG1
  show: true
apex_config:
  dataLabels:
    enabled: true
span:
  start: day
series:
  - entity: sensor.energy_charts_1
    name: Test
    data_generator: |
      return entity.attributes.xAxisValues.map((start, index) => {     
                return [new Date(start), entity.attributes.data[index]];
      });

1 Like

Thank you very much! I could build it in my environment with apexcharts. The next thing would be to have a entity wich gives the data at this time live. Is something like this possible?

Maybe it could work with a template sensor wich ich looking up the actual time and then the data from sensor…

Because i want to Look up this data in the automation to start charging my car while the Renuable Energy Share is > 80% for example.

If the data is in the same sensor then yes you could do that, you’d need to iterate over it with a jinja template which I donot have ready at hand. Probably find the index of the xAxisValues / timestamp and then use that to get the value with that index from data

1 Like

This would do 89.5 for 16:00 today

{{ states.sensor.energy_charts_1.attributes.data[states.sensor.energy_charts_1.attributes.xAxisValues.index((as_timestamp(now().replace(minute=00,second=00,microsecond=00))*1000 )| int)] }}
1 Like

Thank you very much! I got it working with a template sensor and can use it for automation!

Nice Community!