Closed kineticscreen closed 9 months ago
As a workaround for now, your can define a binary_sensor
with template and use it in your condition 🙂
That's... quite clever.
Hi, i would also like to use within the conditional chip a custom card
i.e.
i use this card on my dashboard:
type: conditional
conditions:
- entity: sensor.seventeentrack_packages_in_transit
state_not: '0'
card:
type: custom:seventeen-track-card
entity: sensor.seventeentrack_packages_in_transit
title: Unterwegs
location: false`
but:
`type: custom:mushroom-chips-card
chips:
- type: conditional
conditions:
- entity: sensor.seventeentrack_packages_in_transit
state_not: '0'
chip:
type: custom:seventeen-track-card
entity: sensor.seventeentrack_packages_in_transit
title: Unterwegs
location: false
`
doesnt show anything
Trying to think of a way to template out a conditional chip that displays whether or not the current user is a specific person. Would anyone be able to show me how to template out an is_user binary_sensor using the {{user}}
variable? I tried this but it didnt work:
template:
- binary_sensor:
- name: "is_jake"
state: "{%if user === 'Jake' %}on{%else %}off{%endif %}"
Use this card instead?
Use this card instead?
Thanks for the reply @davidcoulson. Im just trying to implement what @piitaya mentioned above for my specific use case.
I tried doing a conditional chip but the alignment was all out of wack. Ended up with this which is more verbose but works. Leaving it here in case anyone else needs an example:
type: custom:state-switch
entity: user
default: default
states:
Jake:
type: custom:mushroom-chips-card
chips:
- type: weather
entity: weather.home
show_conditions: true
show_temperature: true
- type: alarm-control-panel
entity: alarm_control_panel.ha_alarm
- type: entity
entity: sensor.exchange_rate_1_btc
icon: mdi:bitcoin
icon_color: orange
alignment: center
default:
type: custom:mushroom-chips-card
chips:
- type: weather
entity: weather.home
show_conditions: true
show_temperature: true
- type: alarm-control-panel
entity: alarm_control_panel.ha_alarm
alignment: center
Thanks for sharing. The only solution is to create a condition template chip. We works on other cards for now but that something we can consider 😉 Templates are not user friendly but allow maximum flexibility. Building a condition builder in the UI will be to complicated.
The only solution is to create a condition template chip. We works on other cards for now but that something we can consider 😉
This would be absolutely awesome to be able to create advanced conditionals without resorting to binary sensors. I think it would be fine without a UI for more advanced users. 😊
Thanks for sharing. The only solution is to create a condition template chip. We works on other cards for now but that something we can consider 😉 Templates are not user friendly but allow maximum flexibility. Building a condition builder in the UI will be to complicated.
Actually there's no need to build a complex editor:
Currently you can add multiple (and connected) conditions based on entities. You only need to add a "select" for condition type:
Would it be possible to use the state or attribute of a sensor as the condition:
- type: conditional
conditions:
- entity: sensor.battery_device_a
operator: "<"
state: {{ input_number.low_batt_level }}
I want to show devices where the battery level is less than a input_number slider
Hello I tried to make a conditional chip with extended conditions. Example "state" >=1000 chip shows up with color orange, if "state" >=1800 icon is changing to red, under 1000 chips has nothing to show. Is there any update in this direction? (chip template)
Now It works as I want, but a conditional template with operators would be really nice.
_My config would be better if sensor (sensor.netatmo_co2_indoor_mainunit0) would be declared as a variable over all.
Thanks @piitaya, It is now updated.
However in Style {% if states(entity)|float >= 1000 %}
does not work but so
{% if states('sensor.netatmo_co2_indoor_mainunit_0')|float >= 1000 %}
is OK.
type: custom:mushroom-chips-card
chips:
- type: template
entity: sensor.netatmo_co2_indoor_mainunit_0
icon: |-
{% if states(entity) | float >= 1000 %}
mdi:molecule-co2
{% else %}
{% endif %}
icon_color: |-
{% if states(entity) | float >= 1800 %}
#ff471a
{% elif states(entity) | float >= 1000 %}
#ff9900
{% else %}
{% endif %}
content: |-
{% if states(entity) | float >= 1000 %}
{{ states(entity) | int }} ppm
{% else %}
{% endif %}
card_mod:
style: |-
{% if states('sensor.netatmo_co2_indoor_mainunit_0') | float >= 1000 %}
ha-card {
}
{% else %}
ha-card {
--chip-box-shadow: none;
--chip-background: none;
}
{% endif %}
@orimate You can use entity variable (https://github.com/piitaya/lovelace-mushroom/blob/main/docs/cards/template.md#description) :
- type: template
entity: sensor.netatmo_co2_indoor_mainunit_0
icon: |-
{% if states(entity) | float >= 1000 %}
mdi:molecule-co2
{% else %}
{% endif %}
For now, there is no way to use template in condition because there is performance issue with template so I prefer to keep template for template card and template chip which are more advanced chips.
The workaround to do this is to write a binary_sensor
with the condition you want so it can be easily reused in automations too.
I had poked around with this locally, and have been running a totally hacked together implementation for a while. I have it set up such that if the template returns 1, the desired chip shows, otherwise it will be hidden. Essentially just an inline binary_sensor.
This was really nice for quick one offs that I hadn't wanted to make a new template sensor for, but now that we have the ability to define template helpers in the gui I had started converting my conditions to them. Maybe there are some other nice to haves that others can think of that would make this a more appealing option still?
🚨 Spoiler alert 🚨
It's introduced with this PR https://github.com/piitaya/lovelace-mushroom/pull/1269. It will be available with 2023.11
Home Assistant release and 3.2.0
Mushroom release.
hi, is there any plan to use for chip the type card?
like i mentioned above, i would like to use a custom card
Would be good to have some more options for Conditional Chips - i.e. < > <! !>
Is / is not works for lights and switches, but not for sensors.