Page 1 of 1

rfxcom ignore a switch update done by lua

Posted: Saturday 11 June 2016 11:07
by aleph0
Hi all !

It's my first post on this forum so let me first thanks all the team for this great piece of software domoticz is :)

I'm running into a funny problem, your support will be welcome : I'm running dev version 3.5231 ; I have a On/Off switch which drives a ZK1PA relay via rfxcom. It works well when I click on the switch from the web interface, my relay switches on and off as desired.

Ex :

Code: Select all

2016-06-11 10:44:16.561  User: Admin initiated a switch command
2016-06-11 10:44:16.562  (RfxCom) Lighting 1 (Filtration piscine)
and the relay is toggling in real life

Then, I wrote a lua script to toggle this switch on some criterias :

Code: Select all

[...]
if (MinDuJour >= PpeStart and MinDuJour < PpeStop and Filtration == "Off") then
	-- Filtration On
	print("Filtration piscine : Démarrage par timer")
	commandArray[CmdIdx] = {['UpdateDevice'] = idxPpe..'|1|On'}
	CmdIdx=CmdIdx+1
end
if (MinDuJour >= PpeStop and Filtration == "On") then
	-- Filtration Off
	print("Filtration piscine : Arrêt par timer")
	commandArray[CmdIdx] = {['UpdateDevice'] = idxPpe..'|0|Off'}
	CmdIdx=CmdIdx+1
end
[...]
This commandArray toggle the switch correctly in domoticz : I can see it in the web interface, in the sensor logs, it's taken into account by other lua scripts. However, the rfxcom is not sending the command to the relay in that case :

Code: Select all

2016-06-11 10:45:01.145  LUA: Script Filtration Piscine
2016-06-11 10:45:01.145  LUA: Filtration piscine : Démarrage par timer
2016-06-11 10:45:01.147  EventSystem: Script event triggered: /opt/domoticz/scripts/lua/script_time_piscine.lua
*nothing here :(*
2016-06-11 10:45:08.587  Hardware Monitor: Fetching data (System sensors)
2016-06-11 10:45:13.321  EventSystem: Script event triggered: /opt/domoticz/scripts/lua/script_device_elec.lua
What am I doing wrong ?

Thanks for your help !

Re: rfxcom ignore a switch update done by lua

Posted: Saturday 11 June 2016 12:16
by jvdz
I am not sure that format is correct. I am using it this way in my scripts:

Code: Select all

[...]
if (MinDuJour >= PpeStart and MinDuJour < PpeStop and Filtration == "Off") then
   -- Filtration On
   print("Filtration piscine : Démarrage par timer")
   commandArray[CmdIdx] = {['Filtration piscine'] = 'On'}
   CmdIdx=CmdIdx+1
end
if (MinDuJour >= PpeStop and Filtration == "On") then
   -- Filtration Off
   print("Filtration piscine : Arrêt par timer")
   commandArray[CmdIdx] = {['Filtration piscine'] = 'Off'}
   CmdIdx=CmdIdx+1
end
[...]
Jos

Re: rfxcom ignore a switch update done by lua

Posted: Sunday 12 June 2016 8:52
by aleph0
It works :)

Thanks a lot for your help :)