Are my rules correct? (IF statement)

Here is a tile build with Tile Builder. I post here because I think the error have nothing to see with this app.

Device "WC Suite AVG" is an average from both next sensors in screenshot.

1st problem: This sensor should show an arrow up as both sensors have this arrow up
2nd problem: when the values are updated, the arrow is not always in the correct direction.

I have 2 rules that update some hub variables to identify if temp or hum is going up or down. 2 variable for each sensor (1 for temp / 1 for hum).
One rule detect if temp/hum is increasing & one to detect when it's decreasing.
Someone can explain me what can be wrong? Or if there's a better way to do this?

My rules:



Looking at the conditions listed under the Manage Conditions section, in particular the fact that some of shown as Unused, including WC Suite AVG, I am thinking this may be part of your issue. I have seen some issues with copy and pasting of IF conditional blocks, given the quantity of the conditions, I am expecting you may have copy and pasted these.

Could you please:

  • Try removing and creating the conditional actions for these sensors in the rule to see if that changes the outcome?

  • Mention what platform version you are running

Depending on your sensors and their reporting frequency and thresholds, another thing to consider is that the temperature has to increase / decrease by more than .1 degree in one event, which may or may not be a factor for what you are seeing, but may be more of a general consideration for how the rule works. E.g. successive increases from 25.5 to 25.6, to 25.7, to 25.8 etc, would not trigger the rule, even though the temperature is increasing. Similarly, if the temperature changes were significant enough to trigger the rule, but came down slowly, the temperature would remain in the increasing direction, I expect.

Somewhat similar.... You may want to consider some more mathematical / statistical aspects of how this rule works. Using some kind of recent trend may be more appropriate, e.g. is the temperature increasing or decreasing over the last hour, for example. You may need to get creative for how best to do this, or their may be an app out there somewhere on the Community to help with this.

Both of these ideas would obviously apply to the humidity as well, being a change of > 1 percent.

Thank you
I deleted the unused conditions.
Changed triggers to in/decrease instead of in/decrease by xx

Platform Version :

I think there's a rounding case. Maybe triggers are using values with decimals and the actions rules are using the value that is rounded:

There's as well differences between different drivers. Some reports with one decimal, other with two + rounding. And temperature has always one decimal in the value, against humidity don't have decimals. Because of this, most problems are with humidity.
The humidity average app have as well a king of rounding that can generate different output.

It seems to me you don't need both of your triggers. If the amount increased or decreased by > 1 it definitely increased by > .1. If you want to do something different based on the amount of the increase you need to do that in rule with a conditional.

One of the triggers is for temperature > 0.1 and the other for humidity > 1.

Ahh that makes more sense. Misread it several times.

I know this isn't advice you sought in the OP, but if I were you, I'd break that monster rule into FOUR different rules:

  • One for Temps going UP (*increased*)
  • One for Temps going DOWN (*decreased*)
  • One for Hums going UP
  • One for Hums going DOWN

That way, you eliminate a lot of extra %device% and %text% testing and output formatting.

But if you really want everything done in a single instance, then WebCore might serve you better, since it offers CASE statements and free-form string manipulation.

Thank you all for your help.
After a clean-up of unused conditions and changed trigger basically to increased/decreased, my 2 rules are working well! :blush:
I have only one situation that is not perfect :

I use @bravenel averaging app for humidity and i think because of roundings between this app and rule machine, the direction of the arrow is not always coherent visually. Because mathematical, it's not wrong.


My sensors reports with one decimal in Description but the value row is without decimal. I don't know between rule machine and Bruce's app, which value is considered.