Lua triggerd very often

Moderator: leecollings

Post Reply
TimH
Posts: 11
Joined: Friday 11 November 2016 8:56
Target OS: NAS (Synology & others)
Domoticz version: 3.5877
Location: Germany
Contact:

Lua triggerd very often

Post by TimH »

Hi there,

i have wrote a LUA scripte. You can see this below.
My Problem is the Script is triggerd very often. The Temperature isn't changed in this time. The Setpoint devices is the same Danfoss LC-13
I have attached the log below two.
Why is it triggerd so often.

Code: Select all

local act_time = os.date("%H:%M")

commandArray = {}
if ((otherdevices['Esszimmer Heizung']~='16') or (otherdevices['Wohnzimmer Heizung 1']~='16')) and (otherdevices['Wohnzimmer Heizung']=='17°C') then
    commandArray[1]={['UpdateDevice']="48|0|16"}
    commandArray[2]={['UpdateDevice']="50|0|16"}
    print("Heizung auf 16°C eingestellt")
elseif ((otherdevices['Esszimmer Heizung']~='23') or (otherdevices['Wohnzimmer Heizung 1']~='23')) and (otherdevices['Wohnzimmer Heizung']=='23°C') then
    print(otherdevices['Wohnzimmer Heizung 1'])
    print(otherdevices['Esszimmer Heizung'])
    commandArray[1]={['UpdateDevice']='50|0|23'}
    commandArray[2]={['UpdateDevice']='48|0|23'}
    commandArray[3]={['Variable:Heizungschalten']=act_time}
    print("Heizung auf 23°C eingestellt")
end
return commandArray
LOG FIle:

Code: Select all

2017-01-25 16:38:42.288 User: Tim initiated a switch command (22/Anwesenheit/Off)
2017-01-25 16:43:09.549 LUA: 23
2017-01-25 16:43:09.549 LUA: 23.00
2017-01-25 16:43:09.549 LUA: Heizung auf 23°C eingestellt
2017-01-25 16:43:09.553 EventSystem: Script event triggered: Heizungneu
2017-01-25 16:43:09.739 LUA: 23
2017-01-25 16:43:09.739 LUA: 23.00
2017-01-25 16:43:09.739 LUA: Heizung auf 23°C eingestellt
2017-01-25 16:43:09.744 EventSystem: Script event triggered: Heizungneu
2017-01-25 16:43:15.778 LUA: 23.00
2017-01-25 16:43:15.779 LUA: 23
2017-01-25 16:43:15.779 LUA: Heizung auf 23°C eingestellt
2017-01-25 16:43:15.784 EventSystem: Script event triggered: Heizungneu
2017-01-25 16:43:15.979 LUA: 23.00
2017-01-25 16:43:15.979 LUA: 23
2017-01-25 16:43:15.979 LUA: Heizung auf 23°C eingestellt
2017-01-25 16:43:15.984 EventSystem: Script event triggered: Heizungneu
2017-01-25 16:43:50.799 EventSystem: reset all events...
2017-01-25 16:48:12.131 LUA: 23.00
2017-01-25 16:48:12.131 LUA: 23
2017-01-25 16:48:12.132 LUA: Heizung auf 23°C eingestellt
2017-01-25 16:48:12.135 EventSystem: Script event triggered: Heizungneu
2017-01-25 16:48:12.322 LUA: 23.00
2017-01-25 16:48:12.322 LUA: 23
2017-01-25 16:48:12.322 LUA: Heizung auf 23°C eingestellt
2017-01-25 16:48:12.327 EventSystem: Script event triggered: Heizungneu
User avatar
jvdz
Posts: 2332
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Lua triggerd very often

Post by jvdz »

You are not doing a numeric test but alphanumeric. Just do a numeric compare like:

Code: Select all

elseif ((tonumber(otherdevices['Esszimmer Heizung'])~=23) or (tonumber(otherdevices['Wohnzimmer Heizung 1'])~=23)) and (otherdevices['Wohnzimmer Heizung']=='23°C') then
I am assuming that the result of otherdevices['Wohnzimmer Heizung'] really is something as you test with '23°C'.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
simonrg
Posts: 329
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Lua triggerd very often

Post by simonrg »

TimH wrote:Hi there,

i have wrote a LUA scripte. You can see this below.
My Problem is the Script is triggerd very often. The Temperature isn't changed in this time. The Setpoint devices is the same Danfoss LC-13
I have attached the log below two.
Why is it triggerd so often.
Assuming this is a device script i.e. script_device_setpoint.lua, then the script will be triggered every time any device changes.

Hence the use of deviceChanged to see if the device you are interested in has changed or not:

Code: Select all

local act_time = os.date("%H:%M")

commandArray = {}
if deviceChanged['Temperature Sensor'] then
     -- all your code with the temperature tests and acitons
end
return commandArray
This way the script will only check temperature differences when the temperature device has changed
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
TimH
Posts: 11
Joined: Friday 11 November 2016 8:56
Target OS: NAS (Synology & others)
Domoticz version: 3.5877
Location: Germany
Contact:

Re: Lua triggerd very often

Post by TimH »

jvdz wrote:You are not doing a numeric test but alphanumeric. Just do a numeric compare like:

Code: Select all

elseif ((tonumber(otherdevices['Esszimmer Heizung'])~=23) or (tonumber(otherdevices['Wohnzimmer Heizung 1'])~=23)) and (otherdevices['Wohnzimmer Heizung']=='23°C') then
I am assuming that the result of otherdevices['Wohnzimmer Heizung'] really is something as you test with '23°C'.

Jos
Yes thats it. That works for me. The Switch Wohnzimmer Heizung is a Selector switch an there are select with 23°C.
The idea from simonrg is also good.
I Think i try with another heater when it's manually changed.

Thanks everybody
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest