Advertisement
dykandDK

HA - YAML - Apex chart with hourly energy price and consumption

Jan 1st, 2025
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.78 KB | None | 0 0
  1. type: custom:apexcharts-card
  2. apex_config:
  3.   xaxis:
  4.     type: datetime
  5.     tickAmount: 24
  6.     tickPlacement: between
  7.     labels:
  8.       format: HH
  9.       hideOverlappingLabels: false
  10.       rotate: -90
  11.       rotateAlways: true
  12.       showDuplicates: true
  13.       style:
  14.         fontFamily: Courier New
  15.         fontWeight: 545
  16.         fontSize: 12px
  17.     axisBorder:
  18.       show: true
  19.       color: grey
  20.     tooltip:
  21.       enabled: false
  22.   plotOptions:
  23.     bar:
  24.       dataLabels:
  25.         offsetY: -10
  26.         position: bottom
  27.         maxItems: 32
  28.         hideOverflowingLabels: true
  29.         orientation: vertical
  30.       columnWidth: 90%
  31.   chart:
  32.     type: bar
  33.     height: 350px
  34.     stacked: false
  35.     distributed: false
  36.   dataLabels:
  37.     enabled: true
  38.     style:
  39.       colors:
  40.        - "#fcfcfc"
  41.       fontSize: 10px
  42.     distributed: true
  43.     offsetY: 3
  44.     formatter: |
  45.      EVAL:function(value) {
  46.         return Math.abs(value.toFixed(2));
  47.       }  
  48.   tooltip:
  49.     x:
  50.       format: HH
  51.     "y":
  52.       formatter: |
  53.        EVAL:function(value) {
  54.           return Math.abs(value.toFixed(2));
  55.         }  
  56. experimental:
  57.   color_threshold: true
  58. now:
  59.   show: true
  60.   label: Nu
  61. graph_span: 23h
  62. span:
  63.   start: day
  64. yaxis:
  65.   - id: kwh
  66.     decimals: 1
  67.     opposite: true
  68.     apex_config:
  69.       axisBorder:
  70.         show: true
  71.         color: grey
  72.       tickAmount: 5
  73.       reversed: false
  74.       title:
  75.         text: Forbrug i kWh
  76.       labels:
  77.         show: true
  78.   - id: kr
  79.     min: 0
  80.     max: 5
  81.     decimals: 1
  82.     apex_config:
  83.       axisBorder:
  84.         show: true
  85.         color: grey
  86.       tickAmount: 5
  87.       reversed: false
  88.       title:
  89.         text: Pris i kr. / kWh
  90.       labels:
  91.         show: true
  92. show:
  93.   last_updated: false
  94. header:
  95.   show: true
  96.   title: Elpriser og forbrug pr. time
  97.   standard_format: true
  98. series:
  99.   - entity: sensor.energi_data_service
  100.     type: column
  101.     name: Pris
  102.     yaxis_id: kr
  103.     data_generator: |
  104.      var today = entity.attributes.raw_today.map((start, index) => {
  105.         return [new Date(start["hour"]).getTime(), entity.attributes.raw_today[index]["price"]];
  106.       });
  107.       return today;
  108.     float_precision: 2
  109.     color_threshold:
  110.       - value: 0
  111.         color: green
  112.       - value: 2
  113.         color: orange
  114.       - value: 3.5
  115.         color: red
  116.       - value: 5
  117.         color: darkred
  118.     extend_to: now
  119.     show:
  120.       extremas: false
  121.       datalabels: true
  122.       in_legend: false
  123.   - entity: sensor.kamstrup_total_import_filter
  124.     name: Forbrug
  125.     type: area
  126.     unit: kWh
  127.     float_precision: 2
  128.     stroke_width: 4
  129.     yaxis_id: kwh
  130.     color: 2980b9
  131.     group_by:
  132.       func: diff
  133.       duration: 1hour
  134.     extend_to: now
  135.     show:
  136.       datalabels: false
  137.       in_legend: false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement