IOT 센서의 리포팅 주기(MQTT publish topic)가 잦으면 다른 장치의 트래픽을 방해하거나 자동화가 불필요하게 많이 실행될 수 있습니다.
알리에서 구매한 이산화탄소 센서 (TS0601) 리포팅 주기 0.5초여서 리포팅 주기를 변경한 방법을 공유하고자 합니다.
외부 컨버터 사용
리포팅 주기를 변경할 수 있는 장치도 있지만 펌웨어에서 하드코딩된 부분이라 설정을 직접 변경할 수 없는 장치도 있습니다.
이런 경우에는 외부 컨버터를 사용합니다.
external_converters 폴더를 생성하여 TS0601_CO2.js 파일을 업로드 합니다.
(/homeassistant/zigbee2mqtt/external_converters/TS0601_CO2.js)
TS0601_CO2.js
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const legacy = require('zigbee-herdsman-converters/lib/legacy');
const e = exposes.presets;
const STARTUP_DELAY = 1.0; // Delay before first report in seconds
const PUBLISH_DELAY = 30.0; // Delay between each data publish in seconds
const legacy_tuya_with_delay = {
cluster: 'manuSpecificTuya',
type: ['commandDataReport', 'commandDataResponse'],
convert: (model, msg, publish, options, meta) => {
const now = Date.now();
if (!meta.device.private_cache) {
meta.device.private_cache = {};
meta.device.private_next_update = now + STARTUP_DELAY * 1000;
}
const changes = legacy.fromZigbee.tuya_air_quality.convert(model, msg, publish, options, meta);
Object.assign(meta.device.private_cache, changes);
if (now >= meta.device.private_next_update) {
const result = { ...meta.device.private_cache };
meta.device.private_next_update = now + PUBLISH_DELAY * 1000; // Schedule next publish
meta.device.private_cache = {}; // Clear cache after publishing
return result;
} else {
return {}; // Do not publish if delay has not passed
}
}
};
const definition = {
fingerprint: tuya.fingerprint('TS0601', ['_TZE204_ogkdpgy2']),
model: 'TS0601_co2_sensor',
vendor: 'Tuya',
description: 'NDIR CO2 sensor with delayed reporting',
fromZigbee: [legacy_tuya_with_delay],
toZigbee: [],
exposes: [e.co2()],
};
module.exports = definition;
지그비 제조사에 적힌 내용을 위의 코드에 변경하면 됩니다.
리포팅 주기는 입맛대로 설정하시면 됩니다.
zigbee2mqtt 에드온을 재시작하면 리포팅 주기가 30초로 변경되어 과도하게 보고하는 것을 막을 수 있습니다.
출처: https://community.home-assistant.io/t/carbon-monoxide-detector-is-very-chatty-tuya-ts0601/729267/5
Carbon Monoxide detector is very "chatty" - Tuya TS0601
I have 2 CO2 sensors doing the same. I’ve adapted a code that can be loaded in “external_convertors” in Zigbee2MQTT that fixes reporting issue in Z2M. Feel free to check it out. There are instructions and how to adapt the reporting interval based on
community.home-assistant.io
'스마트홈 IoT 월드 > 스마트홈 설정 문제해결 팁' 카테고리의 다른 글
홈어시스턴트 go2rtc 카메라 홈킷(homekit) 연동 방법 (0) | 2025.07.11 |
---|---|
홈어시스턴트(Home Assistant) 매터브릿지(MatterBridge) 에드온 사용해서 구글홈(Google Home)에 장치 연동하기 (0) | 2025.07.11 |
스마트홈 IR 리모컨 허브의 치명적 단점들, 알고 계셨나요? (0) | 2025.07.09 |
Zigbee2MQTT 설치 및 사용 가이드: Home Assistant와 스마트홈 자동화의 핵심 시작하기 (0) | 2025.07.08 |
처음부터 끝까지 정리! 홈어시스턴트 외부 접속 및 DDNS 설정 방법 (0) | 2025.07.08 |