Hi, I’m looking for a way to order these bins (which show the number of days till collection and hence me going to put each one out in time - I missed the monthly green bin today!) so that the most imminent is on the left, that is ordered left to right by days to collection.
Any ideas?
I’ve had a look at various related posts here to see how to do that with “auto-entities” and grid but unable to get it work.
I’m using “grid” for the formatting, “conditional” for if the bins are within a fixed time window (was thinking 2 weeks, but put in 31 days to see all the bins for troubleshooting purposes) and “picture-elements”.
This is the code that produces the part of the dashboard in the screenshot.
(+ sorting can be added if needed - check the “sort” option in Docs for auto-entities)
But since you need entity-dependent image - that example will not satisfy all you requirements, so will you have to learn more advanced stuff - the “template” option of auto-entities.
But 1st learn THIS simple example. Otherwise, if I provide the ready code for the more advanced case, you will not learn.
lines, they are not needed for you, just play with “image: some.jpg” case.
P.S. Note that since I got 6 entities for the specified “input_number.test_level_*” pattern, there are 6 cells in the grid. In your case you need to provide a pattern for 4 entities.
Come back when you’ll be ready for more advanced stuff - the mentioned “template” option. (also, “eval_js” or how it is called can be used as well - but as I suggested learn things step by step)
where IMAGES must contain names of your jpg files, LEVELS must be replaced with names of your 4 sensors.
Also, set a proper path for 'image' option & change a domain from “input_number” to “sensor”.
And note that all images must be of same size (at least of same aspect ratio).
P.S. Probably some jinja guru will reduce the code to 1 line…
Thanks for taking the time to help. After a few hours of trial and error, I finally managed it by customising the 4 waste bin entities by adding an individual image URL to each as an attribute, sorting a list and looping it in a template…
This may give you false matches, suggest to set smth more strict.
(imagine you got another unrelated entity one day containing “days_”)
You can even set these custom attributes & not depend on particular entity names:
sensor.days_domestic_waste:
entity_picture: /local/media/domestic-waste-bin-small.png
purpose: trash_management ----for all 4 sensors