Hi!
after figuring out someone of blockly codes are bugging my PI's memory, making it slowly reach 100% then crash, i decided to write all the events in LUA.
After a lot of research, the only thing I have left now is heat-control.
Cant seem to get it to work since I dont know how to write this Blockly image into LUA code.
if (devicechanged['tempsensor goes here'] < ['thermostat goes here'] and otherdevices['Hus-Varme-Hovedbryter'] == 'On' ) then
commandArray['Gang-Varmekabler']='On'
end
Hoping for some help, been googling and browsing this forum for hours.
John
noob help needed: If temperature > thermostat then
Moderator: leecollings
-
- Posts: 26
- Joined: Sunday 08 January 2017 19:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
noob help needed: If temperature > thermostat then
- Attachments
-
- tempthermostat.JPG (23.9 KiB) Viewed 1838 times
-
- Posts: 102
- Joined: Thursday 28 January 2016 22:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8153
- Location: NL
- Contact:
Re: noob help needed: If temperature > thermostat then
Do you also have something that switches your 'Gang-Varmekabler' off?
I would use a TIME lua script for this. That runs every minute.
EDIT
....assuming that your thermostat value is available as a uservariable. If it is something different, replace that code or make it into a uservariable.
I would use a TIME lua script for this. That runs every minute.
Code: Select all
IF ( tonumber(otherdevices_svalues['tempsensor']) < tonumber(uservariables['thermostat']) ) and otherdevices['Hus-Varme-Hovedbryter'] == 'On' then
commandArray['Gang-Varmekabler']='On'
end
....assuming that your thermostat value is available as a uservariable. If it is something different, replace that code or make it into a uservariable.
-
- Posts: 26
- Joined: Sunday 08 January 2017 19:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: noob help needed: If temperature > thermostat then
Thanks for the reply. I Will use the same code to turn it off just switch it to
if (temperature > thermostat) then switch off.
Currently it runs every time the sensor picks up a new value. This is often as its 0.1celcius increments.
It's an aetotec multisensor 6 with Temp and Humidity. They share the same IDX aswell, so how I'm going to get only the temp number is also a question I forgot to ask in the main post.
The thermostat is a virtual setPoint thermostat in domoticz.
edit: I edited the thermosat til "otherdevices_svalues['Gang-Varme-Termostat'] but it didnt work.
edit2: this works, but im using numbers instead of the thermostat setpoint number. So it still needs fixing.
end
if (temperature > thermostat) then switch off.
Currently it runs every time the sensor picks up a new value. This is often as its 0.1celcius increments.
It's an aetotec multisensor 6 with Temp and Humidity. They share the same IDX aswell, so how I'm going to get only the temp number is also a question I forgot to ask in the main post.
The thermostat is a virtual setPoint thermostat in domoticz.
edit: I edited the thermosat til "otherdevices_svalues['Gang-Varme-Termostat'] but it didnt work.
edit2: this works, but im using numbers instead of the thermostat setpoint number. So it still needs fixing.
Code: Select all
if (devicechanged['Gang-Temp-Sensor_Temperature'] < 22 ) then
commandArray['Gang-Varmekabler']='On'
elseif (devicechanged['Gang-Temp-Sensor_Temperature'] > 22 ) then
commandArray['Gang-Varmekabler']='Off'
-
- Posts: 102
- Joined: Thursday 28 January 2016 22:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8153
- Location: NL
- Contact:
Re: noob help needed: If temperature > thermostat then
If that Gang-Varme-Termostat is a dummy setpoint termostat, this should work:
You need to use tonumber( ), because the otherdevices['setpointthermostat'] returns a string that represents a number.
For heating, I recommend an extra thermostat switch in the power line to your Varmekabler, set to 25 degrees or so, as a safety, in case something goes wrong in Domoticz or your scripts.
Code: Select all
if (devicechanged['Gang-Temp-Sensor_Temperature'] < tonumber(otherdevices['Gang-Varme-Termostat']) ) then
commandArray['Gang-Varmekabler']='On'
elseif (devicechanged['Gang-Temp-Sensor_Temperature'] > tonumber(otherdevices['Gang-Varme-Termostat']) ) then
commandArray['Gang-Varmekabler']='Off'
end
For heating, I recommend an extra thermostat switch in the power line to your Varmekabler, set to 25 degrees or so, as a safety, in case something goes wrong in Domoticz or your scripts.
-
- Posts: 26
- Joined: Sunday 08 January 2017 19:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: noob help needed: If temperature > thermostat then
Hmm still won't work. Will try to add ['Setpoint_mydevice'] when I get home.
The heat switch have an inbuilt safety to turn off after 4 hours. So if by any chance some goes wrong it can only host for 4 hours at a time before getting a new signal. If domoticz is then bugged, it won't receive a new signal and the power stays off.
The heat switch have an inbuilt safety to turn off after 4 hours. So if by any chance some goes wrong it can only host for 4 hours at a time before getting a new signal. If domoticz is then bugged, it won't receive a new signal and the power stays off.
-
- Posts: 329
- Joined: Tuesday 16 July 2013 22:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8807
- Location: North East England
- Contact:
Re: noob help needed: If temperature > thermostat then
How about:
I have not tested so there could be spelling mistrakes.
Reading the previous posts, my thoughts:
If you are using the in built editor then make sure to set this to a device script, if the script is lua file then script_device_gangtempsensor.lua.
Use tonumber to just make sure things are numbers when you do the comparison.
No need to do 2 comparisons, if it is temperature is low you want to heat, otherwise don't heat.
You could also check the status of the Gang-Varmekabler before sending it a command, so that you don't turn it on again if it is already on, on the otherhand it doesn't matter to send extra commands.
Always helpful to post full scripts including file name or setting on the internal editor so it is obvious what you are doing.
Code: Select all
-- script_device_gangtempsensor.lua
commnadArray = {}
if devicechanged['Gang-Temp-Sensor'] then
-- debugging prints just to check we are getting the right things
print('Current Gang Temp Sensor: '..devicechanged['Gang-Temp-Sensor_Temperature'])
print('Current Set Point: '..otherdevices['Hus-Verme-Hovedbryter'])
if tonumber(devicechanged['Gang-Temp-Sensor_Temperature']) < tonumber(otherdevices['Gang-Verma-Termostat'] and otherdevices['Hus-Verme-Hovedbryter'] == 'On' then
commandArray['Gang-Varmekabler'] = 'On'
else
commandArray['Gang-Varmekabler'] = 'Off'
end
end
return commandArray
end
Reading the previous posts, my thoughts:
If you are using the in built editor then make sure to set this to a device script, if the script is lua file then script_device_gangtempsensor.lua.
Use tonumber to just make sure things are numbers when you do the comparison.
No need to do 2 comparisons, if it is temperature is low you want to heat, otherwise don't heat.
You could also check the status of the Gang-Varmekabler before sending it a command, so that you don't turn it on again if it is already on, on the otherhand it doesn't matter to send extra commands.
Always helpful to post full scripts including file name or setting on the internal editor so it is obvious what you are doing.
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
-
- Posts: 26
- Joined: Sunday 08 January 2017 19:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: noob help needed: If temperature > thermostat then
simonrg wrote:How about:I have not tested so there could be spelling mistrakes.Code: Select all
-- script_device_gangtempsensor.lua commnadArray = {} if devicechanged['Gang-Temp-Sensor'] then -- debugging prints just to check we are getting the right things print('Current Gang Temp Sensor: '..devicechanged['Gang-Temp-Sensor_Temperature']) print('Current Set Point: '..otherdevices['Hus-Verme-Hovedbryter']) if tonumber(devicechanged['Gang-Temp-Sensor_Temperature']) < tonumber(otherdevices['Gang-Verma-Termostat'] and otherdevices['Hus-Verme-Hovedbryter'] == 'On' then commandArray['Gang-Varmekabler'] = 'On' else commandArray['Gang-Varmekabler'] = 'Off' end end return commandArray end
Reading the previous posts, my thoughts:
If you are using the in built editor then make sure to set this to a device script, if the script is lua file then script_device_gangtempsensor.lua.
Use tonumber to just make sure things are numbers when you do the comparison.
No need to do 2 comparisons, if it is temperature is low you want to heat, otherwise don't heat.
You could also check the status of the Gang-Varmekabler before sending it a command, so that you don't turn it on again if it is already on, on the otherhand it doesn't matter to send extra commands.
Always helpful to post full scripts including file name or setting on the internal editor so it is obvious what you are doing.
WITCHCRAFT! it worked, had to edit some typos like you said. Now I need to look into the code and figure why it works, then I perhaps i can sort my errors from my other LUA codes.
Edit:how rude of me. Thank you very much
Who is online
Users browsing this forum: No registered users and 1 guest