Before I start, because I’m a new user I’m only permitted to embed one image. I have replaced some images with links, others I had to remove. See comments below.
I have a Brink Renovent HR/Medium heat recovery unit that has three different fan speeds. After a house renovation I no longer had room for the bulky wired switch that could be used to select the fan speed. The manual showed that instead of the switch (connected to a perilex wall-outlet) the unit could also be switched using three wires that are connected to the unit using a simple RJ11 connector. (See X4-3, X4-5 and X4-6).
I bridged and removed the old switch so the unit was still functioning. I used one Shelly 1 switch to connect X4-3 to X4-5, and one to connect X4-3 to X4-6. See contacts 0 and I in this image. The Shellys are powered with 230V. The SW contact was not used. When both Shellys are off the unit is set to fan speed 1, when X4-3 to X4-5 is closed the unit is set to fan speed 2 and when X4-3 to X4-6 is closed it operates at fan speed 3. I would rather have used a Shelly 2.5 , but since it’s switch contacts are not isolated from the mains, that was not possible.
Because switching them on using the Shelly app, which works quite good, is something I tend to forget I decided to create an Automation for fan speed 2. Fan speed 2 is active from 0700 in the morning to 2300 in the evening.
For fan speed 3 I was looking for something a bit more intelligent. Fan speed 3 is useful e.g. when someone is using the shower or taking a bath. I added a Shelly Humidity and Temperature (H&T) unit with a USB power supply to my setup and spent a few days looking at the humidity readings of the bathroom. It’s very important to set the CoIoT peer as described in https://www.home-assistant.io/integrations/shelly/.
I was looking for foolproof triggers to switch fan speed 3 on and off. I decided that using the humidity value itself as input was not very useful, because humidity tends to vary a lot in a day and over the days. It’s not a very accurate indication of someone using a lot of hot water in the bathroom and it proved difficult to find a reasonable threshold value.
I ended up using the Home Assistant Derivative platform, because it always signals an increase when the bathroom is used.
sensor: - platform: derivative source: sensor.sensor_badkamer_humidity name: Humidity derived unit_time: min time_window: "00:05:00"
I created an automation that turns on the fan speed 3 switch when the derivative reached a value higher than 1 (emperically established value). I created another automation to switch it off again when the derivative reached a value lower than -0.2, with a delay of 10 minutes. It turned out that this automation was sometimes triggered just before the automation that turns the switch on, which resulted in a premature switch off. The on automation therefore kills the off automation to prevent triggers from 5 minutes ago from shortening the automation on duration. After a brief delay the off automation is reenabled.
alias: Ventilation Bathroom On description: '' trigger: - platform: numeric_state entity_id: sensor.humidity_derived above: '1' condition:  action: - type: turn_on device_id: hidden entity_id: switch.ventilatie_stand_3 domain: switch - service: automation.turn_off target: entity_id: automation.ventilation_bathroom_off - delay: hours: 0 minutes: 0 seconds: 30 milliseconds: 0 - service: automation.turn_on target: entity_id: automation.ventilation_bathroom_off mode: single
alias: Ventilation Bathroom Off description: '' trigger: - platform: numeric_state entity_id: sensor.humidity_derived below: '-0.2' condition:  action: - delay: minutes: 10 - type: turn_off device_id: 35c16770069531bb893af11feed6f368 entity_id: switch.ventilatie_stand_3 domain: switch mode: parallel max: 4
I’ll try to add a picture of how the Shellys are wired. I used their own packing material and a sealable container to protect them from dust. They do not seem to be getting very hot, even when in a closed container.