As a new HA user I’m still struggling a bit with binary_sensors and how to use them in frontend (mushroom) cards.
The binary sensor binary_sensor.afval_ophaaldienst_vandaag
has been defined as:
- binary_sensor:
- name: Afval ophaaldienst vandaag
unique_id: "afval_ophaaldienst_vandaag"
state: "{{ states('sensor.afval_vandaag') != 'Geen' }}"
attributes:
icon: >
{% set waste_collection_date = as_datetime(state_attr('sensor.upcoming','upcoming')[0].date) %}
{% set days_until_collection = (waste_collection_date.date() - now().date()).days %}
{% if days_until_collection == 0 %}
{% set icon = state_attr('sensor.upcoming','upcoming')[0].icon %}
{% else %}
{% set icon = "mdi:trash-can" %}
{% endif %}
{{ icon }}
to function as a simple True/False condition for the the Mushroom Chips Card where a Conditional Entity Chip is used to display the entity (icon), or not:
type: custom:mushroom-chips-card
chips:
...
- type: conditional
conditions:
- condition: state
entity: binary_sensor.afval_ophaaldienst_vandaag
state: "on"
...
With the binary sensor set to on
, it still does not show the icon in a Chips Card.