PimDoos / ha-sessy-examples

Example automations for using Sessy with Home Assistant
6 stars 3 forks source link

today and tomorrow in one graphic #8

Open Tazzios opened 4 months ago

Tazzios commented 4 months ago

My attempt to get today and tomorrow in one graphic. Unfortunately, the lines stops at the end of the day. Maybe someone else has an idea how to make it?

type: custom:apexcharts-card
header:
  show: true
  title: Today
  show_states: true
  colorize_states: true
now:
  show: true
graph_span: 2d
span:
  start: day 
yaxis:
  - id: power
    decimals: 0
    opposite: true
  - id: price
    decimals: 2
series:
  - entity: sensor.sessy_deem_power_schedule
    yaxis_id: power
    name: Power Schedule
    curve: stepline
    data_generator: |
      let hours = [];
      for(var i = 0; i < 48; i++){ hours.push(i); }
      let date = new Date().getTime() ;
      let dateindex = new Date(date).toISOString().split("T")[0];
      return hours.map((hour, index) => {
        let date = new Date(dateindex).setHours(hour,0,0);
        return [date, entity.attributes[dateindex][index]];
      });
  - entity: sensor.sessy_deem_energy_price
    yaxis_id: price
    name: Energy Price
    curve: stepline
    float_precision: 5
    data_generator: |
      let hours = [];
      for(var i = 0; i < 48; i++){ hours.push(i); }
      let date = new Date().getTime() ;
      let dateindex = new Date(date).toISOString().split("T")[0];
      return hours.map((hour, index) => {
        let date = new Date(dateindex).setHours(hour,0,0);
        return [date, entity.attributes[dateindex][index]];
      });
Tazzios commented 4 months ago

further attempt. some hacking and hidding with 4 datasources.

TODO:

afbeelding

type: custom:apexcharts-card
header:
  show: true
  title: Sessy
  show_states: false
  colorize_states: true
now:
  show: true
graph_span: 2d
span:
  start: day
color_list:
  - orange
  - blue
  - orange
  - blue
apex_config:
  legend:
    show: false
yaxis:
  - id: power
    decimals: 0
    opposite: true
  - id: price
    decimals: 2
series:
  - entity: sensor.sessy_deem_power_schedule
    yaxis_id: power
    name: Power Schedule
    type: column
    curve: stepline
    data_generator: |
      let hours = [];
      for(var i = 0; i < 48; i++){ hours.push(i); }
      let date = new Date().getTime() ;
      let dateindex = new Date(date).toISOString().split("T")[0];
      return hours.map((hour, index) => {
        let date = new Date(dateindex).setHours(hour,0,0);
        return [date, entity.attributes[dateindex][index]];
      });
  - entity: sensor.sessy_deem_energy_price
    yaxis_id: price
    name: Energy Price
    curve: stepline
    float_precision: 5
    data_generator: |
      let hours = [];
      for(var i = 0; i < 48; i++){ hours.push(i); }
      let date = new Date().getTime() ;
      let dateindex = new Date(date).toISOString().split("T")[0];
      return hours.map((hour, index) => {
        let date = new Date(dateindex).setHours(hour,0,0);
        return [date, entity.attributes[dateindex][index]];
      });
  - entity: sensor.sessy_deem_power_schedule
    yaxis_id: power
    name: Power Schedule
    type: column
    curve: stepline
    data_generator: |
      let hours = [];
      for(var i = 0; i < 24; i++){ hours.push(i); }
      let date = new Date().getTime() + 86400000;
      let dateindex = new Date(date).toISOString().split("T")[0];
      return hours.map((hour, index) => {
        let date = new Date(dateindex).setHours(hour,0,0);
        return [date, entity.attributes[dateindex][index]];
      });
  - entity: sensor.sessy_deem_energy_price
    yaxis_id: price
    name: Energy Price
    curve: stepline
    float_precision: 5
    data_generator: |
      let hours = [];
      for(var i = 0; i < 24; i++){ hours.push(i); }
      let date = new Date().getTime() + 86400000;
      let dateindex = new Date(date).toISOString().split("T")[0];
      return hours.map((hour, index) => {
        let date = new Date(dateindex).setHours(hour,0,0);
        return [date, entity.attributes[dateindex][index]];
      });
PimDoos commented 3 months ago

Feel free to branch & PR for this change

Tazzios commented 3 months ago

I don't think it is ready for PR Because of mentioned todo's and following things: