Display entity icon only in specific conditions?

Hi
as the title suggests, is there a way to display an entity icon only under certain conditions? perhaps by adding a filter entity,
I would like to make sure that a door sensor icon when open is only displayed if the alarm is armed.
Already now I see if the door is open or closed from the default sensor icon,
I created a gif icon that simulates a flashing, now I would like the gif to appear only with the door open and the alarm activated.
This is my card setup

  • type: image
    entity: binary_sensor.sensore_fin_cucina_contact
    tap_action: none
    hold_action: none
    state_image:
    ‘on’: local/Floorplan/alarm.gif
    ‘off’: local/Floorplan/btran.png
    unavailable: local/Floorplan/btran.png
    style:
    top: 61%
    left: 38%
    width: 3%
    • type: state-icon
      entity: binary_sensor.sensore_fin_cucina_contact
      style:
      top: 64%
      left: 38%
      tap_action:
      action: toggle