Advertisement
Mika_Koskela

Nordpool apex-chart

Nov 14th, 2024
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 5.85 KB | None | 0 0
  1. ##### Kahden päivän näkymä #####
  2. type: custom:apexcharts-card
  3. update_interval: 15min
  4. graph_span: 2d
  5. span:
  6.   start: day
  7. header:
  8.   show: true
  9.   title: ""
  10.   show_states: false
  11. experimental:
  12.   color_threshold: true
  13. now:
  14.   show: true
  15.   color: "#2b8c04"
  16.   label: Nyt
  17. apex_config:
  18.   chart:
  19.     height: 250
  20.   grid:
  21.     padding:
  22.       left: -11
  23.       right: 18
  24.       top: -10
  25.       bottom: -5
  26.   legend:
  27.     show: false
  28.     showForSingleSeries: true
  29.     position: bottom
  30.     offsetY: 7
  31.   xaxis:
  32.     labels:
  33.       offsetX: 0
  34.       offsetY: 0
  35.       format: HH
  36.     axisTicks:
  37.       show: true
  38.       borderType: solid
  39.       color: "#121314"
  40.       height: 8
  41.     tooltip:
  42.       enabled: false
  43.   tooltip:
  44.     enabled: true
  45.     x:
  46.       show: true
  47.       format: klo HH:00
  48.     "y":
  49.       title: tt
  50. yaxis:
  51.   - decimals: 1
  52.     apex_config:
  53.       forceNiceScale: true
  54.       tickAmount: 8
  55.       labels:
  56.         offsetX: -14
  57. all_series_config:
  58.   stroke_width: -1
  59.   type: column
  60.   float_precision: 2
  61.   show:
  62.     extremas: true
  63.     legend_value: false
  64.     in_header: false
  65. series:
  66.   - entity: sensor.nordpool_kwh_fi_eur_3_10_0
  67.     name: Sähkönhinta
  68.     color: "#f57607"
  69.     unit: snt/kWh
  70.     data_generator: >
  71.      const tomorrowValid = entity.attributes.tomorrow_valid; const todayData =
  72.       entity.attributes.raw_today.map((start, index) => {
  73.         // Adjust the timestamp by adding 30 minutes (30 * 60 * 1000 milliseconds)
  74.         const timestamp = new Date(start["start"]).getTime() + 30 * 60 * 1000;
  75.         return [timestamp, entity.attributes.raw_today[index]["value"]];
  76.       });
  77.  
  78.       if (tomorrowValid === false) {
  79.         return todayData; // Use raw_today data if tomorrow_valid is false
  80.       } else {
  81.         const tomorrowData = entity.attributes.raw_tomorrow.map((start, index) => {
  82.           // Adjust the timestamp by adding 30 minutes (30 * 60 * 1000 milliseconds)
  83.           const timestamp = new Date(start["start"]).getTime() + 30 * 60 * 1000;
  84.           return [timestamp, entity.attributes.raw_tomorrow[index]["value"]];
  85.         });
  86.         const combinedData = [...todayData, ...tomorrowData];
  87.         combinedData.sort((a, b) => a[0] - b[0]);
  88.         return combinedData; // Use combined data if tomorrow_valid is true
  89.       }
  90.     extend_to: false
  91.     color_threshold:
  92.       - value: 1
  93.         color: "#00ff00"
  94.       - value: 1.5
  95.         color: "#66ff66"
  96.       - value: 2
  97.         color: "#99ff66"
  98.       - value: 2.5
  99.         color: "#ccff66"
  100.       - value: 3
  101.         color: "#ccff33"
  102.       - value: 4
  103.         color: "#ffff00"
  104.       - value: 5
  105.         color: "#ffcc00"
  106.       - value: 6
  107.         color: "#ff9933"
  108.       - value: 7
  109.         color: "#ff6600"
  110.       - value: 9
  111.         color: "#ff0000"
  112.       - value: 11
  113.         color: "#cc0000"
  114.       - value: 15
  115.         color: "#a60000"
  116.       - value: 19
  117.         color: "#700c0c"
  118.       - value: 26
  119.         color: "#360f0f"
  120.  
  121. ##### kuluvan päivän näkymä #####
  122. type: custom:apexcharts-card
  123. update_interval: 15min
  124. graph_span: 1d
  125. span:
  126.   start: day
  127. header:
  128.   show: true
  129.   title: ""
  130.   show_states: false
  131. experimental:
  132.   color_threshold: true
  133. now:
  134.   show: true
  135.   color: "#2b8c04"
  136.   label: Nyt
  137. apex_config:
  138.   chart:
  139.     height: 250
  140.   grid:
  141.     padding:
  142.       left: -11
  143.       right: 18
  144.       top: -10
  145.       bottom: -5
  146.   legend:
  147.     show: false
  148.     showForSingleSeries: true
  149.     position: bottom
  150.     offsetY: 7
  151.   xaxis:
  152.     labels:
  153.       offsetX: 0
  154.       offsetY: 0
  155.       format: HH
  156.     axisTicks:
  157.       show: true
  158.       borderType: solid
  159.       color: "#121314"
  160.       height: 8
  161.     tooltip:
  162.       enabled: false
  163.   tooltip:
  164.     enabled: true
  165.     x:
  166.       show: true
  167.       format: klo HH:00
  168.     "y":
  169.       title: tt
  170. yaxis:
  171.   - decimals: 1
  172.     apex_config:
  173.       forceNiceScale: true
  174.       tickAmount: 8
  175.       labels:
  176.         offsetX: -14
  177. all_series_config:
  178.   stroke_width: -1
  179.   type: column
  180.   float_precision: 2
  181.   show:
  182.     extremas: true
  183.     legend_value: false
  184.     in_header: false
  185. series:
  186.   - entity: sensor.nordpool_kwh_fi_eur_3_10_0
  187.     name: Sähkönhinta
  188.     color: "#f57607"
  189.     unit: snt/kWh
  190.     data_generator: >
  191.      const tomorrowValid = entity.attributes.tomorrow_valid; const todayData =
  192.       entity.attributes.raw_today.map((start, index) => {
  193.         // Adjust the timestamp by adding 30 minutes (30 * 60 * 1000 milliseconds)
  194.         const timestamp = new Date(start["start"]).getTime() + 30 * 60 * 1000;
  195.         return [timestamp, entity.attributes.raw_today[index]["value"]];
  196.       });
  197.  
  198.       if (tomorrowValid === false) {
  199.         return todayData; // Use raw_today data if tomorrow_valid is false
  200.       } else {
  201.         const tomorrowData = entity.attributes.raw_tomorrow.map((start, index) => {
  202.           // Adjust the timestamp by adding 30 minutes (30 * 60 * 1000 milliseconds)
  203.           const timestamp = new Date(start["start"]).getTime() + 30 * 60 * 1000;
  204.           return [timestamp, entity.attributes.raw_tomorrow[index]["value"]];
  205.         });
  206.         const combinedData = [...todayData, ...tomorrowData];
  207.         combinedData.sort((a, b) => a[0] - b[0]);
  208.         return combinedData; // Use combined data if tomorrow_valid is true
  209.       }
  210.     extend_to: false
  211.     color_threshold:
  212.       - value: 1
  213.         color: "#00ff00"
  214.       - value: 1.5
  215.         color: "#66ff66"
  216.       - value: 2
  217.         color: "#99ff66"
  218.       - value: 2.5
  219.         color: "#ccff66"
  220.       - value: 3
  221.         color: "#ccff33"
  222.       - value: 4
  223.         color: "#ffff00"
  224.       - value: 5
  225.         color: "#ffcc00"
  226.       - value: 6
  227.         color: "#ff9933"
  228.       - value: 7
  229.         color: "#ff6600"
  230.       - value: 9
  231.         color: "#ff0000"
  232.       - value: 11
  233.         color: "#cc0000"
  234.       - value: 15
  235.         color: "#a60000"
  236.       - value: 19
  237.         color: "#700c0c"
  238.       - value: 26
  239.         color: "#360f0f"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement