Mushroom Cards - Build a beautiful dashboard easily 🍄 (Part 2)

You should be able to adjust you binary_sensor code to give you different results for last-changed?

I do want the last-changed to show in the chip. I just want it formatted differently. I’m not sure if there is a place I can go and define it?

Currently the formatting is ‘10 minutes ago’ which I want to tweak to ‘10m’

Can you post the binary_sensor code? Did you configure it via the configuration.yaml file or as a helper?

Neither unfortunately - it’s just the default output of the entity. What would you suggest? Probably a helper? But what if I want it as a global setting and not just to one sensor?

What helper should I use for this?

Can you resend the pic of the state from developer tools for the binary sensor?

Binary sensors are generally two states so I’m am overthinking this or learning something new :smiley:

There you go, Sir

What do you get when you enter this in the Developer Tools Template?

{{ states('binary_sensor.office_sensor_motion', 'last_changed') }}

Hopefully this is what you wanted

Yes thank you, I got it…Mushroom code is pulling the last changed time

Thanks, so is there a work-around? Or will it require too much fiddling.

I’m happy to try my hands at a helper if you guide me!

There is templating solution. I just need to convert it to the format you want.

For example if you use
{{ states['binary_sensor.office_sensor_motion'].last_changed | relative_time }} ago you get the same results as the field that is generated in the entity card.

Yeah, you’re bang on - we need to get this to a workable template

sorry @LiQuid_cOOled to jump in on this. @sid1907 if you wanted the output even smaller you could change it to a timestamp and use timestamp_custom.

{{ states['sensor.address'].last_changed|as_timestamp | timestamp_custom("%Hh:%Mm:%Ss", false)}}
1 Like

No worries. @sid1907 was looking for the time difference from now(), not the time stamp. We worked on it via DM

This is what I came up with

{% set time = now() - states.binary_sensor.xxx.last_changed %}
          {% set seconds = time.total_seconds() %}
          {% set hours = seconds // 60 // 60 %}
          {% set minutes = (seconds) // 60 - (hours * 60)%}
          {{ '%2i' % (hours) }}h{{ '%2i' % (minutes) }}m

With your code you can do it this way and I like it better :smiley:

{{(now() |as_timestamp - states.binary_sensor.xxx.last_changed |as_timestamp) | timestamp_custom("%Hh:%Mm:%Ss", false)}}

1 Like

Thanks a lot @Frosty - your code really cleaned it up! With some help from @LiQuid_cOOled , we got it exactly where we wanted it.

image since the last motion!

no problem glad you got it working.
someone with loads of skill and knowledge recently told me there’s more than one way to skin a cat :wink:

2 Likes

How can I change the color of the wattage display and/or the name (heating) depending on the power level? Heating at < 7 watts = green, over 7 watts orange and over 70 watts red?

type: entity-filter
entities:
  - entity: sensor.sh_k_hz_leistung
    icon: mdi:water-boiler
    name: Heizung
    secondary_info: last-changed
    tap_action:
      action: navigate
      navigation_path: /lovelace/15
  - entity: sensor.p_w_k_k_leistung
    icon: mdi:fridge
    name: Kühlschrank
    secondary_info: last-changed
    tap_action:
      action: navigate
      navigation_path: /lovelace/2
conditions:
  - condition: numeric_state
    above: 1
title: aktuell

Consumers are only listed if they are active.

Similar like this:

type: custom:mushroom-chips-card
chips:
  - type: entity
    entity: sensor.sh_k_hz_leistung
    name: ' Heizung '
    secondary_info: last-updated
    card_mod:
      style: |
        ha-card {
          {% set state = states('sensor.sh_k_hz_leistung') | int %}
          {% if state >= 80 %} 
            --text-color: red;
          {% elif state >= 40 %}
            --text-color: orange;
          {% elif state >= 6,2 %}
            --text-color: green;
          {% elif state >= 1 %}
            --text-color: yellowgreen;
          {% endif %}
        }
        }
      use_entity_picture: true
    alignment: center

You are going to have to be a little more specific with your end goal. Are you trying to use the entity filter card in lieu of the Mushroom card?

is it possible to change the background colour this card/icon ?

- type: "custom:button-card"
  template: "card_scenes_welcome"
  variables:
    entity_4:
      entity_id: "sensor.indoor_temperature"
      nav_path: "media"
      icon: "mdi:music"
      name: "Media"
      color: blue

this is what I have tried…

    card_mod:
      style: |
        mushroom-template-chip:nth-child(2)$: |
          ha-card {
            --chip-background: #ede9e3;
          }
        :host {
          --ha-card-background: #8a9977;
        }

How would using card mod for a mushroom chip card work with button card?

Button card supports changing backgrounds internally:

type: custom:button-card
styles:
  card:
    - background-color: red
1 Like