Better test for bulbtype

This commit is contained in:
Stephan Hadinger 2020-03-23 08:25:01 +01:00
parent 4749222d95
commit f9d6ab1825
2 changed files with 3 additions and 2 deletions

View File

@ -1007,7 +1007,7 @@ String Z_Devices::dump(uint32_t dump_mode, uint16_t status_shortaddr) const {
if (device.modelId) { if (device.modelId) {
dev[F(D_JSON_MODEL D_JSON_ID)] = device.modelId; dev[F(D_JSON_MODEL D_JSON_ID)] = device.modelId;
} }
if (-1 != device.bulbtype) { if (device.bulbtype >= 0) {
dev[F(D_JSON_ZIGBEE_LIGHT)] = device.bulbtype; // sign extend, 0xFF changed as -1 dev[F(D_JSON_ZIGBEE_LIGHT)] = device.bulbtype; // sign extend, 0xFF changed as -1
} }
if (device.manufacturerId) { if (device.manufacturerId) {

View File

@ -757,6 +757,7 @@ void CmndZbLight(void) {
if (p) { if (p) {
int8_t bulbtype = strtol(p, nullptr, 10); int8_t bulbtype = strtol(p, nullptr, 10);
if (bulbtype > 5) { bulbtype = 5; } if (bulbtype > 5) { bulbtype = 5; }
if (bulbtype < -1) { bulbtype = -1; }
zigbee_devices.setHueBulbtype(shortaddr, bulbtype); zigbee_devices.setHueBulbtype(shortaddr, bulbtype);
} }
String dump = zigbee_devices.dumpLightState(shortaddr); String dump = zigbee_devices.dumpLightState(shortaddr);