Quick Bathroom Fan Humidity Switch Control

Thanks! The check config keeps pointing out I need to add a platform:. So I’ve tried: running, sensor, bath_room etc. But it keep saying: Platform error binary_sensor.Fan - Integration ‘Fan’ not found.
I can’t figure out how to move on…

Post your whole code snippet

sensor:
  - platform: statistics
    name: Bathroom Humidity Average Linear 24h
    entity_id: sensor.badkamer_ventilator_am2301_humidity
    state_characteristic: average_linear
    max_age:
      hours: 24

binary_sensor:
  - platform: running
    bath_fan_sb:
      friendly_name: Bathroom Fan S/B Status
      value_template: >-
        {% set humid = states('sensor.badkamer_ventilator_am2301_humidity')|int(default=0) %}
        {% set avg = states('sensor.bathroom_humidity_average_linear_24h')|int(default=0) %}
        {% set thresh = 5 %}
        {{ (humid - avg) > thresh }}

This platform does not exist. So HA does not know what to do.

Looks like this binary sensor is a template? If so please follow the template document, and I cite jerrm in post #25:

Okay, completely lost you. If it’s supposed to be a template, why does the original author didn’t mention this? Don’t know how to convert from original setup to template. :disappointed_relieved:

I happened to post my codes the other day.

Thank you very much! I implement it in my configuration.yaml now without any errors. Hopefully it works. Much appreciated!

I’m having issues with this portion of the automation. Can you clear this up for me? Saying “String does not match pattern of deprecated.” Thanks!

Can you post your code for this? Just checked my automation and it’s showing the same as you’ve quoted above.

When I trace the last execution of the automation, here’s part of the ‘changed variables’ section that is being leveraged between the {{ }}

image

I’m actually having more issues than I thought. Here is my configuration code. Once I get this figured out, I’ll try the automation again. I’m very new to home assistant and have only done basic stuff so far. Very likely that it’s a simple mistake. Thanks for the help.

Any ideas what’s wrong with my config for this stuff?

you shouldn’t post screen shots of code. Post text and be sure it’s properly formatted using ``` before and after the code block.

but from looking at the code you need to use lower case letters for the various domain keys. And no spaces:

binary_sensor:
.
.
statistics_sensor:
.
.
etc

Agree that posting actual code using 3 `s is far better than a screenshot.

I do see that your binary sensor indentation is off - first line should not be same ‘depth’ as the 2nd and 3rd. Also depends on how / where you’re configuring these - w/in configuration.yaml or if you’re using (as I am) separate files referenced via includes within configuration.yaml:

automation: !include automations.yaml
binary_sensor: !include sensor_binary.yaml
input_number: !include input_number.yaml
sensor: !include sensors.yaml

Certainly realize some of this configuration can be foreign when first starting - but worth learning the building blocks - will help tremendously as you become more addicted :slight_smile:

i have some trouble with the average value over the past 24h, my sensor isn’t reporting every 1 or 2 minutes it’s a zigbee device, so my avg value rises rapedly when there is moister. such vast that the treshold value never occured.

How could i solve this, i would like to test it to a value from let’s say 1 or 2 hours ago.

1 Like

is it a typo that you put sensor.sensor in the attributes section of your code?

attributes:
Hall: >
{{ states(‘sensor.main_hall_relative_humidity’) }}
Bath: >
{{ states(‘sensor.sensor.master_bath_humidity’) }}

No, but it’s optional.

The attributes expose the underlying values for easy view when drilling down on the Net sensor and easy access for automations in the trigger from_state and to_state properties.

Thanks, but I was specifically meaning how the last part of the code snipped says:

sensor.sensor.master_bath_humidity

Shouldn’t it be

sensor.master_bath_humidity ?

Sorry, you’re correct. I usually try and cut/paste working code. Something went sideways.

EDIT: Original post corrected, and updated with an availability clause.

Controlling fan based on bathroom humidity (regardless you use smart fan, smart relay or something like Switchbot Bot) is a good idea. However, I’d set the target humidity in a different way. I see no reason to set it by history. There are several objectives:

  1. Healthy humidity in space where you usually are (usually recommended: 40% – 60%; some recommend just 55% for summer).
  2. Reducing mold risk – the ranges can be somewhat higher, but if you have something like 23°C or more, the threshold is something like 65%. When your sensor is not directly above bath, maybe you will want to lower the threshold, even to something like 60 % or less. (I’ve written something about desired humidity at How do you care about humidity - #2 by v6ak .)

So, when you have something like 30% humidity on average, it doesn’t make much sense to achieve this low value after bathing.

Thanks for posting this, managed to get it created in HA but I’m not sure if there is an issue as it seems to be showing as always on, is that normal behaviour?

It didn’t trigger a change when the shower was on this morning