Also use state converter when value is open, close, stop, lock and unlock. #4123

This commit is contained in:
Koen Kanters committed 2020-08-18 21:27:36 +02:00
1 parent b7409295b5
commit a20c6728b8
1 file changed
+2 -1
+2 -1
View File
@@ -8,6 +8,7 @@ const Extension = require('./extension');
const stringify = require('json-stable-stringify');
const topicRegex = new RegExp(`^(.+?)(?:/(${utils.getEndpointNames().join('|')}))?/(get|set)(?:/(.+))?`);
const stateValues = ['on', 'off', 'toggle', 'open', 'close', 'stop', 'lock', 'unlock'];
const groupConverters = [
zigbeeHerdsmanConverters.toZigbeeConverters.light_onoff_brightness,
@@ -112,7 +113,7 @@ class EntityPublish extends Extension {
try {
json = JSON.parse(message);
} catch (e) {
if (['on', 'off', 'toggle'].includes(message.toLowerCase())) {
if (stateValues.includes(message.toLowerCase())) {
json = {state: message};
} else {
logger.error(`Invalid JSON '${message}', skipping...`);