I'm using a netatmo weather station to monitor the temperature. When the temperature is below a certain threshold, the switches should go to 'on'. When the temperature is above a threshold, the switches should go 'off'. So I created this code. The state of the netatmo station is something like this '19.5;70;3;1012.5;7'. Therefor, I take the first three symbols of this string and convert this to a number. Unfortunately nothing is hapening. Someone an idea what's going wrong?
Code: Select all
commandArray = {}
if (devicechanged['Binnen']) then
--print('Temp is ' .. devicechanged_svalues['Binnen'])
temp = devicechanged['Binnen']
temp = temp:sub( 1, 4 )
temp = tonumber(temp)
if (temp < 25.0 and otherdevices['Zithoek'] == 'Off') then
commandArray['Zithoek']='On'
--print('Outside temperature is hot, switching fan on')
end
end
return commandArray