Create Expression to call out Entity ID of Tripped Binary Sensor
-
-
You're right... it is almost the exact same expression... almost. (I'm teaching here... look closely at the one the works, and the one that doesn't).
-
Hi @Pabla
I'm sorry if I'm saying something wrong and out of the context of this discussion, but I'll put what I have that seems to be what you are looking for, using DynamicGroupController, which was an excellent feature that @toggledbits implemented.
config > reactor.yaml
- id: groups enable: true implementation: DynamicGroupController name: Dynamic Group Controller config: groups: "dgc_low_battery": name: DGC Low Battery select: - include_capability: - battery_power filter_expression: > entity.attributes.battery_power.level < 0.3 "dgc_tripped": name: DGC Tripped select: - include_capability: - door_sensor - motion_sensor - co_detector - smoke_detector - leak_detector filter_expression: > entity.attributes?.door_sensor?.state == true or entity.attributes?.motion_sensor?.state == true or entity.attributes?.co_detector?.state == true or entity.attributes?.smoke_detector?.state == true or entity.attributes?.leak_detector?.state == true "dgc_internal_motion": name: DGC Internal Motion select: - include_entity: - "hubitat>40" - "hubitat>41" - "hubitat>43" - "hubitat>73" filter_expression: > entity.attributes?.motion_sensor?.state == true
When I then have the information loaded, it is easy to handle in many situations.
In the example below, I put in the array HouseSECURITY which devices I want to monitor, according to the way the house is, and then I crosscheck with what comes from DynamicGroup, and display messages, take actions, etc..
At the moment, the house is in Day mode, so there is nothing, at night I load in this variable the list of doors and windows; when it is travel, I add movement.
I don't know if I helped or hindered.
Thanks.
-
It would be my preference that Pabla find his error, since the way he's doing it will work... worked before, and he said that, he just changed something that made it not work, and some troubleshooting is necessary. In this case, a "code review" is sufficient (a review of the failing expression, perhaps in conjunction with a careful comparison to the working similar expression).
-
@toggledbits said in Create Expression to call out Entity ID of Tripped Binary Sensor:
You're right... it is almost the exact same expression... almost. (I'm teaching here... look closely at the one the works, and the one that doesn't).
Had a feeling it was a typo mistake, gonna take a look with some fresh eyes later today.
-
@wmarcolin that’s my next plan! I want to get comfortable with some basic expressions first then dive into the dynamicgroupcontroller
-
@pabla said in Create Expression to call out Entity ID of Tripped Binary Sensor:
dynamicgroupcontroller
I highly recommend taking the time to use DynamicGroupController, before I had huge global variables, complexity to monitor and create array, when this feature was implemented it made these group management actions by characteristics much easier. Good luck!
-
Pablareplied to toggledbits on Sep 8, 2022, 3:59 AM last edited by Pabla Sep 8, 2022, 12:57 AM
@toggledbits said in Create Expression to call out Entity ID of Tripped Binary Sensor:
You're right... it is almost the exact same expression... almost. (I'm teaching here... look closely at the one the works, and the one that doesn't).
okay so I checked and noticed that I wrote
attribute
singular and in the working one made itattributes
plural. Still no success.. I even got someone else to check the syntax and they weren't able to find a difference between the working and non-working expression.I fear I am overlooking something super basic which I thought I fixed but I have yet to find the error
Edit: I had a typo in my array of entities all is well
-
Did the behavior change? If so, what does the new behavior look like? If not, what is in the logs?
-
@toggledbits it works as expected now, I had a typo in one of my entities in the array.
-
@toggledbits said in Create Expression to call out Entity ID of Tripped Binary Sensor:
You can't do it in x_hass_system.call_service (specifically and uniquely) because the data is an object field in that action, and the substitution doesn't work in object types, only in strings.
This restriction has been lifted in build 22251. The data will now be stored as a string rather than an object, so that substitution can occur. This requires that any use of
call_service
be edited, so that the stored data is updated to the new form. You'll get alerts for actions that need to be edited. See the announcement for build 22251 for more info.
17/18