#Displaying lowest entity

1 messages Β· Page 1 of 1 (latest)

old trail
#

I'm hoping to display an entity card which shows the lowest fuel price in my area.
I'm using the NSW Fuel addon, and have a bunch of the local petrol stations added (as such have a bunch of entities for each petrol station's petrol type price)

It's easy enough to grab the lowest value (either nodered or min/max), however that just gives me the value, not the location (entity name).
Is there some way I can display the lowest value entity name as well as it's value?

magic dust
#

If you stick them all in a sensor group helper and set the group type to be minimum it will have an attribute min_entity_id which gives you the entity id of the one it's displaying

#

that's the easiest method imo, unless you expect to be changing your list of petrol stations frequently?

old trail
#

Ah! Thanks! That should work
Lemme tinker and see if I can figure out how to get the entity_id display name

old trail
magic dust
#

a template of {{ state_attr(state_attr('sensor.petrol_station_group', 'min_entity_id'), 'friendly_name') }} should do it - the "inner" state_attr gets the entity_id to use for the outer one

old trail
#

would that be a manual card?? (sorry, not used any cards needing {{ }} yet!)

magic dust
#

that would be with a mushroom template card - you can't put templates in normal entity cards sadly

old trail
#

uno momento whilst I go google that πŸ˜›

#

Is that the HACS mushroom addon by piitaya?

magic dust
#

yeah that's the one

old trail
#

awesome, thanks, lemme nab it and play around, see if I can get that working πŸ™‚

magic dust
#

you could do something like that (pointing the secondary information at whatever the fuel cost attribute is actually called)

old trail
#

ah thanks, how would I find out the name of the value?
It's not an attribute, it's the value of the entity itself

magic dust
#

do you have developer tools active?

old trail
#

yea

magic dust
#

go into that and then "State" and then search for that entity

old trail
#

ah, figured it out.
{{ states('sensor.cheapest_fuel_u91') }}

#

lemme just check that's giving the right value, but it outputs a price xP

magic dust
#

ah - yeah that makes sense ^^

#

so it would be {{ states(state_attr(..)) }}

old trail
#

Is there any benefit to accessing the state from the fuel entity itself vs accessing the state that the sensor group calculates?
i.e. states('sensor.cheapest') vs states(state_attr('sensor.cheapest', 'min_entity_id'))

#

cause this seems to be working?

magic dust
#

probably not tbh ^^

#

I was just in the mindset of getting it from the entity_id

old trail
#

yea fair

#

thanks for the help πŸ™‚
looks like this will work wonderfully

magic dust
#

that said, you might want to edit the station name to get rid of the "U91" it sticks on the end

old trail
#

yea probably.
Is there a way to multi-line the output?
(eg:

Cheapest U91
BP Place
123c

)

#

using \n\r <br> or just enter don't seem to work, keeps it all on one line

magic dust
#

yeah i don't think you can split the primary information up like that

old trail
#

or the secondary by the looks, damn, ah well!

magic dust
#

if you set the secondary to multiline (down at the bottom) you can get something like this:

old trail
#

ooh hey, I just didn't scroll enough xP
thanks!!

magic dust
#

np πŸ™‚

old trail
#

End result πŸ™‚

magic dust
#

sweet!

old trail
#

Thanks again!
Wouldn't have grabbed those mushroom cards without your suggestion πŸ˜›
Probably would have gone down trying some evil spaghetti of making an entity card for each station and using visibility rules or something xP

magic dust
#

Hah, that would be gross

#

I think you could do it with a filtered entities card

#

they even have an example πŸ™‚

old trail
#

huh xP

#

Might try it out and see the differences