Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax-m1· MiniMaxHugging Face LMArena Human Preference 140K

Mam problem z wykresem w Home Assistant. To kod karty: [code] Sensory są i mają…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Metallama-3.3-70b-instruct’s answer.
  1. User

    Mam problem z wykresem w Home Assistant. To kod karty:

    type: custom:layout-card
    layout_type: custom:grid-layout
    cards:
      - type: custom:config-template-card
        entities:
          - input_datetime.date_picker
        variables:
          offset: |
            {{states['sensor.apex_days'].state}}
        card:
          type: custom:apexcharts-card
          apex_config:
            chart:
              height: 250
              stacked: true
            plotOptions:
              columnWidth: 90%
              borderRadiusApplication: end
            fill:
              type: gradient
              gradient:
                type: horizontal
                shadeIntensity: 0.4
                opacityTo: 0.95
                inverseColors: false
          experimental:
            color_threshold: true
          graph_span: 1d
          span:
            start: day
            offset: ${offset}
          update_interval: 1h
          header:
            show: true
            title: Godzinowy bilans energii
            standard_format: false
            show_states: false
            colorize_states: true
          series:
            - entity: sensor.pv_godzinowo
              name: Produkcja PV
              opacity: 90
              type: column
              statistics:
                align: start
                type: state
              fill_raw: last
              float_precision: 2
              yaxis_id: export
              group_by:
                func: last
                duration: 1h
              stroke_width: 0.1
              show:
                datalabels: false
                header_color_threshold: false
                legend_value: false
              color: orange
            - entity: sensor.sprzedaz_godzinowa
              name: Export energii
              transform: return x *-1
              opacity: 90
              type: column
              fill_raw: last
              float_precision: 2
              yaxis_id: export
              group_by:
                func: last
                duration: 1h
              stroke_width: 0.1
              show:
                datalabels: false
                header_color_threshold: false
                legend_value: false
              color: darkorchid
            - entity: sensor.zakup_godzinowy
              name: Import energii
              opacity: 90
              type: column
              fill_raw: last
              float_precision: 2
              group_by:
                func: max
                duration: 1h
              stroke_width: 0.1
              show:
                datalabels: false
                header_color_threshold: false
                legend_value: false
              color: dodgerblue
      - type: vertical-stack
        cards:
          - type: entities
            entities:
              - input_datetime.date_picker
          - type: custom:config-template-card
            entities:
              - input_datetime.date_picker
            variables:
              offset: |
                {{states['sensor.apex_days'].state}}
            card:
              type: custom:apexcharts-card
              chart_type: pie
              graph_span: 1.1d
              update_interval: 1h
              span:
                offset: ${offset}
                end: day
              apex_config:
                chart:
                  height: 300px
                legend:
                  show: true
                  position: right
                  fontSize: 18px
                dataLabels:
                  style:
                    fontSize: 12px
              header:
                show: true
                title: Bilans energii
                show_states: false
                colorize_states: true
              series:
                - entity: sensor.dzienny_pobor
                  name: Import
                  unit: " kWh"
                  statistics:
                    period: day
                    align: start
                    type: state
                  group_by:
                    func: max
                    duration: 1d
                  float_precision: 2
                  show:
                    datalabels: true
                    extremas: false
                    header_color_threshold: false
                    legend_value: true
                    in_chart: true
                  color: dodgerblue
                - entity: sensor.sprzedaz_dzienna
                  unit: " kWh"
                  name: Export
                  transform: return x *1
                  opacity: 90
                  fill_raw: last
                  float_precision: 2
                  group_by:
                    func: last
                    duration: 1d
                  show:
                    datalabels: true
                    header_color_threshold: false
                    legend_value: true
                    in_chart: true
                  color: darkorchid
                - entity: sensor.deye_inverter_daily_pv_production
                  name: Produkcja
                  unit: " kWh"
                  transform: return x *1
                  opacity: 90
                  fill_raw: last
                  float_precision: 2
                  group_by:
                    func: last
                    duration: 1d
                  show:
                    datalabels: true
                    header_color_threshold: false
                    legend_value: true
                    in_chart: true
                  color: orange
    layout:
      grid-template-columns: 75% 25%
    

    Sensory są i mają statystyki. Dodatki zainstalowane. Problem chyba jest w sensorach z pomocnika date_picker i sensor.apex_days. Pomocnika stworzyłem i datę wyświetla. Do sensor.apex_days użyłem wpisu w configuration.yaml:

      - platform: template
        sensors:
          apex_days:
            friendly_name: "Dni do wykresów"
            icon_template: mdi:data
            value_template: >        
              {% if state_attr('input_datetime.date_picker', "timestamp")==as_timestamp(states('sensor.date')) %}
                -0d
              {% else %}
                {{ ((as_timestamp(states('sensor.date'))|float(0) - state_attr('input_datetime.date_picker', "timestamp")|float(0)))/ -86400 }}d
              {% endif %}
    

    i tu coś chyba nie działa bo w Statystykach w Narzędziach deweloperskich go nie znajduje.

  2. MiniMax Assistant

    Aby rozwiązać problem z sensorem sensor.apex_days, wykonaj następujące kroki:

    1. Sprawdź poprawność definicji sensora

    Upewnij się, że sekcja w configuration.yaml jest poprawnie sformatowana i umieszczona w odpowiedniej sekcji sensor::

    sensor:
      - platform: template
        sensors:
          apex_days:
            friendly_name: "Dni do wykresów"
            value_template: >-
              {% set date_picker_ts = state_attr('input_datetime.date_picker', 'timestamp') %}
              {% set current_ts = as_timestamp(now()) %}  # Zastąpiono sensor.date na aktualny czas
              {% if date_picker_ts == current_ts %}
                -0d
              {% else %}
                {{ ((current_ts - date_picker_ts) / 86400) | round(0) }}d  # Usunięto znak minus w dzieleniu
              {% endif %}
    

    Uwagi:

    • Usunięto sensor.date: Zakładając, że sensor.date nie istnieje, użyto now() do uzyskania aktualnej daty.
    • Poprawiono formułę: Zmieniono znak w dzieleniu na +86400, aby wartość była dodatnia przy przeszłej dacie.

    2. Sprawdź logi Home Assistant

    Po wprowadzeniu zmian, zrestartuj Home Assistant i sprawdź logi (sekcja Configuration > Logs) pod kątem błędów związanych z sensorem apex_days.

    3. Weryfikuj stan sensora

    Przejdź do Developer Tools > States i wyszukaj sensor.apex_days. Sprawdź, czy pojawia się i czy zwraca wartość np. 2d lub -0d.

    4. Przykładowe wartości

    • Jeśli date_picker jest dzisiaj: sensor.apex_days zwróci -0d.
    • Jeśli date_picker jest 2 dni w przeszłości: sensor.apex_days zwróci 2d.

    5. Dostosuj offset w karcie

    Upewnij się, że w konfiguracji karty apexcharts-card parametr span.offset korzysta z ${offset}, co powinno dynamicznie podstawiać wartość z sensora.

    6. Ostateczna poprawka kodu YAML

    Zaktualizuj sekcję sensor.apex_days w configuration.yaml na powyższy kod i zrestartuj system. To powinno rozwiązać problem z niewidocznym sensorem.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.