Yaml help needed

I have an interactive floor plan in a picture elements card. I am looking to input a state icon for motion that is only visible when the entity state is detected and not visible when the entity state is cleared.

- type: state-icon
    style:
      left: 47%
      top: 60%
      "--mdc-icon-size": 15px
    entity: binary_sensor.fp2_living_room_presence_sensor_1
    icon: mdi:motion-sensor
    state_color: true
    tap_action:
      action: none
    hold_action:
      action: none

this is the current code. the icon does change color based on its state but I haven’t been able to change its viability based on its state. Also is there a way to change the state colors. as of now blue is the clear state and yellow the detected state and I have been unable to change those as well. Any help would be appreciated dearly.

Hello Anryn Malcolm,
Welcome to the Home Assistant Forum!

Thanks for coming here and asking a question.
Would you be so kind as to adjusting the format of your code so that we can read it properly & check the YAML spacing, etc. Editing your original is the preferred way. It is very hard for us to tell what is what when the text formatter jumbles everything like that.
You can use the </> button like this… How to format your code in forum posts
OR… Here is an example of how to fix formatting from the site FAQ Page.
How to help us help you - or How to ask a good question.

Thanks much, I have edit the post as suggested.

1 Like

I don’t think you can do that with the icons.
It says in the docs “This element creates a static icon that is not linked to the state of an entity”
I think you’re best bet is to use a PNG image and use the state_image.
Download a PNG of a motion looking icon and use that for the on and then make that png blank or transparent and use that for the off.

I was able to get it to work using the following

- type: state-icon
    icon: mdi:motion-sensor
    style:
      left: 57%
      top: 45%
      "--mdc-icon-size": 25px
      "--state-binary_sensor-off-color": transparent
      "--state-binary_sensor--on": red
    entity: binary_sensor.fp2_living_room_presence_sensor_1
    state_color: true
    tap_action:
      action: none
    hold_action:
      action: none
1 Like