Hi there.
I’m trying to display a badge at the top of my default view in Lovelace that shows what bins are being collected this week (recycling or refuse). I feel like I’m close to getting it working how I want, but I can’t quite figure it out.
I use Node-RED to scrape the bin collection info from my local council website and publish it to an MQTT topic:
{
"type": "recycling",
"attributes": {
"date": "2020-10-26",
"day": "Monday",
"countdown": 1
}
}
I then have an MQTT sensor in Home Assistant with the state set to either recycling
or refuse
, and three attributes that I was hoping to use with setting up the badge:
sensor:
- platform: mqtt
state_topic: "bins/home"
name: "Bin Collection"
qos: 0
value_template: '{{ value_json.type }}'
json_attributes_topic: "bins/home"
json_attributes_template: "{{ value_json.attributes|to_json }}"
force_update: true
This creates a sensor that looks like this:
To create the badge, I thought I’d use the entity-filter
badge (Badges docs) two switch between two different badges depending on the state of sensor.bin_collection
(either recycling
or refuse
).
badges:
- type: entity-filter
entities:
- entity: sensor.bin_collection
name: Recycling
image: /local/bins_recycling.png?v=1
state_filter:
- recycling
- entity: sensor.bin_collection
name: Refuse
image: /local/bins_refuse.png?v=1
state_filter:
- refuse
This works perfectly fine, and the badges change depending on the sensor state. However, I would only like the bin colleciton badge to display when there are fewer than three days to go until bin collection day.
I tried adding the state_filter
part to the badge definition, but it seems to be ignored and the bin badge displays all the time.
badges:
- type: entity-filter
state_filter:
- attribute: countdown
operator: <
value: 3
entities:
- entity: sensor.bin_collection
name: Recycling
image: /local/bins_recycling.png?v=1
state_filter:
- recycling
- entity: sensor.bin_collection
name: Refuse
image: /local/bins_refuse.png?v=1
state_filter:
- refuse
In the Examples section of the docs, it shows a state_filter
for the badge, as well as separate state_filter
s for individual entities.
What am I doing wrong? It seems as if you can’t combine state_filter
s as “AND” conditions, and can only combine them as “OR” conditions.
Thanks for reading,
Chris