How do I check if a value excists?
Posted: Tue Jan 20, 2015 8:07 am
I'm workikng on an if statement to check if the freezer or fridge are too warm or selected rooms are too cold (basically the rooms with water in them). The statement is pretty simple (all variables are pre set in other scripts, I have put explanatory names instead, and I just made the action a print for now):
It errors out because for the first type of sensors there is no max temp, and for most of the second type of sensors there is no min temp. I would like to keep it in one script, since the fridge has both a minimum and maximum temperature. So I'm looking for something similar to what I would have done in LUA:
This code should theoretically first check if there is a value in the variable if eg.globals.Romtemperatur[Rom], and if there is it then checks if that value is smaller than the alarm temperature. Of course it errors out since it's partly LUA code.
I could of course set alarm temps so far outside the possible that they wouldn't react (like a min temp of -50 degrees for the freezer), but that would mess up the second line in the script, which shows the alarm temperature for a room in my webserver, where I would like to have only one colum for alarm temps. Anyway, I'd like to learn how to check if a variable is empty or not.
Code: Select all
if eg.globals.Romtemperatur[Rom] < eg.globals.Alarmtemperatur1[Rom]:#For rooms with water in them
print Rom, eg.globals.Termostatmodus[Rom], eg.globals.Alarmtemperatur1[Rom], eg.globals.Romtemperatur[Rom]
eg.globals.WebsiteAlarmTemp[Rom] = eg.globals.Alarmtemperatur1[Rom]
if eg.globals.Romtemperatur[Rom] > eg.globals.Alarmtemperatur2[Rom]: #For fridge, freezer, cooler room
print Rom, eg.globals.Termostatmodus[Rom], eg.globals.Alarmtemperatur2[Rom], eg.globals.Romtemperatur[Rom]
eg.globals.WebsiteAlarmTemp[Rom] = eg.globals.Alarmtemperatur2[Rom]
Code: Select all
if eg.globals.Romtemperatur[Rom]: if eg.globals.Romtemperatur[Rom] < eg.globals.Alarmtemperatur1[Rom]: