Thanks, make sense. I realized from a backup that I had previously solar into the triggers. So I don’t know, maybe I was tired. Thanks for your help, I’ll try to rework this and create two rules!
Global Moderators
Forum wide moderators
Posts
-
[MSR] Rule do not fire -
[MSR] Rule do not fireI'm not sure how I can help here. Your assessment seems correct. Like the other recent post, the displayed states here show the triggers going true substantially before the constraints did, so the constraints prevented the rule from SETting.
That seems like a logic issue. You need different approach, and I can't really gauge how you want this to work, and what the system limitations and risks are. That's knowledge only you can possess, at least not without a much lengthier explanation/q&a about what all this is meant to do, what you want it to do, etc.
I can, however, throw out some things based on assumptions (and because they are assumptions, they may be completely useless to your problem and not make any sense)... assuming two key goals: you don't want to start A/C unless solar power is high, and once A/C is running you want to keep it that way, at least for a while. You could move the solar power condition to triggers and latch it. To make sure A/C is stopped if solar drops too low, add a trigger condition requiring solar > whatever minimum, so you basically have solar >= ACthreshold (latched) AND solar > ACminimum in the triggers. If solar momentarily drops below threshold, the latch keeps the A/C running, but when it drops below minimum, that condition going false resets the latch (and presumably allows the A/C to turn off). Additionally, you could add a delay reset on the A/C, to enforce a minimum runtime. This is often recommended to avoid cycling compressors too often, but also helps make sure that the money you spent on the startup inrush gets some useful life. Be careful here, though, because you now introduce the possibility that the A/C could run when the solar is below minimum (held on by the time delay).
I will also repeat advice I've given previously... sometimes it is easier and, in fact, necessary to separate "turn on" and "turn off" logic into separate rules. I know there's a big temptation to use the SET and RESET reactions of a single rule, but it can make the triggers and constraints excessively complex to support. For example, I have a dehumidifier in my garage (where I live, my tools would rust every summer otherwise). Three garage doors, temperature, humidity, standby generator operation, and other large loads in the space are all considerations for both stop and start, but with varying logic. One aspect perhaps similar to your rule here, is that the dehumidifier isn't stopped when the garage door opens for a short period (e.g. a car pulls in or out of the garage), because of the wear on the compressor starting it, and brief periods of door open don't significantly drag on dehumidification, but long periods definitely do. I have one rule with just the start conditions, and those conditions include (a) the dehumidifier hasn't been running for at least ten minutes (prevent short cycling; it doesn't have smart controls), (b) the doors are all closed, (c) the humidity has been above threshold for 30 minutes (via a "sustained for" option on that condition). If those are met, the unit is started (via the SET reaction). In the rule with stop conditions that turns the unit off, the triggers are (a) dehumidifier has been on for at least five minutes, and (b) the start rule isn't SET (i.e. the conditions that call for it to be on are no longer met), also sustained for at least five minutes. SET reactions only; no RESET reactions. While the basic logic isn't complicated, it would be very difficult to get the independent timing of the two (on and off) processes to work in a single rule. By the way, I have a separate rule to detect if doors are open; I don't look at each individual entity in every rule, because...
More general advice to the community: many (most?) posts lately have had huge monolithic rules posted. I don't recommend it. I don't do this to myself, and I wrote the darned thing. I make liberal use of the Rule State condition and separate out chunks of logic into small, easy to define, easy to debug, easy to test condition-only (no reaction) rules that are tested by other (action-oriented) rules. Modular design. Using the overrides on the UI makes it easier to test, because you can SET and RESET your input rules at will and in any order. When devices fail or change, there are then a lot fewer rules to update. I always start with this approach on anything new. If I later find it's overkill for the task, I can always import the input (condition-only) rules into the action rule and get rid of them.
Again, just some thoughts/rambling without deeper knowledge of the task...
-
[MSR] Rule do not fireI have this rule that stopped working recently, I think with the latest update:
As you can see, all is true, but the rule stays reset. Resetting the rule does the work and the A/C starts. I think it's because the trigger window is true, while a specific constraint (power_solar >= 1800) is not true when the triggers are true. But I don't want to put this into triggers, since I want the A/C to stay ON after it started, even if we have rain or similar, because of the inertia to start it. Any hint is appreciated here @toggledbits. Thanks.
-
Rule condition shows TRUE in UI but Rule never transitions to SET — survives full restartIn the first image, the triggers show true as of 9:42:09. The constraints show true 10 seconds later. That's a not pass. The constraints have to be true at the instant the triggers are also true (or before), or the rule does not SET. If the constraints become true later, that doesn't matter, the rule does not SET.
Your third image shows the same. Triggers true at 10:31:53, but constraints didn't go true until 10:32:12 (19 seconds later).
From the docs:
-
DynamicGroupController and attributesThis is now available in build 26242. The config has changed slightly, so review the final documentation for correct usage and examples.
-
Reactor (Multi-System/Multi-Hub) Announcements -
Rule condition shows TRUE in UI but Rule never transitions to SET — survives full restartA couple of things here...
- Editing the rule will cause re-evaluation, which is likely why you have repeated RESETs in the history with no SETs between.
- As hard as I try, and I keep looking, finding, and fixing, the UI can get out of sync with the running engine/service, so always hard-refresh when the UI isn't making sense.
- If a Rule has been edited, especially multiple times, and it's not performing as expected, reset the Rule. There's button for that:
Even restarting Reactor doesn't do what this button does. - Beyond that, it would also be handy to see the top part of the screen shot that has been cut off (the Triggers group heading and stuff above it).
-
Ooops - Deleted Reactor Ex Machina IINo backup? Restore from backup (recommended) is the best way, of course.
Beyond that, recreating it should not be difficult, but there have been key changes since that original post. Some detail beyond "did not work" is necessary here. Show your work and tell us about your environment.
-
DynamicGroupController and attributesThis sounds really complete. I’ll give it a try when available.
-
DynamicGroupController and attributesHere are the docs for what I have built thus far. Comments and suggestions on functionality appreciated!
Custom Attributes
In addition to setting the primary attribute for a dynamic group, users may add custom attributes to the group. The values of these custom attributes are typically derived from attribute values of the group's members. For example, a group of temperature sensors can have a calculated average of the readings of all the sensors.
Custom attributes are defined under the
calculate:object in a group's configuration. Here's a possible configuration for the example given above as a group with IDtemp_sensors. Theselectconfiguration simply selects all entities having thetemperature_sensorcapability, for illustration purposes (in practice, we'd probably want toinclude_entitysome specific entities for this purpose).temp_sensors: select: - include_capability: temperature_sensor calculate: - attribute: 'temperature_sensor.value' source: attribute: temperature_sensor.value # Where to get data values op: averageThis is the most basic form of custom attribute configuration. The
calculateobject is an array of configuration objects. Theattributekey is required for each array element and specifies the attribute to be defined and calculated on the group. Thesourcesubstructure tells DynamicGroupController what attributes on the member entities should be used for calculation. Any member entity that does not have the specified source attribute, or for which the attribute's value is null, is simply ignored. Theoptells DGC how to reduce (or aggregate) the multiple values from the member entities down to a single value. Pre-defined operations foropare defined below:opType Description average,avg,meannumeric The average (arithmetic mean) of the available values. mediannumeric The median of the available values (i.e. the middle value of the values when sorted). min,maxnumeric The minimum or maximum of the available values. sumnumeric The sum of the available values. countnumeric Count of non-null values. and,nandboolean Logical AND of available values. All values must be boolean true for the result to be true. If nandis used, the result is inverted (i.e. false when all values are true)or,norboolean Logical OR of available values. If any value is true, the result is true. norinverts the results (false when any value is true)xor,xnorboolean Logical XOR. Since more than two values may be considered, this operation is only true when exactly one of the values is true. If multiple are true, or all are false, the result is false. The xnorinverts the result.firststring Given a string or an array of strings to match in a valuekey (at the same level asop), this operation returns the first matching value. That is, each element ofvalueis checked to see if it matches asourcevalue from any of the group's member entities; if so, that element/value is the result; if not, the test moves on to the next element. If no match, null results.!!! note "null Member Attribute Values"
All of the above operations ignore null values from thesource, unless otherwise indicated.There may be circumstances where the
sourcevalues require some pre-conditioning or filtering. This is enabled by thevalue_exprsubkey undersource. The result of the expression is the value that will be added to the array of values foroporreduce_expr. For example, in our temperature sensor group, some of the sensors return temperatures in Celsius, and others in Fahrenheit. We can usevalue_exprto convert the values to a consistent unit, so that the resulting reduction operation yields a consistent value in that same unit:temp_sensors: select: - include_capability: temperature_sensor calculate: - attribute: 'temperature_sensor.value' source: attribute: temperature_sensor.value # Where to get data values # Convert Celsius temperatures to Fahrenheight value_expr: > local units = entity.attributes.temperature_sensor.units; local d = ( units === 'C' || units === '°C' ) ? value * 1.8 + 32 : value; ( d <= 0 || indexOf( ['C','F','°C','°F'], units ) < 0 ) ? null : d op: average prec: 2 # two decimal digit max resultStep by step, the
value_exprabove first fetches the member entity's temperature units into a local variable calledunits. Since theattributeundersourceistemperature_sensor.value, the context variablevaluewill contain the raw value from that attribute. The second line of the expression then checks if the units are Celsius, and if so, converts them to Fahrenheit (if units are not Celsius, it just takes the currentvalue) and assigns it to a local variabled. Finally (third line of the expression), if the value is in range and the units are known, the value ofdis returned, otherwise null. As stated above, most of the predefined operations ignore null values in their computation. Sovalue_exprcan function both to condition values and to filter them.The
preckey allows you to define the number of decimal digits precision for the result value; the result is rounded to comply. For example, a calculated value of 3.14159265 withprec: 4results in 3.1416.If none of the pre-defined operations addresses the need, the
op:key can be replaced with an expression defined byreduce_expr:. The result value of the expression will be the value assigned to the custom attribute. The context forreduce_exprincludes the following variables:grouprefers to the group entity being defined;membersis an array of canonical IDs of the member entities at the time of evaluation (which may change in a truly dynamic group); andvaluesis an array of the member values (as derived fromsource).temp_sensors: select: - include_capability: temperature_sensor calculate: - attribute: 'temperature_sensor.value' source: attribute: temperature_sensor.value # Where to get data values # Compute harmonic mean (not predefined) using expression (trivialized for illustration) reduce_expr: > local s = 0; each v of values: do s = s + (1.0 / v) done; len(values) / s prec: 2 # two decimal digit max resultFinally, custom attributes that should have fixed values can be defined by simply supplying
value:undersource:, like this:- attribute: 'temperature_sensor.units' source: value: '°F'Make sure the data type of the
valueconfigured matches the expected type of attribute being defined.

