I am using configuration files and defined below Thing/Channel of my AC via MQTT:
Thing mqtt:topic:mosquitto:AC1 "Master" (mqtt:broker:mosquitto) []
{
Type string : Mode "Mode" [stateTopic="master/climate/masterAC/mode/state"]
Type switch : Power "Power" [stateTopic="master/climate/masterAC/mode/state" , commandTopic="master/climate/masterAC/mode/command", on="cool", off="off"]
Type number : TargetTemp "Target Temperature" [stateTopic="master/climate/masterAC/target_temperature/state" , commandTopic="master/climate/masterAC/target_temperature/command"]
Type number : CurrentTemp "Current Temperature" [stateTopic="master/climate/masterAC/current_temperature/state"]
Type string : FanMode "Fan Mode" [stateTopic="master/climate/masterAC/fan_mode/state" , commandTopic="master/climate/masterAC/fan_mode/command"]
}
1. The MQTT Topic "basement/climate/madoka_-_basement/mode/state" (Mode channel) returns more than 2 values (off, cool, hot and fan). Is it possible to use it as a switch, and set the 'off' value to 'off' and the 'on' value to 'cool or hot or fan'?
2. How do I add icons to the channels?
3. How do I add Units Of Measurement to the channels?
Thank you
Thank you both.
I tried to use the script transform option but it didn’t work.
I used below thing configuration - “Mode2” channel uses stateTransformation:
Thing mqtt:topic:mosquitto:AC1 "Master" (mqtt:broker:mosquitto) [ ]
{
Type switch : Power "Power" [stateTopic="master/climate/masterAC/mode/state", commandTopic="master/climate/masterAC/mode/command", on="cool", off="off"]
Type string : Mode "Mode" [stateTopic="master/climate/masterAC/mode/state"]
Type string : Mode2 "Mode2" [stateTopic="master/climate/masterAC/mode/state", stateTransformation="JS:daikin_transform.js"]
}
and put the following “daikin_transform.js” file under the transform folder (I am not a programmer so I used ChatGPT):
(function(input) {
// Define the mapping
var mapping = {
"off": "off",
"cool": "on",
"heat": "on",
"heat_cool": "on",
"fan_only": "on",
"dry": "on"
};
// Return the mapped value, or "off" as the default if the input is not in the mapping
return mapping[input] !== undefined ? mapping[input] : "off";
})(input)
The problem is that both channels “Mode” & “Mode2” return the same value “cool”, instead “cool” for “Mode” and “on” for “Mode2”.
What there a change in the mode after you made the changes to the Channels? If the device doesn’t change there won’t be an event to run the transformation and the Item will remain “cool” until the mode changes to something else.