howi Skrevet 25. november 2022 Skrevet 25. november 2022 Hei, jeg har laget meg en sensor via Tibber APIen som har disse attributtene : Attributes Data viewer: homes: - consumption: nodes: - from: '2021-11-01T00:00:00.000+01:00' cost: 2444.0790312625 consumption: 1774.194 - from: '2021-12-01T00:00:00.000+01:00' cost: 6337.83502785 consumption: 2855.022 - from: '2022-01-01T00:00:00.000+01:00' cost: 3693.5323019 consumption: 2091.36 - from: '2022-02-01T00:00:00.000+01:00' cost: 2890.0519197125 consumption: 1897.162 - from: '2022-03-01T00:00:00.000+01:00' cost: 3269.835485575 consumption: 1390.317 - from: '2022-04-01T00:00:00.000+02:00' cost: 2759.9224379625 consumption: 1259.916 - from: '2022-05-01T00:00:00.000+02:00' cost: 2073.228999575 consumption: 964.274 - from: '2022-06-01T00:00:00.000+02:00' cost: 770.6099757625 consumption: 308.307 - from: '2022-07-01T00:00:00.000+02:00' cost: 2757.3187822125 consumption: 850.927 - from: '2022-08-01T00:00:00.000+02:00' cost: 2451.6382636875 consumption: 507.456 - from: '2022-09-01T00:00:00.000+02:00' cost: 2562.2602708625 consumption: 591.231 - from: '2022-10-01T00:00:00.000+02:00' cost: 2688.7950699875 consumption: 1562.747 Jeg vil lage meg en Apex-chart med 'cost' og 'consumption', men har problemer med å få access til dataene korrekt. Som eksempel har jeg noe lignende med Nordpool-data, men sliter med data generatoren. Eksempel som fungerer bra : type: custom:apexcharts-card experimental: color_threshold: true graph_span: 24h header: title: Strompreis Morgen show: true span: start: day offset: +1d series: - entity: sensor.nordpool_kwh_krsand_nok_3_10_025 type: column data_generator: | return entity.attributes.raw_tomorrow.map((start, index) => { return [new Date(start["start"]).getTime(), entity.attributes.raw_tomorrow[index]["value"]]; }); color_threshold: - value: 0 color: green opacity: 1 - value: 3 color: yellow - value: 6 color: red Noen som kan hjelpe med med generator formuleringen ? Siter
howi Skrevet 7. desember 2022 Forfatter Skrevet 7. desember 2022 Jeg kommer med en beskrivelse litt senere i kveld. 1 Siter
howi Skrevet 7. desember 2022 Forfatter Skrevet 7. desember 2022 Først, en sensor : med som eksempel en query for 'cost' og 'consumption' , 'MONTHLY' og 12 måneder rest: - resource: "https://api.tibber.com/v1-beta/gql" scan_interval: 3600 method: POST payload: '{"query": "{ viewer { homes { consumption (resolution: MONTHLY, last: 12) { nodes { from cost consumption } }} } } "}' headers: Authorization: !secret tibberAuthorization Content-Type: application/json sensor: - name: tibber_monat_date_1 value_template: '{{ value_json.data.viewer.homes.0.consumption.nodes.0.from }} ' json_attributes: - "data" Resultat ( sensor attributes ) blir dette : Attributes Data viewer: homes: - consumption: nodes: - from: '2021-12-01T00:00:00.000+01:00' cost: 6337.83502785 consumption: 2855.022 - from: '2022-01-01T00:00:00.000+01:00' cost: 3693.5323019 consumption: 2091.36 - from: '2022-02-01T00:00:00.000+01:00' cost: 2890.0519197125 consumption: 1897.162 - from: '2022-03-01T00:00:00.000+01:00' cost: 3269.835485575 consumption: 1390.317 - from: '2022-04-01T00:00:00.000+02:00' cost: 2759.9224379625 consumption: 1259.916 - from: '2022-05-01T00:00:00.000+02:00' cost: 2073.228999575 consumption: 964.274 - from: '2022-06-01T00:00:00.000+02:00' cost: 770.6099757625 consumption: 308.307 - from: '2022-07-01T00:00:00.000+02:00' cost: 2757.3187822125 consumption: 850.927 - from: '2022-08-01T00:00:00.000+02:00' cost: 2451.6382636875 consumption: 507.456 - from: '2022-09-01T00:00:00.000+02:00' cost: 2562.2602708625 consumption: 591.231 - from: '2022-10-01T00:00:00.000+02:00' cost: 2688.7950699875 consumption: 1562.747 - from: '2022-11-01T00:00:00.000+01:00' cost: 2278.7636694125 consumption: 1610.012 Nå mangler bare et apex-chart : type: custom:apexcharts-card graph_span: 365d yaxis: - id: first min: 0 max: 8000 decimals: 0 - id: second min: 0 max: 3000 decimals: 0 opposite: true header: title: Kosten - Verbrauch (12 Mon ) show: true show_states: false series: - entity: sensor.tibber_monat_date_1 type: column name: Kosten show: legend_value: false yaxis_id: first data_generator: > return entity.attributes.data.viewer.homes[0].consumption.nodes.map((start, index) => { return [new Date(start["from"]).getTime(), entity.attributes.data.viewer.homes[0].consumption.nodes[index]["cost"]]; }); - entity: sensor.tibber_monat_date_1 type: column name: Verbrauch show: legend_value: false yaxis_id: second data_generator: > return entity.attributes.data.viewer.homes[0].consumption.nodes.map((cost, index) => { return [new Date(cost["from"]).getTime(), entity.attributes.data.viewer.homes[0].consumption.nodes[index]["consumption"]]; }); 1 Siter
Anbefalte innlegg
Bli med i samtalen
Du kan publisere innhold nå og registrere deg senere. Hvis du har en konto, logg inn nå for å poste med kontoen din.