Skip to content

Template warning: history_event_list_1_datetime missing from state_all payload when aggregate has no data #52

Description

@linky67

Hello,

I'm running the Docker image and using Home Assistant 2026.8.1. Home Assistant repeatedly logs the following warning:

Logger: homeassistant.helpers.template
Source: helpers/template/__init__.py:685
Template variable warning: 'dict object' has no attribute 'history_event_list_1_datetime' when rendering '{{ value_json.history_event_list_1_datetime }}'

This occurred 400 times over ~26 minutes, so it's firing on (or near) every MQTT publish cycle.

Cause (as far as I can tell from SOFAR-HYD-3PH-AND-G3.json):

history_event_list_1 is a "normal" register (read directly at 0x1480), but history_event_list_1_datetime has no register field — it's computed via aggregate_datetime_bitmap from three separate registers (year_month 0x1481, day_hour 0x1482, minute_second 0x1483):

{
  "name": "history_event_list_1_datetime",
  "aggregate_datetime_bitmap": {
    "year_month": "0x1481",
    "day_hour": "0x1482",
    "minute_second": "0x1483"
  },
  "ha": {
    "name": "History Event List 1 - DateTime",
    "value_template": "{{ value_json.history_event_list_1_datetime }}"
  }
}

It looks like this computed key isn't always included in the sofar/state_all JSON payload — possibly only when the aggregation produces a non-empty/valid result. Since the HA auto-discovery config points value_template directly at value_json.history_event_list_1_datetime with no fallback, HA logs a warning every time the key is absent from the payload.

Suggested fix:

Either:

  1. Always include history_event_list_1_datetime in state_all (e.g. null/empty string when the aggregate has no valid data yet), so the key is consistently present, or
  2. Add a default to the generated value_template, e.g. {{ value_json.history_event_list_1_datetime | default('') }}, so HA doesn't warn when the key is briefly absent.

Happy to test a fix if useful — thanks for the great project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions