HOBEIAN ZG-IR01: HA infrared receiver template fails ("LoggingUndefined is not JSON serializable") when learned_ir_timings is absent from payload
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
- Domain
- backend, embedded-iot
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
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)
- Pair a HOBEIAN ZG-IR01 with Home Assistant integration (MQTT discovery) enabled.
- Leave the auto-created infrared.*_learned_ir_timings entity enabled.
- Wait for any regular state report (temperature/humidity/battery).
- 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
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Koenkk/zigbee2mqtt
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Koenkk/zigbee2mqtt#33613 · 1 comment ·
Maintainers usually reply within 1 day
-
problem
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Koenkk/zigbee2mqtt#33611 ·
Maintainers usually reply within 1 day
-
problem
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Koenkk/zigbee2mqtt#33596 ·
Maintainers usually reply within 1 day
-
problem
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Koenkk/zigbee2mqtt#33592 ·
Maintainers usually reply within 1 day
-
new device support
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Koenkk/zigbee2mqtt#33577 · 1 comment ·
Maintainers usually reply within 1 day
All issues in Koenkk/zigbee2mqtt
Similar issues
-
bug needs-triage potential-regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
aws/aws-sdk-js-v3#8408 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
colinhacks/zod#6743 ·
Maintainers usually reply within 1 day
-
[BUG] Packing list: the weight field drops digits on a slow connection and saves the wrong weightOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
openai/openai-node#3124 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
anthropics/anthropic-sdk-typescript#1296 ·
Maintainers usually reply within 8 days