How to combine multiple sensors into one new sensor for graphing?

I have a sensor for each upcoming day, with the kWh forecast of solar production.
I’d like to show all days in a bar graph. Therefore all forecast sensors need to be combined into one, so apex charts (or others) can plot it.
Is there a way to combine multiple sensors into one? I would be fine with attributes, too, as there is a way with data_generator to extract them in apex charts.

My source sensors:

I tried to build something what I am looking for, by grouping each sensor at 24h rate. This gives me funky bars with lots of 0-bars in between:

grafik

The final result should look more like these blue bars:
grafik

Take a look at this topic, that came up 15 minutes before you posted. Was just coincidence, that I read your post first… :laughing:

Thanks for the link, but the topic wants to sum multiple sensors into one to get a total. Today that’s easy to do with sum helpers.

My question is on how to append multiple sensors into one in a timely manner. A form of concatenate, as each of the example sensors is for a different day.

I’m sorry, but then I don’t get what you want. :slight_smile:

You have the sensors shown in your screenshot above. How do you want these to be concatenated?

So you want it like your first graph but with thicker columns?

After realising, you’re speaking German, I kind of getting an idea what you want to do. :slight_smile:

I’d try it with a template sensor and set the days in the attributes. Is that what you need? Like in this example of a sensor:

template:
  - sensor:
      - name: solcast_something
        unit_of_measurement: "W"
        state: "{{ states('sensor.aktuelle_leistung') }}"
        attributes:
          prognose_day_1: "{{ states('sensor.prognose_day_1') }}" # heute
          prognose_day_2: "{{ states('sensor.prognose_day_2') }}" # morgen
          prognose_day_3: "{{ states('sensor.prognose_day_3') }}" # Tag 3
          [...] # und so weiter

This gives you one sensor, “solcast_something” with “Aktuelle Leistung” as state, and the upcoming days are listed as attributes from day_1 to day_x.

I hope this is at least the right direction. :slight_smile:

Let us know, if this fits your needs! :slight_smile:

yeai that’s it! :smile:

Maybe for better understandig of my initial post, I graphed my usecase with some ascii art:


sensor_forecast_day1: 11kWh  -----------+ 
                                        |
sensor_forecast_day2: 12kWh  -----------+---> sensor_combined_forecast
                                        |          - shows value of day 1 at timepoint now()+1day: 11kWh
sensor_forecast_day3: 13kWh  -----------+          - shows value of day 2 at timepoint now()+2day: 12kWh
                                                   - shows value of day 3 at timepoint now()+2day: 13kWh
                                            
                                            
graphed as timeline:
        11      12      13        kWh
 +-------+-------+-------+----...-->
now     day1    day2    day3

For my data, here is the complete solution I got so far:

template:
  - sensor:
      - name: "solar_forecast_timeline"
        state: "{{ states('sensor.solcast_pv_forecast_prognose_heute') }}"
        unit_of_measurement: "kWh"
        device_class: energy
        attributes:
            day_1: "{{ states('sensor.solcast_pv_forecast_prognose_morgen') }}"
            day_2: "{{ states('sensor.solcast_pv_forecast_prognose_tag_3') }}"
            day_3: "{{ states('sensor.solcast_pv_forecast_prognose_tag_4') }}"
            day_4: "{{ states('sensor.solcast_pv_forecast_prognose_tag_5') }}"
            day_5: "{{ states('sensor.solcast_pv_forecast_prognose_tag_6') }}"
            day_6: "{{ states('sensor.solcast_pv_forecast_prognose_tag_7') }}"

and the apexcharts series:

series:
  - entity: sensor.solar_forecast_timeline
    name: PV
    yaxis_id: kwh
    type: column
    color: '#FFBF00'
    show:
      datalabels: true
    data_generator: |
      return [
          [moment().add(1, 'days'), entity.attributes.day_1],
          [moment().add(2, 'days'), entity.attributes.day_2],
          [moment().add(3, 'days'), entity.attributes.day_3],
          [moment().add(4, 'days'), entity.attributes.day_4],
          [moment().add(5, 'days'), entity.attributes.day_5],
          [moment().add(6, 'days'), entity.attributes.day_6]
        ]

gives me this chart:

grafik

(blue: rain, gold: solcast, red and green: temps )

It screams to be treated as an array and loops, but I couldn’t figure it out :frowning:
Tried to adapt from

and

interesting, but is there a way to scale this up from 7 days to e.g. 2 years?

I’m trying to keep health records, e.g. weight, blood pressure etc

and sometimes, values like blood pressure requires several values taken together, systolic, diastolic and pulse