This is related to a Tasmota RGB bulb, that is connected using the MQTT Binding.
When changing the colour on the bulb using its app, it sends a JSON update that produces warning in the log, and the Item linked to the channel does not get updated.
Item
Color BedroomRGBLampColour "Bedroom RGB lamp colour" (InternalState) {channel="mqtt:topic:44092da7f6:598434b618:Colour"}
Channel config in Thing:
- id: Colour
channelTypeUID: mqtt:colorHSB
label: Colour
configuration:
commandTopic: cmnd/tasmota_4BA7A4/HSBColor
transformationPatternOut: JS:noTransform.js
stateTopic: stat/tasmota_4BA7A4/RESULT
transformationPattern: JS:extractHSBColor.js
I am using a JavaScript transform to parse the incoming JSON:
extractHSBColor.js
(function(jsonString) {
try {
// Log the raw incoming payload for debugging purposes
console.log("Incoming HSBColor payload:", jsonString);
var data = JSON.parse(jsonString);
if (data && data.HSBColor != undefined) {
console.log("Extracted HSB Color field:", data.HSBColor);
return data.HSBColor;
}
} catch (e) {
// Log or handle the parsing error if needed
console.log("Error parsing JSON or missing HSB Color field:", e); // Log error details
}
return ""; // Returning an empty string prevents the Item from being updated
})(input)
This is the warning received in the log (even though it is just a warning, my linked Item does not get updated):
2024-11-30 17:57:04.084 [INFO ] [org.openhab.automation.script ] - Incoming HSBColor payload: {"POWER":"ON","Dimmer":100,"Color":"5CFFC10000","HSBColor":"157,64,100","White":0,"CT":450,"Channel":[36,100,76,0,0]}
2024-11-30 17:57:04.085 [INFO ] [org.openhab.automation.script ] - Extracted HSB Color field: 157,64,100
2024-11-30 17:57:04.086 [WARN ] [transport.mqtt.internal.Subscription] - A subscriber of type 'class org.openhab.binding.mqtt.generic.ChannelState' failed to process message '7B22504F574552223A224F4E222C2244696D6D6572223A3130302C22436F6C6F72223A2235434646433130303030222C22485342436F6C6F72223A223135372C36342C313030222C225768697465223A302C224354223A3435302C224368616E6E656C223A5B33362C3130302C37362C302C305D7D' to topic 'stat/tasmota_BC463F/RESULT'.
You can see that the HSB Colour values are stripped successfully from the payload, and returned by the transformation script.
The long hex number in the log is simply the payload encoded in hex.
Other Items on the Thing, such as Dimmer, and CT are working fine using a similar config; the issue is just with the Color Item.
Any ideas why this isn’t working?