Page 1 of 1

dzVents temperature switch

Posted: Thursday 02 August 2018 17:32
by Remicade
Hi Forum,
After a lot of reading and trying still strugling to get this dzVents script working.
I use the Omnik script to read the temperature.
This is a Custom Device.
The fan should cool the inverterabove 25 degrees Celcius.

Can somebody please give me a suggestion why the script is faulty?

return {
on = {
timer = 'every minute'
},
execute = function(domoticz)
local Sensor = domoticz.devices( 'Omnik temperature' )
if (Sensor.temperature) >= 25) then
domoticz.devices( 'Omnik Ventilator' ).switchOn()
end
end
}

btw what tochoose by
event name,
dzVents,
???

Thanks Paul

Re: dzVents temperature switch

Posted: Thursday 02 August 2018 18:52
by dannybloe
Try to remove all the ( and ) in your if-statement.

And next time post the errors you get. That helps 😀

Re: dzVents temperature switch

Posted: Thursday 02 August 2018 19:12
by EdwinK
Can you please use the [ code ] and [ /code ] blocks. It will make everything easier to read

Thanks.

Re: dzVents temperature switch

Posted: Thursday 02 August 2018 20:16
by Remicade
Hi and thanks for your support.
I will try to make it more readable...... :oops:

Now changed the script as suggested :

Code: Select all

 
return {
   on = {
      timer = 'every minute'
   },
   execute = function(domoticz)
      local Sensor = domoticz.devices('Omnik temperature')
      if Sensor.temperature >= 25 then
         domoticz.devices('Omnik Ventilator').switchOn()
      end
   end
}
Can it be the problem with the Custom Sensor?
Or the fact that "spacebar" is used between Omnik temperature?

Thanks again!
Paul

Re: dzVents temperature switch

Posted: Thursday 02 August 2018 20:22
by waaren
Remicade wrote: ↑Thursday 02 August 2018 20:16 I will try to make it more readable...... :oops:
Can it be the problem with the Custom Sensor?
Or the fact that "spacebar" is used between Omnik temperature?

Thanks again!
Paul
Problem is that you forgot a pair of {}
Please find corrected script below.

Code: Select all

 
return {
   on = {       timer = { 'every minute'  } },
      
   execute = function(domoticz)
      local Sensor = domoticz.devices('Omnik temperature')
      if Sensor.temperature >= 25 then
         domoticz.devices('Omnik Ventilator').switchOn()
      end
   end
}

Re: dzVents temperature switch

Posted: Thursday 02 August 2018 20:56
by Remicade
Thanks waaren,
If you three guys think that the script is o.k. but it is still not working....Could it be that my devices are not correct?
I had a typo in the previous script but that seems o.k. now.
Now will try to debug, after finding out how exactly.

Thanks!
Paul

Re: dzVents temperature switch

Posted: Thursday 02 August 2018 21:01
by EdwinK
Sounds so easy :) Was trying to get something like this for a few weeks. Now I've two of these scripts running for the two ventilators I've got, but could those also be combined in one script?

Re: dzVents temperature switch

Posted: Thursday 02 August 2018 21:09
by EdwinK
Remicade wrote: ↑Thursday 02 August 2018 20:56 Thanks waaren,
If you three guys think that the script is o.k. but it is still not working....Could it be that my devices are not correct?
I had a typo in the previous script but that seems o.k. now.
Now will try to debug, after finding out how exactly.

Thanks!
Paul
I have my fan's as on/off switch and the temperature is coming from two temperature devices, not custom sensors.

Re: dzVents temperature switch

Posted: Thursday 02 August 2018 21:16
by waaren
Remicade wrote: ↑Thursday 02 August 2018 20:56 Thanks waaren,
If you three guys think that the script is o.k. but it is still not working....Could it be that my devices are not correct?
I had a typo in the previous script but that seems o.k. now.
Now will try to debug, after finding out how exactly.

Thanks!
Paul
What about looking at the log in the GUI ? [SETUP][LOG][ALL] do you see anything there on every minute :00 ?

Re: dzVents temperature switch

Posted: Thursday 02 August 2018 21:46
by Remicade
Hi EdwinK,
That did the trick.
Made a new device, but now Type Temp.
In the Omnik changed IDX.
The script is now running and switching my OmnikVentilator.
Thanks for the help!
Paul

Re: dzVents temperature switch

Posted: Friday 03 August 2018 20:50
by EdwinK
i thought this would be working, as the fan in the living room doesn't have to be on at night.

Code: Select all

 return {
   on = {       timer = { 'every minute at daytime'  } },
      
   execute = function(domoticz)
      local Sensor = domoticz.devices('HSKTemp')
      if Sensor.temperature >= 20 then
         domoticz.devices('FAN Huiskamer').switchOn()
      end
   end
}
Same would be for the bedroom fan; but then during night-time. But unfortunately, this doesn't seem to work.