Custom card - Binary sensor icon not updating

So I made a custom card:

Everything works fine, except for the binary_sensor entities. Their icons do not update when the binary_sensor state update. Anyone got an idea why?

Hmm Nobody??

Hi, Did you work it out? I have the same problem with setting a custom icon… doesn’t update but using the default icon it does.

- trigger:
    - platform: webhook
      webhook_id: bath-2
    - name: "Bathroom"
      unique_id: bath-2
      device_class: occupancy
      state: "{% if 'Unoccupied' in trigger.json.Cortex_HAAPI.State %}False  {% else %}True {% endif -%}"
      icon: >
        {% if is_state("binary_sensor.bathroom", True) %}
        {% else %}
        {% endif %}

This is what I get when binary is True

This is what I am hoping for

Hey, yes its working now. Was some issue in the code. But your problem…
Your sensor, what is the off state trigger.json.Cortex_HAAPI.State give?

And if thats not the problem I think it has something to do with the fact you are using the state of the sensor in its own template. I did something similar and I had to use states.binary_sensor.bathroom in your case.

Also try to define it like this:

     friendly_name: 'Bathroom' 

Thanks for getting back to me!
There are 3 room states in Cortex; unoccupied, occupied, must be occupied.
On the API these are presented as (only 1 of the state messages is sent, these are the 3 types of response)

   "Room": "Family Room", 
   "State-u": "Bedroom 3 - Unoccupied.\n",
   "State-o":  "Family Room - Occupied.\n",
   "State-must": "Bath Room - Occupied.\n"

I also changed the sensor definition within the template as suggested but it told me ‘Property friendly_name is not allowed’

- trigger:
    - platform: webhook
      webhook_id: bath-2
    - name: bathroom
      friendly_name: Bathroom

Ah yeah its not a template entity. Sorry about that. Try your yaml out in the developer tools section > template. That always helps me a lot