Has anybody a good working hysteresis script based on lux level?
Based on multilevels or better a formula?
I am looking for a scripts which sets the level of bulbs, with 'dimTo()', based on the lux level in the room.
Hysteresis script [Solved]
Moderator: leecollings
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Re: Hysteresis script
@EddyG
Perhaps more basic question to be answered before trying to find a control solution:
how do you determine lux level in the room?
And is that lux-reading sufficiently separated from the lamps' light?
Otherwise the risc of 'chicken-and-egg':
- if lamp-level is a dynamic reaction on room's lux-level, and the lux-sensor in some way reads the light of the lamps, then the risc that you get 'flip-flop'-action.
Myself solved this aspect by taking outdoor lightlevel as reference (not indoor), and 'gated' that reference using clock-time and a filter on the value:
- clock ( ~sunset and sunrise) as gate to suppress any on-switching while nominally still bright enough outside
[clock anyway needed to control automated off-switching]
- filter to suppress spikes and dips in the lux-value due to quick variations
Then hysteresis just becomes an add-on to set the upper and lower margin around the switching value.
Perhaps more basic question to be answered before trying to find a control solution:
how do you determine lux level in the room?
And is that lux-reading sufficiently separated from the lamps' light?
Otherwise the risc of 'chicken-and-egg':
- if lamp-level is a dynamic reaction on room's lux-level, and the lux-sensor in some way reads the light of the lamps, then the risc that you get 'flip-flop'-action.
Myself solved this aspect by taking outdoor lightlevel as reference (not indoor), and 'gated' that reference using clock-time and a filter on the value:
- clock ( ~sunset and sunrise) as gate to suppress any on-switching while nominally still bright enough outside
[clock anyway needed to control automated off-switching]
- filter to suppress spikes and dips in the lux-value due to quick variations
Then hysteresis just becomes an add-on to set the upper and lower margin around the switching value.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Re: Hysteresis script
I know that switching on lights have effect on the lux reading. I minimized that.
I am already partially using the outdoor lux to get a more 'stable' lux reading.
That's why I am looking for a "formula" of some kind to prevent the 'flip-flop', because there is always a threshold on which the dimTo() changes.
I am not using on/off bulbs, but bulbs with brightness setting.
I am already partially using the outdoor lux to get a more 'stable' lux reading.
That's why I am looking for a "formula" of some kind to prevent the 'flip-flop', because there is always a threshold on which the dimTo() changes.
I am not using on/off bulbs, but bulbs with brightness setting.
- waltervl
- Posts: 6692
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: Hysteresis script
See viewtopic.php?t=19956 were a hysteresis of 2% is used
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Re: Hysteresis script
Tnx, may be I could use parts of it.
I will keep testing....
I will keep testing....
Re: Hysteresis script [Solved]
Roughly found my 'formula'.
Most important I set my Zigbee bulbs with 'transition: 5'
That means that those bulbs go from X brightness to desired brightness in 5 seconds. That has a good influence on the 'flip flop' effect.
On other settings all kind of different factors might be used.
Code: Select all
LUXLEVEL = 50
local binnenlux = dz.devices(LUX_IN).lux
local buitenlux = dz.devices(LUX_OUT).lux / 100 -- lux is kind of logarithmic so divide by 100
local lux = ((binnenlux + buitenlux) / 2) + 1 -- prevent lux from 0 value
local brightness = (100/lux) + 8 -- add a minimum of 10% brightness
if brightness > 100 then
brightness = 100 -- max 100% brightness
end
if lux < LUXLEVEL then
dz.devices("<Device>").dimTo(brightness).silent()
//or
dz.devices("<Device>").dimTo(brightness/2).silent() -- 2 is factor to get 50% max. brightness
end
That means that those bulbs go from X brightness to desired brightness in 5 seconds. That has a good influence on the 'flip flop' effect.
On other settings all kind of different factors might be used.
Who is online
Users browsing this forum: No registered users and 1 guest