Displaying binary sensor that had last motion #79
pkozul
started this conversation in
Show and tell
Replies: 1 comment 4 replies
-
Hi! class: 'binary-sensor-${entities[element.id].state} ${(entities["sensor.last_motion_entity_id"].state === element.id) ? "last-motion" : "" }' I would write :
I simply cannot tackle the right syntax ! |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there,
Just sharing how I implemented 'last motion', which is something that was part of the original version of Floorplan.
First of all, I created a sensor in HA to keep track of which binary sensor detected the most recent motion. There are actually 2 sensors shown below... one stores the entity ID of the binary sensor, and the other stores the name of the binary sensor.
I then have a floorplan rule that sets the CSS classes for the binary sensors on my floorplan. As you can see,the rule is executed whenever any of the binary sensors change their state, or when the last motion sensor (created above) changes.
The rule then calls the
floorplan.class_set
service, but it doesn't do this just for the binary sensor that has changed, but rather, it calls this service for each of the binary sensors (one at a time). This ensures that any binary sensor (on the floorplan) that was previously displayed as the 'last motion' sensor has a chance to revert back to its normal display. So, in other words, whenever the rule is executed, thefloorplan.class_set
service is called 3 times - once for each of the binary sensors. The actual class that gets set consists of 2 CSS classes.... one class is for the binary sensor on/off state (fll colour for the room), and the other class is the for the last motion (outline of the room).The CSS classes:
Here you can see the Salon had the 'last motion', hence the background show around the room.
Beta Was this translation helpful? Give feedback.
All reactions