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 |
|---|---|
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 |
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. |
humidity_enabled |
Required boolean parameter that determines whether the block should react to humidity measurements. |
humidity_threshold |
Required only when humidity_enabled is true. It defines the humidity threshold for turning the fan on. Allowed values are from 1 to 99 percent. When humidity_enabled 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. 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, but only if the light source had previously actually activated the fan or the fan was forced by thesetcommand from thecommandblock while the light was on. - If the light is turned on again while
light_off_delay_timeis active, the fan does not turn off andlight_on_delay_timeis 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 forlight_off_delay_time. 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 forlight_on_delay_time. - If
humidity_enabledis true, humidity greater than or equal tohumidity_thresholdactivates 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 belowhumidity_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 parameter has an invalid value or was not provided. |
Invalid light_off_delay_time configuration. |
The light_off_delay_time parameter has an invalid value or was not provided. |
Invalid humidity_enabled configuration. |
The humidity_enabled 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. |