Hi, I started to create widget for fasades lighting and easy script, but all not so easy for me. Idea - swich On/off by time or/and outside sensor.
At widget I need enter hour/min for On time and hour.min for Off time. Also I added Sensor control - Light level form sensor, Lux when Light will be On, and Delta when Light should be off.
Below my widget (not finished) and script.
Some moments I need help:
1. How to show zero in front if hours or minutes from 0 to 9 ?
2. For me my idea not forking correctly, fasades light is flashing some times.
3. How check "mistakes" settings better?
Not found example at forum.
i used resident script 1 minute.
BR,
Alex
At widget I need enter hour/min for On time and hour.min for Off time. Also I added Sensor control - Light level form sensor, Lux when Light will be On, and Delta when Light should be off.
Below my widget (not finished) and script.
Some moments I need help:
1. How to show zero in front if hours or minutes from 0 to 9 ?
2. For me my idea not forking correctly, fasades light is flashing some times.
3. How check "mistakes" settings better?
Not found example at forum.
i used resident script 1 minute.
Code:
HStart = grp.getvalue('0/1/100') -- Hours to start Fasades Light On
MinStart = grp.getvalue('0/1/101') -- Minutes to start Fasades Light On
HStop = grp.getvalue('0/1/102') -- Hours to stop Fasades Light On
MinStop = grp.getvalue('0/1/103') -- Minutes to stop Fasades Light On
SensorValue = grp.getvalue('1/0/100') -- Outside Light Sensor Value LUX
SensorLightOn = grp.getvalue('0/1/105') -- LightOn Value LUX
LightOffHysteresis = grp.getvalue('0/1/106') -- LightOff Hysteresis LUX
-------------------------------------------------------------------------
now = os.date('*t')
-- time table
time = {
day = wday,
hour = now.hour,
minute = now.min,
second = now.sec,
}
if (now.hour == HStart) and (now.min == MinStart)then
FasadesLightTime = 1
grp.write ('0/2/19', 1) -- Group Fasades Light
end
if (now.hour == HStop) and (now.min == MinStop) then
FasadesLightTime = 0
grp.write ('0/2/19', 0)
end
if SensorValue <= SensorLightOn then
SensorOn = 1
grp.write ('0/2/19', 1)
end
if SensorValue > SensorLightOn + LightOffHysteresis then
SensorOn = 0
grp.write ('0/2/19', 0)
end
BR,
Alex