Entities - where used and what triggered it
-
Haven't payed attention to the development for a while (and it seems to be progressing fast), is there a way to see where an entity is used, and what action used it recently?
If not, it would be nice to have when things happen when they shouldn't, wether its because of bugs or bad logic.
-
toggledbitswrote on Mar 30, 2021, 12:20 PM last edited by toggledbits Mar 30, 2021, 8:33 AM
At the moment, if you turn the logging level for the "Rule" class (see more below) to 5 or higher (but 5 is enough), rules will log dependency notifications (entities or other data changing that cause them to re-evaluate). Looks like this (scroll to see the first line, in particular):
2021-03-29T12:04:39.753Z <Rule:5:Rule.js:448> Rule#rule-grpy8wi802 requesting eval; entity-changed Entity#house>device_376 2021-03-29T12:04:39.753Z <Rule:5:Rule.js:768> Rule#rule-grpy8wi802 (Dehumidifier Off) evaluate() acquiring mutex 2021-03-29T12:04:39.753Z <Rule:5:Rule.js:774> Rule#rule-grpy8wi802._evaluate() mutex acquired, evaluating 2021-03-29T12:04:39.753Z <Rule:5:Rule.js:782> Rule#rule-grpy8wi802 update rate is 3/min limit 60/min 2021-03-29T12:04:39.753Z <Rule:5:Rule.js:627> Rule#rule-grpy8wi802 evaluateExpressions() with 0 expressions 2021-03-29T12:04:39.753Z <Rule:5:Rule.js:810> Rule#rule-grpy8wi802._evaluate() trigger state now false (was false)
In all likelihood, the logging of a changing entity starting a rule evaluation is going to get promoted to "info" level (4) and be a visible message in a default configuration (without changing log levels). But, as I'm working in the background on status tab info and trouble alerts, I'm experimenting with a more comprehensive way of reporting this on the UI. But this is what it is for now.
For reactions, at the moment all actions against entities are logged unconditionally. That looks like this (notice the
Engine:null
entry and the line fromVeraController
that follows):2021-03-30T12:01:18.245Z <Engine:INFO> Enqueueing "Pump Run Conditions<RESET>" (rule-grpjx0sdf8:R) 2021-03-30T12:01:18.245Z <Engine:NOTICE> Starting reaction Pump Run Conditions<RESET> [RuleReaction#rule-grpjx0sdf8:R] 2021-03-30T12:01:18.245Z <Engine:null> _resume_reaction() entity house>device_373 (Recirc Pump Switch) perform power_switch.off({ } ) 2021-03-30T12:01:18.246Z <VeraController:null> VeraController#house enqueue task for Entity#house>device_373 action power_switch.off : task { "newTargetValue": "0", "DeviceNum": 373, "id": "action", "serviceId": "urn:upnp-org:serviceId:SwitchPower1", "action": "Set Target" } 2021-03-30T12:01:18.426Z <Engine:NOTICE> Resuming reaction Pump Run Conditions<RESET> from step 1 2021-03-30T12:01:18.426Z <Engine:INFO> Pump Run Conditions<RESET> all actions completed.
This does not require a change in the logging level for the
Engine
class (that runs reactions) right now. In future, it will also get a level 5 requirement, but, there already exists amonitored_entities
in which you can place an array of (canonical) entity IDs for which the system will log all actions performed regardless of source (so by rule reaction, global reaction, or user action from the UI).reactor: baseurl: ... your other top-level configuration stuff engine: # this line indented two spaces monitored_entities: - hass>light_test_dimmer_73 - vera>device_10 - hubitat>1 - vera>device_254
Changing Log Levels
Logging is controlled by configuration in
logging.yaml
. Every object in the system can be logged either through its parent class or by individual object, so you can set a logging level for all rules, or for just one particular rule you are interested in. The structure of the file should be clear from the example indist-config/logging.yaml
.- Rule #1: do not under any circumstances change the "default" logging level at the top of
logging.yaml
. - Class- or object-based logging level can be changed by either modifying the
level
below the listed class or object, if it's already in the file. If it's not, add a class by indenting the class name with two space and following with a colon, and then on the following line addlevel:
indented four spaces and your level (see example below). To add a specific object, such as a single rule, use the ID found in the UI status display and add it. And example of each is shown below:
Rule: # this line is indented TWO spaces level: 5 # this line is indented FOUR spaces Rule#rule-kvjw8634: level: 6
You can later return the log level to the default (4) or remove the entry entirely. If you set log levels high, remember to set them back down after troubleshooting or you'll be logging a lot of unnecessary data.
More info on Logging here: https://reactor.toggledbits.com/docs/Logging/
- Rule #1: do not under any circumstances change the "default" logging level at the top of
-
Ok, that will work. Thanks.
Would be good to have a "quick look" somewhere in the UI though, specifically where reactor performs an action, not for all evaluations or change notifications.
The usual scenario is that some light is turned off when it shouldn't, and i need to know what turned it off. (may not have been reactor at all)
I.e a list of the 5 latest actions done on the entity at the bottom of the entity status list? with date/time and rule/reaction name? -
Yup, coming. For now, check the logs.
-
I could use this "Where Used" feature as well. I have 3 Global Expressions that I don't think I have using, but want to make sure before I nuke them. I did not change my logging levels, but did search through all the reactor.log files and do not see anything. Is there a different way to see if they are in use, other than killing them and seeing what breaks?
-
-