Need a little help with setting up my first binary sensor

Am looking to set up a binary sensor based on the state of the Aqara humidity sensor that I have, with a view to turning on an extractor fan when humidity is above 72% and turning it off when it is below that figure. The fan power switch and aqara sensor are already installed and visible in HA

I asked the AI bot on how to do this;

 `To set up a humidity sensor as a binary sensor in Home Assistant, you will need to follow these steps:`

1. `Install the humidity sensor according to the manufacturer's instructions. Make sure that the sensor is properly calibrated and functioning correctly.`
2. `Configure the sensor in the Home Assistant configuration file (usually configuration.yaml`  
`). You will need to specify the sensor's platform, name, and any other relevant parameters. Here is an example configuration for a humidity sensor using the sensor`  
 `platform:`

`Copy code`

    sensor:
      - platform: sensor
        name: Humidity Sensor
        unit_of_measurement: %
        device_class: humidity
        icon: mdi:water-percent
        sensor_type: humidity
        device_id: 0x12345678
1. `Add the humidity sensor to your Home Assistant frontend by creating a new entity in the appropriate Lovelace dashboard.`
2. `Create a binary sensor in Home Assistant by using the binary_sensor`  
 `platform in the configuration file. You will need to specify the sensor's name, device class, and any other relevant parameters. Here is an example configuration for a binary sensor that is triggered when the humidity level exceeds a certain threshold:`

`Copy code`

    binary_sensor:
      - platform: template
        sensors:
          humidity_too_high:
            friendly_name: "Humidity Too High"
            value_template: "{{ states.sensor.humidity_sensor.state | float > 72 }}"
            device_class: moisture
  1. Add the binary sensor to your Home Assistant frontend by creating a new entity in the appropriate Lovelace dashboard.

I’m a little unsure on how to go about this, I’ve done some googling but cant find any direct examples so don’t know where to start really. I’ve gone into Dev Tools and then States and for my sensor I have the following;

sensor.lumi_lumi_weather_humidity

questions:

Do I need to amend these values and headings with what the code above says, or will that break it and I need to add another one? If another one, does it get appended to the above or do I need to crate an entire new one somehow? Or is Step 2 not needed because the sensor is already configured, and I just need to do the binary sensor part with the correct values?

I notice that the first details that the bot gave me says humidity but the second one says moisture - is that an error or is this to differentiate from the original settings?

Is there any good resource to walk through doing these step by step? For now I’d appreciate if someone can advise me what I need to do so I can figure it out from the changes, as I learn best that way, but would also like to learn it properly so that I can work my way through these easier.

At the risk of hurting the feelings of the AI bot, I would suggest that you are being led in the wrong direction.

I think you need a Threshold Helper. You can find details here:

Threshold Helper

You can then use the changing state of this to trigger an automation.

You don’t necessarily need this though. An automation with a numeric state trigger may be enough.

Thanks, I will take a look.

the problem with numeric state, at least from what I understand from numerous postings on here and reddit with people trying to trouble shoot, is where the automaton is triggered where the value already exceeds the value in numeric state, same with using the sensors standard output. So if HA reboots, or another automation turns it off (for example motion sensor routine times out because you’re chilling in the bath) then it wont turn it back on because humidity is already above 72%

Maybe this would work:

description: ""
mode: single
trigger:
  - platform: numeric_state
    entity_id: sensor.bathroom_temperature_humidity
condition: []
action:
  - if:
      - condition: numeric_state
        entity_id: sensor.bathroom_temperature_humidity
        above: 72
    then:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.kitchen_extractor_fan_boost_switch
    else:
      - service: switch.turn_off
        data: {}
        target:
          entity_id: switch.kitchen_extractor_fan_boost_switch