Skip to content

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 set command from the command block, 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 set command from the command block means the fan should be turned on immediately.
  • The reset command from the command block 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 the set command from the command block while the light was on.
  • If the light is turned on again while light_off_delay_time is active, the fan does not turn off and light_on_delay_time 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 set command from the command block 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 set command from the command block while the light is off starts the fan for light_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 for light_on_delay_time.
  • If humidity_enabled is true, humidity greater than or equal to humidity_threshold activates the fan immediately, without any start delay.
  • The reset command from the command block 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 reset command from the command block 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 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.