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
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.