Display gaps in history graph

Hi guys, I am going crazy…

My HA:

  • core 2025.3.3
  • frontend 20250306.0

I need to collect data from modbus device using custom stuct, I am still working about this.
Then I need to extract data and display values on graph.

I am still working on modbus, so it could be I read “register1” and not “register2”.

I extract “Solar panel voltage” from “register1” and I want show values on history graph displayed in “Volt”, let’s say I extract “Battery voltage” from register2.
If something wrong I wanna see gap in graph.

  1. Chatgpt and Deepseek tell me “version 2025.3.3 doesn’t exixt, so you are using 2023 version”
  2. if modbus device offline I correctly see no displayed values on graph
  3. if available only “Solar panel voltage” I still see displayed on graph last of “Battery voltage” such if I’ve just correctly read register2, even if register2 hasn’t been read.
  4. due I need “unit of measurement” my HA tells me I need to supply numeric value, but every solution I use I still see displayed values and AI can’t help me about this.

This is example code:


      epever_load_power_pa05:
        friendly_name: "Epever panel power PA05"
        unit_of_measurement: "W"
        value_template: >-
          {#                                          versione per la gestione dei valori numerici in caso di lettura assente #}
          {% set raw_value = states('sensor.epv_block5_pa05') | lower %}
          {% set position = 3 %}
          {% set scale = 0.01 %}
          {% set endianness = "LE" %}                                       {# Epever lavora in Big Endian, Alfa in Little Endian #}
          {% set dimension = 2 %}                                           {# numero di registri a 16 bit che compongono la variabile #}
          {% if raw_value not in ['unavailable', 'unknown', '', ' '] %}
            {% set parts = raw_value.split(',') %}
            {% if parts | length >= (position+1) %}
              {# qui ho un numero sufficiente di elementi, adesso devo andare a comporli #}  
              {% if (parts[position - 1] | regex_match('^\d+$')) and (parts[position] | regex_match('^\d+$')) %}
                {# ho tutti gli elementi numerici #}
                  {% if endianness in ['BE', 'LE'] %}
                    {% if endianness == 'BE' %}
                      {% set msb = parts[position - 1] | int %}     {# Primo registro (LSB) #}
                      {% set lsb = parts[position] | int %}         {# Secondo registro (MSB) #}
                    {% elif endianness == 'LE' %}
                      {% set lsb = parts[position - 1] | int %}     {# Primo registro (LSB) #}
                      {% set msb = parts[position] | int %}         {# Secondo registro (MSB) #}
                    {% endif %}
                    {% set target_value = (msb * 65536) + lsb %}
                    {# a questo punto io potrei anche lavorare con int32 invece di un uint32, quindi vado a verificare se sia negativo  #}
                    {% if target_value > 0x80000000 %}
                      {% set target_value = target_value - 0x100000000 %}  {# Applica la conversione a numero signed in complemento a 2 #}
                    {% endif %}
                    {% set numeric_value = (target_value | int) * scale %} {# lo converto in float #}
                    {% set rounded_value = numeric_value | round(1, 'half_even') %}           {# Arrotondamento al decimo più vicino "arrotondamento bancario" #}
                      {{ rounded_value}}
                  {% else %}
                    states('sensor.epv_block5_pa05')
                  {% endif %}
              {% else %}
                states('sensor.epv_block5_pa05')
              {% endif %}          
            {% else %}
              states('sensor.epv_block5_pa05')
            {% endif %}
          {% else %}
            states('sensor.epv_block5_pa05')
          {% endif %}