#Understanding how to work with sensors and conditions in YAML

1 messages · Page 1 of 1 (latest)

main socket
#

I have no idea if I've titled this correctly, so my apologies.

I have a device with a bunch of sensors and I want to add some of those sensors to my yaml dashboard.
For example, say I want to create a mushroom-chip card to display the value of a sensor.
I was hoping I could do something like

type: custom:mushroom-chips-card
    chips:
      - type: template
        content: >
          Status: {{entity('device_status_label')}}

However that just shows an empty chip, when I would expect it to display Status: at the very least.

brave meadow
#

That YAML is completely wrong.

hard raven
#

there are several issues there

brave meadow
#
type: custom:mushroom-chips-card
chips:
  - type: entity
    entity: person.bill
  - type: entity
    entity: sensor.daylight_saving_time_starts
#

If you want a template chip:

type: custom:mushroom-chips-card
chips:
  - type: template
    icon: mdi:test-tube
    entity: person.bill
    icon_color: "{{ iif(is_state(entity, 'home'), 'green', 'red') }}"
    content: "{{ state_translated(entity) }}"
hard raven
#

mdi:test-tube :). Did you pick some random icon?

#

or do you live in a test tube? Like some capsule hotel?

brave meadow
#

D) All of the above

#

(but also, I was creating a test, so it seemed appropriate lol)

main socket
#

Ahh, god I'm always so awful at figuring this out.

I want a second chip that only shows if the first sensor is in a certain state. I know I can use if statements for the content, but I'm not sure if there's a way to only show the chip if needed.

brave meadow
#

That’s not possible. Visibility rules apply to the entire chip card. So, for something like that, you’d have to have 2 chips cards and toggle visibility on each one separately.

main socket
#

Okay, so there isn't a way to basicallt say
"if is_state(entityA, 'error')
show chipB
else
don't show chipB

hard raven
#

No

ebon brook
#

card_mod applied at the chip level would work (with the appropriate template used to determine if the second chip should be shown or not, of course.) ```yaml
card_mod:
style: |
ha-card {
display: none !important
}

#

With display: true !important: