HOBEIAN ZG-IR01: HA infrared receiver template fails ("LoggingUndefined is not JSON serializable") when learned_ir_timings is absent from payload

Open Beginner friendly
#33,565 4 comments 4 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript

Research direction

The payload does not name the source file, so start by searching the repository for where the infrared learned_ir_timings receiver's Home Assistant discovery value_template is built. The fix is to guard the template so it renders nothing when value_json.learned_ir_timings is undefined, as the issue suggests. Done means the generated template contains that guard and no longer logs a TypeError for state messages that lack the key.

Written by the indexing model from the issue text.

Description

problem
What happened?

Since the Home Assistant infrared discovery was added (2.13.0), the infrared._learned_ir_timings receiver entity generated for my HOBEIAN ZG-IR01 logs a warning in Home Assistant for every state message the device publishes.

The discovered value_template is:

{{ value_json.learned_ir_timings | tojson }}

learned_ir_timings is only present in the payload right after an IR code has been learned. Regular state reports (temperature, humidity, battery, switch states) do not contain this key. value_json.learned_ir_timings then evaluates to Undefined, and tojson raises a TypeError.

This device reports temperature/humidity often, and usually in bursts of ~4 identical messages ~200 ms apart. As a result, the HA log gets flooded: about 200 warnings in ~3.5 hours on my system.

Learning and sending IR codes via Z2M work fine. The problem is only the log spam from the HA receiver entity. Disabling the entity in HA stops the warnings.

What did you expect to happen?

The receiver template should handle the missing key without raising an error. For example:

{% if value_json.learned_ir_timings is defined %}{{ value_json.learned_ir_timings | tojson }}{% endif %}

or an equivalent guard, so state messages without learned_ir_timings are ignored by the infrared receiver entity.

How to reproduce it (minimal and precise)
  1. Pair a HOBEIAN ZG-IR01 with Home Assistant integration (MQTT discovery) enabled.
  2. Leave the auto-created infrared.*_learned_ir_timings entity enabled.
  3. Wait for any regular state report (temperature/humidity/battery).
  4. Check the HA log: a warning appears for every message.
Zigbee2MQTT version

2.14.3 (zigbee-herdsman-converters 26.125.0, zigbee-herdsman 11.2.0, frontend windfront 2.15.1)

Adapter firmware version

EmberZNet 7.4.4 [GA]

Adapter

SONOFF Zigbee 3.0 USB Dongle Plus | ZBDongle-E - EmberZNet

Setup

Home Assistant OS add-on (HAOS kernel 6.18.58-haos, x64), Mosquitto add-on, Node v24.22.1. Home Assistant Core 2026.10.4.

Device database.db entry

No response

Debug log

2026-11-01 13:05:19.559 WARNING (MainThread) [homeassistant.components.mqtt.entity] TypeError: Object of type LoggingUndefined is not JSON serializable rendering template for entity 'infrared.ir_remote_learned_ir_timings', template: '{{ value_json.learned_ir_timings | tojson }}' and payload: {"battery":30,"humidity":52,"humidity_calibration":0,"last_seen":"2026-11-01T11:05:19.555Z","linkquality":200,"switch1":"ON","switch1_off":"registered","switch1_on":"registered","switch2":"OFF","switch2_off":"registered","switch2_on":"registered","switch3":"OFF","switch3_off":"registered","switch3_on":"registered","switch4":"OFF","switch4_off":"unregistered","switch4_on":"unregistered","switch5":"OFF","switch5_off":"unregistered","switch5_on":"unregistered","switch6":"OFF","switch6_off":"unregistered","switch6_on":"unregistered","temperature":23,"temperature_calibration":0,"temperature_unit":"celsius","voltage":2600}
2026-11-01 13:05:19.758 WARNING (MainThread) [homeassistant.components.mqtt.entity] TypeError: Object of type LoggingUndefined is not JSON serializable rendering template for entity 'infrared.ir_remote_learned_ir_timings', template: '{{ value_json.learned_ir_timings | tojson }}' and payload: {"battery":30,"humidity":52,...,"temperature":23,"temperature_unit":"celsius","voltage":2600}
2026-11-01 13:05:19.959 WARNING (MainThread) [homeassistant.components.mqtt.entity] TypeError: Object of type LoggingUndefined is not JSON serializable rendering template for entity 'infrared.ir_remote_learned_ir_timings', template: '{{ value_json.learned_ir_timings | tojson }}' and payload: {"battery":30,"humidity":52,...,"temperature":23,"temperature_unit":"celsius","voltage":2600}

Notes

(Same warning repeats for every state message; none of the payloads contain learned_ir_timings.)

Dominant language
TypeScript
Stars
15.8k
Forks
2.2k
Avg merge
1d 16h
Merged PRs (30d)
47

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Koenkk/zigbee2mqtt

All issues in Koenkk/zigbee2mqtt

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.