MyElectricalData / myelectricaldata_import

131 stars 35 forks source link

[FEATURES] - sensor HA avec détails des x derniers jours (max ? 5) #243

Closed vingerha closed 1 year ago

vingerha commented 1 year ago

Je voudrais créer des graphs pour ma consommation des derniers jours plus détaillés Car le bdd a déjà ces données je le voix comme ça:

  1. parametre (config.yaml) pour # jours dans le sensor (max 5)
  2. sensor avec
    • state: nombre des jours couvert
    • attributes
      time: 
      2022-12-01 00:00:00
      2022-12-01 00:30:00
      2022-12-01 01:00:00
      etc.
      etc.
      consumption:
      132
      134
      121
      etc
      etc

      Avec un tel sensor je peux construire des charts apex/plotly Ce sensor aide aussi ceux qu ont pas un truc temps-reel comme zlinky/tic

m4dm4rtig4n commented 1 year ago

Est-ce que ceci te convient ? State : 5 Config :

{
  "name": "myelectricaldata_last5day_XXXXXXXXXXXXX",
  "uniq_id": "myelectricaldata_last5day.XXXXXXXXXXXXX",
  "stat_t": "ha_discovery/sensor/myelectricaldata_last_5_day/XXXXXXXXXXXXX/state",
  "json_attr_t": "ha_discovery/sensor/myelectricaldata_last_5_day/XXXXXXXXXXXXX/attributes",
  "unit_of_measurement": "d",
  "device": {
    "identifiers": [
      "linky_history_XXXXXXXXXXXXX"
    ],
    "name": "Linky XXXXXXXXXXXXX",
    "model": "Linky",
    "manufacturer": "MyElectricalData"
  }
}

Attributes :

{
  "numPDL": "XXXXXXXXXXXXX",
  "activationDate": "2018-08-31 00:00:00",
  "lastUpdate": "2022-12-22 23:57:02",
  "timeLastCall": "2022-12-22 23:57:02",
  "time": [
    "2022-12-21 23:30:00",
    "2022-12-21 23:00:00",
    "2022-12-21 22:30:00",
    "2022-12-21 22:00:00",
    "2022-12-21 21:30:00",
    "2022-12-21 21:00:00",
    "2022-12-21 20:30:00",
    "2022-12-21 20:00:00",
    "2022-12-21 19:30:00",
    "2022-12-21 19:00:00",
    "2022-12-21 18:30:00",
    "2022-12-21 18:00:00",
    "2022-12-21 17:30:00",
    "2022-12-21 17:00:00",
    "2022-12-21 16:30:00",
    "2022-12-21 16:00:00",
    "2022-12-21 15:30:00",
    "2022-12-21 15:00:00",
    "2022-12-21 14:30:00",
    "2022-12-21 14:00:00",
    "2022-12-21 13:30:00",
    "2022-12-21 13:00:00",
    "2022-12-21 12:30:00",
    "2022-12-21 12:00:00",
    "2022-12-21 11:30:00",
    "2022-12-21 11:00:00",
    "2022-12-21 10:30:00",
    "2022-12-21 10:00:00",
    "2022-12-21 09:30:00",
    "2022-12-21 09:00:00",
    "2022-12-21 08:30:00",
    "2022-12-21 08:00:00",
    "2022-12-21 07:30:00",
    "2022-12-21 07:00:00",
    "2022-12-21 06:30:00",
    "2022-12-21 06:00:00",
    "2022-12-21 05:30:00",
    "2022-12-21 05:00:00",
    "2022-12-21 04:30:00",
    "2022-12-21 04:00:00",
    "2022-12-21 03:30:00",
    "2022-12-21 03:00:00",
    "2022-12-21 02:30:00",
    "2022-12-21 02:00:00",
    "2022-12-21 01:30:00",
    "2022-12-21 01:00:00",
    "2022-12-21 00:30:00",
    "2022-12-21 00:00:00",
    "2022-12-20 23:30:00",
    "2022-12-20 23:00:00",
    "2022-12-20 22:30:00",
    "2022-12-20 22:00:00",
    "2022-12-20 21:30:00",
    "2022-12-20 21:00:00",
    "2022-12-20 20:30:00",
    "2022-12-20 20:00:00",
    "2022-12-20 19:30:00",
    "2022-12-20 19:00:00",
    "2022-12-20 18:30:00",
    "2022-12-20 18:00:00",
    "2022-12-20 17:30:00",
    "2022-12-20 17:00:00",
    "2022-12-20 16:30:00",
    "2022-12-20 16:00:00",
    "2022-12-20 15:30:00",
    "2022-12-20 15:00:00",
    "2022-12-20 14:30:00",
    "2022-12-20 14:00:00",
    "2022-12-20 13:30:00",
    "2022-12-20 13:00:00",
    "2022-12-20 12:30:00",
    "2022-12-20 12:00:00",
    "2022-12-20 11:30:00",
    "2022-12-20 11:00:00",
    "2022-12-20 10:30:00",
    "2022-12-20 10:00:00",
    "2022-12-20 09:30:00",
    "2022-12-20 09:00:00",
    "2022-12-20 08:30:00",
    "2022-12-20 08:00:00",
    "2022-12-20 07:30:00",
    "2022-12-20 07:00:00",
    "2022-12-20 06:30:00",
    "2022-12-20 06:00:00",
    "2022-12-20 05:30:00",
    "2022-12-20 05:00:00",
    "2022-12-20 04:30:00",
    "2022-12-20 04:00:00",
    "2022-12-20 03:30:00",
    "2022-12-20 03:00:00",
    "2022-12-20 02:30:00",
    "2022-12-20 02:00:00",
    "2022-12-20 01:30:00",
    "2022-12-20 01:00:00",
    "2022-12-20 00:30:00",
    "2022-12-20 00:00:00",
    "2022-12-19 23:30:00",
    "2022-12-19 23:00:00",
    "2022-12-19 22:30:00",
    "2022-12-19 22:00:00",
    "2022-12-19 21:30:00",
    "2022-12-19 21:00:00",
    "2022-12-19 20:30:00",
    "2022-12-19 20:00:00",
    "2022-12-19 19:30:00",
    "2022-12-19 19:00:00",
    "2022-12-19 18:30:00",
    "2022-12-19 18:00:00",
    "2022-12-19 17:30:00",
    "2022-12-19 17:00:00",
    "2022-12-19 16:30:00",
    "2022-12-19 16:00:00",
    "2022-12-19 15:30:00",
    "2022-12-19 15:00:00",
    "2022-12-19 14:30:00",
    "2022-12-19 14:00:00",
    "2022-12-19 13:30:00",
    "2022-12-19 13:00:00",
    "2022-12-19 12:30:00",
    "2022-12-19 12:00:00",
    "2022-12-19 11:30:00",
    "2022-12-19 11:00:00",
    "2022-12-19 10:30:00",
    "2022-12-19 10:00:00",
    "2022-12-19 09:30:00",
    "2022-12-19 09:00:00",
    "2022-12-19 08:30:00",
    "2022-12-19 08:00:00",
    "2022-12-19 07:30:00",
    "2022-12-19 07:00:00",
    "2022-12-19 06:30:00",
    "2022-12-19 06:00:00",
    "2022-12-19 05:30:00",
    "2022-12-19 05:00:00",
    "2022-12-19 04:30:00",
    "2022-12-19 04:00:00",
    "2022-12-19 03:30:00",
    "2022-12-19 03:00:00",
    "2022-12-19 02:30:00",
    "2022-12-19 02:00:00",
    "2022-12-19 01:30:00",
    "2022-12-19 01:00:00",
    "2022-12-19 00:30:00",
    "2022-12-19 00:00:00",
    "2022-12-18 23:30:00",
    "2022-12-18 23:00:00",
    "2022-12-18 22:30:00",
    "2022-12-18 22:00:00",
    "2022-12-18 21:30:00",
    "2022-12-18 21:00:00",
    "2022-12-18 20:30:00",
    "2022-12-18 20:00:00",
    "2022-12-18 19:30:00",
    "2022-12-18 19:00:00",
    "2022-12-18 18:30:00",
    "2022-12-18 18:00:00",
    "2022-12-18 17:30:00",
    "2022-12-18 17:00:00",
    "2022-12-18 16:30:00",
    "2022-12-18 16:00:00",
    "2022-12-18 15:30:00",
    "2022-12-18 15:00:00",
    "2022-12-18 14:30:00",
    "2022-12-18 14:00:00",
    "2022-12-18 13:30:00",
    "2022-12-18 13:00:00",
    "2022-12-18 12:30:00",
    "2022-12-18 12:00:00",
    "2022-12-18 11:30:00",
    "2022-12-18 11:00:00",
    "2022-12-18 10:30:00",
    "2022-12-18 10:00:00",
    "2022-12-18 09:30:00",
    "2022-12-18 09:00:00",
    "2022-12-18 08:30:00",
    "2022-12-18 08:00:00",
    "2022-12-18 07:30:00",
    "2022-12-18 07:00:00",
    "2022-12-18 06:30:00",
    "2022-12-18 06:00:00",
    "2022-12-18 05:30:00",
    "2022-12-18 05:00:00",
    "2022-12-18 04:30:00",
    "2022-12-18 04:00:00",
    "2022-12-18 03:30:00",
    "2022-12-18 03:00:00",
    "2022-12-18 02:30:00",
    "2022-12-18 02:00:00",
    "2022-12-18 01:30:00",
    "2022-12-18 01:00:00",
    "2022-12-18 00:30:00",
    "2022-12-18 00:00:00",
    "2022-12-17 23:30:00",
    "2022-12-17 23:00:00",
    "2022-12-17 22:30:00",
    "2022-12-17 22:00:00",
    "2022-12-17 21:30:00",
    "2022-12-17 21:00:00",
    "2022-12-17 20:30:00",
    "2022-12-17 20:00:00",
    "2022-12-17 19:30:00",
    "2022-12-17 19:00:00",
    "2022-12-17 18:30:00",
    "2022-12-17 18:00:00",
    "2022-12-17 17:30:00",
    "2022-12-17 17:00:00",
    "2022-12-17 16:30:00",
    "2022-12-17 16:00:00",
    "2022-12-17 15:30:00",
    "2022-12-17 15:00:00",
    "2022-12-17 14:30:00",
    "2022-12-17 14:00:00",
    "2022-12-17 13:30:00",
    "2022-12-17 13:00:00",
    "2022-12-17 12:30:00",
    "2022-12-17 12:00:00",
    "2022-12-17 11:30:00",
    "2022-12-17 11:00:00",
    "2022-12-17 10:30:00",
    "2022-12-17 10:00:00",
    "2022-12-17 09:30:00",
    "2022-12-17 09:00:00",
    "2022-12-17 08:30:00",
    "2022-12-17 08:00:00",
    "2022-12-17 07:30:00",
    "2022-12-17 07:00:00",
    "2022-12-17 06:30:00",
    "2022-12-17 06:00:00",
    "2022-12-17 05:30:00",
    "2022-12-17 05:00:00",
    "2022-12-17 04:30:00",
    "2022-12-17 04:00:00",
    "2022-12-17 03:30:00",
    "2022-12-17 03:00:00",
    "2022-12-17 02:30:00",
    "2022-12-17 02:00:00",
    "2022-12-17 01:30:00",
    "2022-12-17 01:00:00",
    "2022-12-17 00:30:00",
    "2022-12-17 00:00:00"
  ],
  "consumption": [
    3200,
    3204,
    4066,
    3500,
    736,
    756,
    2608,
    3012,
    2058,
    2236,
    2386,
    1190,
    872,
    848,
    808,
    802,
    838,
    874,
    790,
    1244,
    1278,
    1152,
    902,
    4148,
    2040,
    2104,
    874,
    1302,
    2740,
    2274,
    4564,
    4540,
    4720,
    4862,
    8464,
    3368,
    1132,
    684,
    4750,
    708,
    946,
    1194,
    4682,
    3378,
    3034,
    3754,
    4874,
    3490,
    3270,
    3250,
    3180,
    3216,
    606,
    1568,
    5982,
    4398,
    7146,
    9608,
    8002,
    6796,
    9150,
    580,
    4290,
    1530,
    916,
    896,
    1044,
    1762,
    2718,
    1100,
    854,
    1406,
    1406,
    4032,
    862,
    1142,
    1786,
    810,
    758,
    868,
    2608,
    3584,
    2862,
    4546,
    4110,
    2532,
    3612,
    5762,
    2746,
    2368,
    1342,
    4558,
    920,
    2596,
    4028,
    6790,
    4354,
    3774,
    3850,
    3670,
    2130,
    3366,
    7918,
    9558,
    8380,
    7038,
    7138,
    10482,
    9218,
    1136,
    1378,
    3660,
    3006,
    1154,
    1390,
    4988,
    1494,
    1290,
    3398,
    1376,
    1900,
    2952,
    1378,
    1108,
    3738,
    1314,
    1230,
    2538,
    3454,
    1208,
    1184,
    2872,
    7820,
    4046,
    1806,
    3570,
    6000,
    2072,
    2300,
    2134,
    2580,
    3366,
    2240,
    2512,
    2350,
    4060,
    3646,
    3734,
    4058,
    5106,
    6414,
    7918,
    7418,
    6986,
    4266,
    3382,
    1426,
    3314,
    2522,
    1842,
    1828,
    1818,
    2352,
    4444,
    3512,
    2448,
    3648,
    4378,
    4216,
    2418,
    2466,
    3900,
    5218,
    2336,
    6798,
    6296,
    6814,
    11742,
    12388,
    3562,
    7588,
    5146,
    4994,
    6988,
    5870,
    3158,
    7232,
    3952,
    4314,
    4878,
    3868,
    4008,
    3868,
    3598,
    7084,
    5926,
    4310,
    9056,
    9680,
    8622,
    3154,
    1860,
    3720,
    2522,
    3906,
    1124,
    2282,
    2280,
    2654,
    940,
    1724,
    3132,
    4374,
    2464,
    3706,
    5092,
    4740,
    3282,
    4982,
    6570,
    11604,
    3652,
    4980,
    8846,
    10674,
    13848,
    10996,
    5166,
    5992,
    4564,
    6078,
    5812,
    5330,
    5936,
    6466,
    4318,
    9074,
    8616,
    5244,
    5256
  ]
}
vingerha commented 1 year ago

Oui... ça marche bien 👍 j. ai crée un sensor testevents et j'ai copié/collé le tout dedans image


type: custom:apexcharts-card
header:
  title: Test
  show: true
span:
  start: hour
  offset: '-6d'
apex_config:
  dataLabels:
    enabled: true
series:
  - entity: sensor.testevents
    name: test
    type: line
    extend_to: false
    data_generator: |
      return entity.attributes.time.map((time, index) => {     
                return [new Date(time).getTime(), entity.attributes.consumption[index]];
              });