Im trying to do a simple on/off switch in Domoticz to send the appropriate json payload into a Tasmota device that will turn on or off an AC unit, using a virtual switch.
Im not into dzVents so i asked Bing Chat

Code: Select all
return {
on = {
devices = {
'AC_ESCRIT'
}
},
execute = function(domoticz, device)
if device_state == 'On' then
local mqttCommand = {
Vendor = "FUJITSU_AC",
Model = "ARRAH2E",
Command = "Control",
Mode = "Auto",
Power = "On",
Celsius = "On",
Temp = 23,
FanSpeed = "Auto",
SwingV = "Off",
SwingH = "Off",
Quiet = "Off",
Turbo = "Off",
Econo = "Off",
Light = "Off",
Filter = "Off",
Clean = "Off",
Beep = "Off",
Sleep = -1,
iFeel = "Off",
SensorTemp = 0
}
domoticz_publish('cmnd/tasmota_F6CD26/IRHVAC', domoticz_utils_toJSON(mqttCommand))
end
end
}
If i run this script and press the virtual switch i get the error: field 'publish' is not callable (a nil value)
This seems to be a rather simple thing to do but i couldn't find info in the wikis... Also i would prefer to publish the json payload into the mqtt broker rather than opening an URL since the devices IPs can change.
Thanks in advence