Hi,
I have an ultrasonic sensor in my water tank and have 10 different images to display based on level. I was trying to do this with 10 conditional cards but i’m having trouble getting the syntax right…
I have the below code which does works if state = 10 but I want the image to display if the state is below 10 and cant get the logic/syntax for that right.
input_select creates a drop-down menu in the frontend (which can be hidden), but it can also be set using the input_select.select_option service. So you could use it the same way as an input_boolean but with more than two states.
I do this a bit differently for a garage door card using picture glance. I’m assuming the states of your sensor.watertank are “1, 2, 3, 4, etc.”?
If so, maybe give this a try so you don’t have to create any input booleans or input selects. You wouldn’t have to create a group’d sensor like I did below, just sharing for clarity.
Your state image below would be your states from the watertank sensor and the entity is the sensor.watertank, I hope this makes sense!
Thank you jparthum and French Toast for your suggestions, the Glance Cards looks easiest but I still need some template logic whichever option I go with, this is where I was getting stuck. Condition picture cards didnt seem to allow templating but not sure how to do that with Glance-Cards either.
Are your states given as whole numbers or with decimal places? Should still be able to accomplish this with a template sensor similar to what I outlined above, it’ll just have different syntax.
Okay give this a shot, I think this should cover what you’re after. It’s not the most elegant template sensor but it should work. You can modify values to suit your needs.
state_image:
empty: /local/(name of your empty image).jpg
20: /local/(name of your image where water is between 10-19%).jpg
30: /local/(name of your image where water is between 20-29%).jpg
40: /local/...
50: /local/...
60:...
70:
80:
90:
Full:
entities: (I think you'll have to have at least one "entity" here as it's required for the card. Can be any entity)
type: picture-glance
entity: sensor.watertank_card
Yep, works well ! Thank you for your help !
One last question…
Is there a way of capping picture display size, home assistant seems to scale images up when viewed on large monitors which I dont like.
Folks, I’m quite new to HomeAssistant, learning by reading your posts. I’m trying to do the same as Phil here, but I can’t quite figure it out. The lovelace part I’m doing from within lovelace, add a manual card, and using the same code but I get this error:
Expected a value of type undefined for state_image but received {“20”:"/local/images/20percent.png",“40”:"/local/images/40percent.png",“60”:"/local/images/60percent.png",“80”:"/local/images/80percent.png",“100”:"/local/images/100percent.png"}
the sensor part I’m not sure where to configure it. is it on the configuration.yaml file?
The error is likely due to where you’re storing your photos. Can you share where you stored your images (are they in your www folder or can you share your folder structure)?
Can you share your code for your Lovelace card so i can help debug? Please be sure to use the “preformatted text” button when posting your yaml snippets so the formatting is retained.
Yes, the sensor is added to configuration.yaml file. If you share your sensor portion of the configuration.yaml file i can help debug this as well.