rfxcom ignore a switch update done by lua

Moderator: leecollings

Post Reply
aleph0
Posts: 85
Joined: Thursday 12 May 2016 15:47
Target OS: Linux
Domoticz version: 11838
Location: South of France
Contact:

rfxcom ignore a switch update done by lua

Post 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 !
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: rfxcom ignore a switch update done by lua

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
aleph0
Posts: 85
Joined: Thursday 12 May 2016 15:47
Target OS: Linux
Domoticz version: 11838
Location: South of France
Contact:

Re: rfxcom ignore a switch update done by lua

Post by aleph0 »

It works :)

Thanks a lot for your help :)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest