Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-4-20250514· AnthropicHugging Face LMArena Human Preference 140K

I am using esphome for sensor. I have the following sensor value "Leistung" in my .yaml.…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.0-flash-001’s answer.
  1. User

    I am using esphome for sensor. I have the following sensor value "Leistung" in my .yaml. I now want to to have another sensor based on that "Leistung" which sends out the two minute rolling average of "Leistung" every 30 seconds.

    • platform: sml name: "Leistung" sml_id: mysml obis_code: "1-0:16.7.0" unit_of_measurement: W accuracy_decimals: 0 device_class: power state_class: measurement filters:
      • throttle_average: 30s
  2. Claude Assistant

    You can create a rolling average sensor in ESPHome using a template sensor with a sliding window filter. Here's how to add it to your configuration:

    sensor:
      - platform: sml
        name: "Leistung"
        sml_id: mysml
        obis_code: "1-0:16.7.0"
        unit_of_measurement: W
        accuracy_decimals: 0
        device_class: power
        state_class: measurement
        filters:
          - throttle_average: 30s
    
      - platform: template
        name: "Leistung 2min Rolling Average"
        id: leistung_rolling_avg
        unit_of_measurement: W
        accuracy_decimals: 0
        device_class: power
        state_class: measurement
        lambda: |-
          return id(leistung).state;
        update_interval: 30s
        filters:
          - sliding_window_moving_average:
              window_size: 4
              send_every: 1
    

    The key points here:

    • The template sensor reads from your original "Leistung" sensor using id(leistung).state
    • update_interval: 30s makes it update every 30 seconds
    • sliding_window_moving_average with window_size: 4 creates a 2-minute rolling average (4 samples × 30 seconds = 120 seconds)
    • send_every: 1 ensures it sends the average every time it updates

    Make sure to add an id: leistung to your original sensor so the template can reference it:

      - platform: sml
        name: "Leistung"
        id: leistung  # Add this line
        sml_id: mysml
        # ... rest of your configuration
    

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