After upgrade to OH4.1 and JS Scripting installed, all my js transformations, which i wrote to work with JSON for Mosquitto server seem to work, but every item state update spams to log with a lot of similar lines like this:
2024-01-12 21:12:18.644 [WARN ] [transport.mqtt.internal.Subscription] - A subscriber of type 'class org.openhab.binding.mqtt.generic.ChannelState' failed to process message '7B226272696768746E657373223A22323534222C22636F6C6F72223A7B22687565223A3236382C2273617475726174696F6E223A38322C2278223A302E323938322C2279223A302E313733347D2C22636F6C6F725F6D6F6465223A226873222C22636F6C6F725F74656D70223A3231332C22646F5F6E6F745F64697374757262223A66616C73652C226C6576656C5F636F6E666967223A7B226F6E5F6C6576656C223A2270726576696F7573227D2C226C696E6B7175616C697479223A37322C227374617465223A224F4E227D' to topic 'zigbee2mqtt/O_B_Color_Light_3'.
I’ve added some logging to js script to see what happens:
(function (x) {
var logger = log('color_bulb color_in');
logger.info(x);
var tmp = JSON.parse(x);
// The brightness value is received as integer 1-254 but needed as percentage
var brightness = Math.round(parseFloat(tmp.brightness) / 254 * 100);
var color_mode = tmp.color_mode;
var saturation = parseFloat(tmp.color.saturation);
if (color_mode == 'color_temp') {
saturation = 0
}
out = '' + tmp.color.hue + ',' + saturation + ',' + brightness
logger.info(out);
return out.toString();
})(input)
and logs became:
2024-01-12 21:12:18.639 [INFO ] [ation.openhab-js.color_bulb color_in] - {"brightness":"254","color":{"hue":268,"saturation":82,"x":0.2982,"y":0.1734},"color_mode":"hs","color_temp":213,"do_not_disturb":false,"level_config":{"on_level":"previous"},"linkquality":72,"state":"ON"}
2024-01-12 21:12:18.640 [INFO ] [ation.openhab-js.color_bulb color_in] - 268,82,100
2024-01-12 21:12:18.644 [WARN ] [transport.mqtt.internal.Subscription] - A subscriber of type 'class org.openhab.binding.mqtt.generic.ChannelState' failed to process message '7B226272696768746E657373223A22323534222C22636F6C6F72223A7B22687565223A3236382C2273617475726174696F6E223A38322C2278223A302E323938322C2279223A302E313733347D2C22636F6C6F725F6D6F6465223A226873222C22636F6C6F725F74656D70223A3231332C22646F5F6E6F745F64697374757262223A66616C73652C226C6576656C5F636F6E666967223A7B226F6E5F6C6576656C223A2270726576696F7573227D2C226C696E6B7175616C697479223A37322C227374617465223A224F4E227D' to topic 'zigbee2mqtt/O_B_Color_Light_3'.
As I see it, the script itself works fine, but after it something strange happens: each message arrives several times, and in some strange encoding. Separately, I would like to understand what “failed to process message to topic” means, given that it seems to be a message FROM the server.
MQTT Thing configuration is:
// O_B_Color_Light_3
Thing topic O_B_Color_Light_3 "O_B_Color_Light_3" @ "O_Backyard" {
Channels:
Type switch : light "Backyard Light 3" [
stateTopic="zigbee2mqtt/O_B_Color_Light_3",
transformationPattern="REGEX:(.*state.*)∩JSONPATH:$.state",
commandTopic="zigbee2mqtt/O_B_Color_Light_3/set",
retained=true,
on="ON",
off="OFF"
]
Type number : brightness "Backyard light 3 brightness" [
stateTopic="zigbee2mqtt/O_B_Color_Light_3",
transformationPattern="JS:color_bulb_brightness.js",
commandTopic="zigbee2mqtt/O_B_Color_Light_3/set",
transformationPatternOut="JS:color_bulb_brightness_out.js"
]
Type number : color_temp "Backyard light 3 temp" [
min="2700",
max="6500",
step="100",
stateTopic="zigbee2mqtt/O_B_Color_Light_3",
transformationPattern="JS:color_bulb_temperature.js",
commandTopic="zigbee2mqtt/O_B_Color_Light_3/set",
transformationPatternOut="JS:color_bulb_temperature_out.js"
]
Type color : color "O_B 3 Hue" [
//colorMode="XYY",
stateTopic="zigbee2mqtt/O_B_Color_Light_3",
transformationPattern="JS:color_bulb_color.js",
commandTopic="zigbee2mqtt/O_B_Color_Light_3/set",
transformationPatternOut="JS:color_bulb_color_out.js"
]
}
Please help me find out the reason for these messages.