Humidity control using unifi environment sensor and Tapo plug for dehumidifier

Unifi sensor is reporting to Home assistant and the Tapo plug is controllable from home assistant.
The automation that I have written does not seem to function. Trigger being humidity change with high and low limits action being toggle Tapo plug.

Share said automation.

I can take a guess, but you will get better answers if you post your properly formatted (</>) YAML. Automations #1: trigger only fires when it changes from not true to true


Yes I understand but was unable to find a function that would hold the trigger. My 1st foray into HA so learning. Thanks for yr help

If the sensor value is between 50 and 59 (or above 59 or below 50) there will be no triggers. The sensor value has to pass thru the limit to generate a trigger, as my link states. So if you are not getting a trigger but think you should, that could be the reason.

Humidity is currently 60

The automation state reads as ON and has been that way since below target to above target as now. Even though the automation state is on the plug is OFF

When I click "run actions" in the automation it does turn it on it just doesn't happen automatically

Depending how frequently the polling or reporting of the humidity happens, your action "toggles" the switch, meaning it'll turn it the opposite of what it is currently. You might be flip-flopping your switch. You should enhance your action to also check if the humidifier is off, and only explicitly turn it on. Create a second automation to turn off when it's below your set point. You could get advanced and combine them into a single automation, but as you're starting out, split it into two.

If it runs properly when manually triggered, check traces to see when your sensor reports the humidity level. This is an event driven action, and if no event happens, then your automation won't run even if the conditions are met.

Thanks . there is no option for that in the sensor only a change with a high and low reading ie a dead point between high and low

What @Sir_Goodenough mentioned also is important (and I should have read his comment before providing my info) - the event will only fire the first time it crosses the barrier. So when the humidity goes below 50, or above 59, it will fire your action - but it will only do so once. If it stays below 50 and above 59, it won't re-trigger, nor will it trigger if the humidity goes back to 50-59 range to cause it to turn off.

You may want to alternatively look at setting up a generic hygrostat in HA. It is like creating a generic thermostat for your humidifier. You would use your humidity sensing device as the sensor that will provide humidity levels, and then you configure the switch as your humidifier. From there you can configure the range you want it to be on/off and other settings. It may be much more intuitive than trying to use automations. Generic hygrostat - Home Assistant

I can’t figure out how to post my yaml. Just shows up all scrambled. Hold. I posted screenshots.

I have mine turn on at 50% then off at 48%. I also make sure the windows in that area are closed before it turns on. I’ve dehumidified the outside too many times now so I added that recently.

Above 50 is 1 trigger with a trigger id Above 50
Below 48 is 1 trigger with a trigger id Below 48





Not getting any further with this. It is my 1st automation so I may have done something wrong. Automation does work when manually triggered. but does absolutely nothing when left to be automatic.I have tried a separate on and off as well as the Unifi one shown without any success. Humidity displays correctly. Need to go through it from the very beginning I think

As you have it now, it says toggle the switch when the humidity is both above 60 and below 50. That can’t be true at the same time. So it will never run. As it can’t be both 61% and 49% at the same time.

Make a new automation that says when it’s above 60%, turn ON the switch

And then another new automation that says when it’s below 50, turn off the switch.

Manually running an automation isn’t a good test to see if it works. Because in this case, when you manually run it, it says ok, he believes this needs to run and jumps straight to the actions. It doesn’t stop to verify the triggers. You pressing Run, was what triggered the automation so it will simply just run the actions.

1 Like

I would suggest you try using a generic hygrostat helper instead. I have a feeling it will be far easier for you to understand and configure properly.

1 Like

firstly the trigger parameters are what is asked for by home assistant so I simply fill in the high, low and time. toggling a switch means literally that. change the state each time a trigger is activated. I can see problems with this potentially but HA does not give me any other options! I have also tried 2 separate automatons with no success. I am now looking at "state change flattening" ie the fact the unifi humidity sensor spends a lot of time asleep and therefore jumps past the triggers. So I am now looking at "state" rather than "numerical value" Not a lot of point having HA help write automations that don't work!

This, far better. Also handles the case of the sensor going offline / failing.

Time is optional & you can leave it blank. For the Above & Below, only 1 is required - the other is optional, plus you got them the wrong way round. As explained by @Jl55412, a single trigger can't possibly be both above: 60 & below: 50 - it either needs to be above: 50 & below: 60, or else you need to use 2 triggers.

HA will definitely give you other options - you just need to learn how to set up automations. Use 2 separate triggers (1 for above & another for below) & give each of them a Trigger ID. Set up a Choose Action based on the trigger ID & have it turn on the plug when it's above 60 & turn off when it's below 50.
Alternatively, try doing separate automations again. It should work just fine if you use one with only the above & another with only the below.

This behaviour won't affect numerical states if you use separate triggers. In fact, that's exactly what they're designed to do. State, on the other hand, requires an exact match & will cause you further headaches. Stick to numerical states or get a sensor which doesn't sleep as much.

Automations are only as good as the person who writes them. I suggest you read the automation docs I linked above and to familiarise yourself with how they work.

Thank you everybody I now have it working with 2 separate automations, However there are some conflicts between peoples advise to use numeric or state values. My issue is that as a 1st time user of HA which I was advised to buy because it had a built in integration for UNIFI and Indeed TAPO I got this:


Completing it intuitively ie above 60 and below 50 gives a result that does not work. Swapping the figures around does not work either. So in this case the system designed to help people who can't or don't want to edit in YAML does not work. I did not write the non working automation HA did it for me