fan-controller
Description
The fan-controller block is used to control a bathroom fan based on the light state, commands from the command block, and an optional humidity measurement.
The fan is on when at least one of the following sources is active:
- the light has been on long enough and the start delay time has elapsed,
- the switch-off delay time is still running after the light has been turned off,
- the
setcommand from thecommandblock, issued while the light was off, is still active, - the humidity has reached or exceeded the configured threshold.
The reset command from the command block turns the fan off immediately. Additionally, it can temporarily block reactivation from the light and humidity according to the input handling rules described below.
Configuration parameters
| Parameter name | Value |
|---|---|
Name (name) |
Name displayed on the block in the editor. |
Light-on delay time (s) (light_on_delay_time) |
Required parameter that defines the fan start delay after the light is turned on. The value is given in seconds. The allowed range is from 0 to 64800 seconds, that is from 0 s to 18 hours, with a step of 0.1 s. Examples: 2 means 2 s, and 10.5 means 10.5 s. |
Light-off delay time (s) (light_off_delay_time) |
Required parameter that defines the fan switch-off delay after the light is turned off. The value is given in seconds. The allowed range is from 0 to 64800 seconds, that is from 0 s to 18 hours, with a step of 0.1 s. Examples: 2 means 2 s, and 10.5 means 10.5 s. |
Enable humidity control (humidity_enabled) |
Required boolean parameter that determines whether the block should react to humidity measurements. |
Humidity threshold (%) (humidity_threshold) |
This field is visible and required when “Enable humidity control” is checked. It defines the humidity threshold for turning the fan on. Allowed values are from 1 to 99 percent. When “Enable humidity control” is false, this parameter is ignored. |
Input handling
The block has one input and recognizes several data types:
- The boolean value true means the light has been turned on.
- The boolean value false means the light has been turned off.
- A numeric value in the 0..100 range means the current humidity level in percent. If the input value has a fractional part, the fractional part is truncated before further processing.
- The
setcommand from thecommandblock means the fan should be turned on immediately. - The
resetcommand from thecommandblock means the fan should be turned off immediately.
Behavior details:
- After the light is turned on, the block starts counting “Light-on delay time (s)”. If the light is turned off before that time elapses, the pending start is canceled.
- After the light is turned off, the block starts counting “Light-off delay time (s)”, but only if the light source had previously actually activated the fan or the fan was forced by the
setcommand from thecommandblock while the light was on. - If the light is turned on again while “Light-off delay time (s)” is active, the fan does not turn off and “Light-on delay time (s)” is not started again. The block treats this situation as if the light had never been turned off, and the active off-delay is immediately replaced by the active light source.
- The
setcommand from thecommandblock while the light is on activates the fan immediately without starting the switch-off delay. If the light was already an active source of fan operation, the command is ignored. - The
setcommand from thecommandblock while the light is off starts the fan for “Light-off delay time (s)”. If this time was already being counted, it is reset and started again. If the light is later turned on during this time, the light source immediately takes over fan operation without waiting for “Light-on delay time (s)”. - If “Enable humidity control” is true, humidity greater than or equal to “Humidity threshold (%)” activates the fan immediately, without any start delay.
- The
resetcommand from thecommandblock turns the fan off and cancels active timers. If the light is on at the moment of reset, the light logic remains blocked until the light is turned off and then turned on again. - The
resetcommand from thecommandblock while humidity-based activation is active also blocks reactivation from humidity until the reading drops below “Humidity threshold (%)”.
The block does not require the use of inputs marked using the tag block.
Block outputs
| Output number and name | Output description |
|---|---|
| 1. Fan operating status. | Returns true when the fan is active, or false when the fan is off. |
Errors returned by the block
The block can return the following errors:
| Error code | Error description |
|---|---|
Invalid light_on_delay_time configuration. |
The “Light-on delay time (s)” parameter has an invalid value or was not provided. |
Invalid light_off_delay_time configuration. |
The “Light-off delay time (s)” parameter has an invalid value or was not provided. |
Invalid humidity_enabled configuration. |
The “Enable humidity control” parameter has an invalid value or was not provided. |
Invalid humidity_threshold configuration. |
The “Humidity threshold (%)” parameter has an invalid value when humidity control is enabled. |