I have an AirGradient AQ sensor that has entities for CO2 and PM2.5 those values show up in states as numbers like ‘439’ and ‘0’ respectively. I tried to make an automation to trigger different fan speeds based on these numbers. But when I do a “test” of conditions they are always not met regardless of the numbers associated with the sensors. I really am at a loss as to why this isn’t working the way I expect. Here’s my YAML:
In the automation, I click on the Three Dots on the condition and choose the option “Test” from the dropdown. This is a way I would test a condition in a lighting automation, or whatever. In this AQ/fan automation it always returns an orange “Condition did not pass” banner, even when (as far as I can tell) the conditions are met.
That test is inconclusive because it’s attempting to test a Trigger Condition.
A Trigger Condition only works after the automation has been triggered because the trigger id value is created only when triggered. If there’s no trigger, id has no value.
tl;dr
You can’t use that Test feature for a Trigger Condition.
The only way to properly test your automation is to wait until one of its six triggers is triggered. Then you can examine the automation’s trace to see how it processed each step.
If you don’t want to wait for a sensor’s value to change and cause triggering, you can manually “force” the sensor’s value to be whatever you want. I described the procedure to another user in this post:
Ok…I think I understand. The conditions don’t check to see if a value is true, they just get triggered when a value changes.
So if I go breathe on the sensor for minute the CO2 will raise above a threshold vale, triggering the condition and the fans will kick on/up. Then as CO2 levels drop it will trigger the option that turns the fans back down.
Is there a way to make it test? My trouble here is in the returning to normal portion because I want both CO2 and PM2.5 to be low so that trigger has an AND instead of an OR. But if CO2 only went up and triggered higher fan speeds when CO2 comes down it won’t trigger lowering the speed because PM2.5 stayed zero all along.
Even if the fans don’t come on, you should be able to see in the traces if the ‘choose conditions’ were evaluated as true or false.
Keep in mind that the trigger values need to pass the threshold - if they are above it already nothing will happen,
You can manually set (“force”) the sensor values to whatever you want as described in the link I shared in my previous post.
The sensor values you set manually are temporary and will be (eventually) overwritten by the sensor’s integration. How quickly it’s overwritten depends on how frequently the integration updates the sensor.
Manually changing a sensor’s value is the easiest way to test a trigger (easier than breathing on a CO2 sensor or warming a temperature sensor, etc).
As the conditions are evaluated as AND this will check, if both values - CO2 and PM2.5 - are in the normal range before it moves on to execute the sequence.
If only one of them is, it will ‘wait’ until it’s triggered again by the other one.