Smart Home Automation Forum

Full Version: Domoticz Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Can you please update your Plug-in for domoticz to add support for KC868-A16?

I've been added with MQTT but i have many loop problems! If anybody have added Kincony products with mqtt . pls help me to make it working without toggle loops?
KC868-A16 download KCS v2 firmware, it already support MQTT.
(10-13-2023, 11:19 PM)admin Wrote: [ -> ]KC868-A16 download KCS v2 firmware, it already support MQTT.

yes is correct! But have you any way to supress loops On/Off!?!?

1- When i send a command to enable output by click on button in domoticz (i have one script in events pane to trigger the actions)
2- Domoticz send command directly to the correct mqtt topic regarding my panel (not Node-red command)
3- the panel receive the MQTT command and enable the output
4- The panel send all status by mqtt to broker
5- the Node-red receive info from broker
6- The Node-Red send update to domoticz device for all inputs and outputs

This work fine to enable and disable device from domoticz. After that, when one input trigger one output (with fttt rule):
1- the panel enable the output
2- The panel send all status by mqtt to broker
3- the Node-red receive info from broker
4- The Node-Red send update to domoticz device for all inputs and outputs
5- the domoticz seems to be send again again one command
6- after that, the panel off the output and the cycle is repeated in loop state and repeat on-off-on.... each 3 seconds

When i use Node-Red to enable output, the comportement is poor because domoticz send new state each time in domoticz/out topic and the comportement is the same

! i thy to making some adjustments to my scripts but this is verry hard to resolve and prevent loop!
It is possible for you to:
1- add possibility in KCS (toggle button on web UI) for remove sending all mqtt status for all I/O each time one have changed?
2- any way to prevent loop toggle locking 
3- add any way to send custom message in a custom topic in mqtt protocol (with this i canot need to use node-red and act directly with domoticz)


In other way, i maked by myself with esp8266 smart devices communicating with domoticz using mqtt where i have created all code and i do not have this comportement!

Here my script in domoticz Events to send commandes for pane: (similar to my custom ESP8266 nodes)
Code:
-- Variables Locales                                                                                                                              //
ScriptName      = "Kincony - Garage - Commandes"
NodeTopicName   = "KC868_A16/90380CA438B0/SET";
NodeName        = "Kincony - Garage";
IdxTxtInfo      = "203";
Heure_Actuelle  = os.date("%X");
TempoNonReact   = 7;                                -- Tempo durant lequel on ne fait rien avec ce script

--Do1
VarNameToScrut1  =   "Gar-o1 - Lumiere Intérieur Min";
Do1OnStr  = '\'{\"output01\":{\"value\":true}}\'';
Do1OffStr = '\'{\"output01\":{\"value\":false}}\'';
--Do15
VarNameToScrut15  =   "Gar-o15";
Do15OnStr  = '\'{\"output15\":{\"value\":true}}\'';
Do15OffStr = '\'{\"output15\":{\"value\":false}}\'';
--Do16
VarNameToScrut16 =   "Gar-o16";
Do16OnStr  = '{"output16":{"value":true}}';
Do16OffStr = '{"output16":{"value":false}}';

--//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--                                                                                                                                                //
-- Fonctions                                                                                                                                      //
--//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--                                                                                                                                                //
--  Cette fonction retourne le temps en secondes depuis le dernier changement de la variable passée en argument                                   //
--                                                                                                                                                //


function timeSecondDifference(d)
   s = otherdevices_lastupdate[d]
   print(ScriptName.. " L162: otherdevices_lastupdate était à ".. otherdevices_lastupdate[d] .." pour la variable " .. d);
   year = string.sub(s, 1, 4)
   month = string.sub(s, 6, 7)
   day = string.sub(s, 9, 10)
   hour = string.sub(s, 12, 13)
   minutes = string.sub(s, 15, 16)
   seconds = string.sub(s, 18, 19)
   t1 = os.time()
   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds, mil=000}
   difference = os.difftime (t1, t2)
   return difference
end

--//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--                                                                                                                                                //
--  Cette fonction Active ou Désactive la variable scrutée que si elle n'a pas été activée dans le temps spécifié                                 //
--
--

function OnOffDevice(VarNameToScruting, NodeMqttTopicName, DoOnStr, DoOffStr, ModuleNodeName)
    --Do12
    if (devicechanged[VarNameToScruting] == 'On') then  -- Détection sur la variable
        if (timeSecondDifference(VarNameToScruting) > TempoNonReact) then -- Ignore la commande si la dernière activation est inférieure a 3 secondes
            print (ScriptName.. " L185: temps depuis la dernière action sur ce device: "..timeSecondDifference(VarNameToScruting))
            print(ScriptName.. " L186: "..ModuleNodeName.." - Commandes : "..VarNameToScruting.." commande "..DoOnStr);
            PrintTextToIdx(VarNameToScruting.." activée",IdxTxtInfo)  -- Envoi du log dans le device Arrosage actuel
           
        print('================= -> Le dispositif est éteint. Execution de: mosquitto_pub -t '..NodeMqttTopicName..' -m "'..DoOnStr..'"')
            os.execute ('mosquitto_pub -t '..NodeMqttTopicName..' -m '..DoOnStr)     -- Commande Mqtt
        end
    end
    if (devicechanged[VarNameToScruting] == 'Off') then  -- Détection sur la variable
        if (timeSecondDifference(VarNameToScruting) > TempoNonReact) then
            print (ScriptName.. " L193: time of off")
            print(timeSecondDifference(VarNameToScruting))
            print(ScriptName.. " L195: ".. ModuleNodeName.." - Commandes : "..VarNameToScruting.." commande "..DoOffStr);
            PrintTextToIdx(VarNameToScruting.." désactivée",IdxTxtInfo)  -- Envoi du log dans le device Arrosage actuel
           
        print('================= -> Le dispositif est éteint. Execution de: mosquitto_pub -t '..NodeMqttTopicName..' -m "'..DoOffStr..'"')
            os.execute ('mosquitto_pub -t '..NodeMqttTopicName..' -m '..DoOffStr)    -- Commande Mqtt
        end
    end
end
commandArray = {}
--Do1
OnOffDevice(VarNameToScrut1, NodeTopicName, Do1OnStr, Do1OffStr, NodeName)
--Do15
OnOffDevice(VarNameToScrut15, NodeTopicName, Do15OnStr, Do15OffStr, NodeName)
--Do16
OnOffDevice(VarNameToScrut16, NodeTopicName, Do16OnStr, Do16OffStr, NodeName)

return commandArray


HEre is my  Node-red commande to update domoticz:
Code:
msg216.payload = { "command": "udevice", "idx": 387, "nvalue": Number(msg.payload.output16.value), "svalue": "", "parse": false };