A different take on designing a Lovelace UI

Well quite embarrassing to tell you then that I have had Home Assistant for several years. I’m also a web developer. So codes are not strange to me. But for the record, just because I’m a developer myself doesn’t mean I develop everything I use. No need to invent the wheel several times.

And I haven’t gone this deep into Home Assistant that I know why “local” is “www”. But if that is something basic then, I guess I need to lookup the basic guide again.

Is it possible to edit the custom_fields of the custom button card config so that it will show battery level instead of brightness? I use the button to show the state of zigbee motion and door/window sensors and would like to be able to tell at a glance what the battery level is.

image

custom_fields:
  info: >
    [[[ if (entity.state === 'on' && entity.attributes.brightness) { const
    brightness = Math.round(entity.attributes.brightness / 2.54); const radius =
    20.5; const circumference = radius * 2 * Math.PI;  return `<svg viewBox="0 0
    50 50"><circle cx="25" cy="25" r="${radius}" stroke="#b2b2b2"
    stroke-width="1.5" fill="none" style=" transform: rotate(-90deg);
    transform-origin: 50% 50%; stroke-dasharray: ${circumference};
    stroke-dashoffset: ${circumference - brightness / 100 * circumference};" />
    <text x="50%" y="54%" fill="#8d8e90" font-size="14" text-anchor="middle"
    alignment-baseline="middle">${brightness}<tspan
    font-size="10">%</tspan></text></svg>`; } ]]]

This is the part of the button that controls the brightness graphic, but my battery levels are actually their own sensor instead of being an attribute of the binary sensor. i.e The entity for the Laundry button in my screencap is named binary_sensor.laundry_window and the battery level is sensor.laundry_window_power. How would I go about editing the custom field to display the battery % instead of brightness?

Hi @Mattias_Persson

FYI
I don’t know if you have seen it, but the sensor values for the Roborock have changed.
So in your sensors.yaml, it is now like this:
sensor.main_filter = sensor.filter_left
sensor.main_brush = sensor.main_brush_left
sensor.sensor = sensor.sensor_dirty_left
right_side_brush = sensor.side_brush_left

And then a question. My sensor.robot_last_clean, gives me this time format: 2021-04-01T14:27:37. I have your config, but would like something more clean. Has this also changed on your end?

Thanks in advance

@Martin_Pejstrup

Hello, try this:

      roborock_last_clean:
        friendly_name: Dernier nettoyage
        icon_template: mdi:calendar-clock
        device_class: timestamp
        value_template: >
          {{ state_attr('vacuum.roborock_vacuum', 'clean_stop') | replace(' ','T') }}

The key is the device_class: timestamp here

Hello everybody!
First of all many thanks to the creator. After the classic lovelace and hadashboard i wanted to try something else for a new display in the kitchen…
I have been having fun with this for a few weeks, but I got stuck: clicking or holding a button does nothing. I must be missing sth quite obvious but cannot find what.

  • custom components are installed
  • the dashboard looks fine (state of lights are correctly displayed)
  • button card works in onther dashboards (yaml)

Anybody knows what I am overlooking?

ty guys!
Kjoere

Post yaml to be helped :wink:

sure but what yaml you mean? it is the base code from the author with my devices/Entities (nothing changed besides this)
the unchanged buttons (like the sidebar (info, vacuum, update) also dont react when clicked

Part of the code where the non working button card is defined

Nothing react ? Not only button card ? Same thing on computer and touch device ?

hi Djal, thx for your time,

          - type: custom:button-card
            entity: light.hue_lightstrip_outdoor_1
            style:
              top: 20.35%
              left: 41.31%
              width: 10%
            template:
              - light
              - icon_shade

this is an example of almost original code. nothing happens onclick

You have « tap_action » and « hold_action » well defined in the template ?

I did not change anything in the button_card_templates.yaml file

I refer (see code in previous post) to the light template:

  light:
    template:
      - base
      - circle
    variables:
      .......
    hold_action:
      action: fire-dom-event
      browser_mod:

and in the base template I see the tap action defined:

 base:
    aspect_ratio: 1/1
    show_state: true
    show_icon: false
   ........

    tap_action:
       action: toggle

I have been fiddling back and forward: the hold action works and changes in the light template work (for hold action). It needs a restart though (clearing the browser is not enough).
so for instance:

  hold_action:
    action: toggle

works fine in the light template. So I conclude I am in the right place in the code
Adding the tap action inside the light template itself (and reverting hold action):

  tap_action:
    action: toggle

does not work either…

EDIT: (SOLVED for NOW) : deleting the sound part in the tap_action in the base template fixed it .

    tap_action:
      ui_sound: |
        [[[
         .....
        ]]]
      action: toggle
      haptic: light

Thanks Djal and others for helpin me out!

Thank you for everything, it looks amazing.

I do not like to use template. Is it possible to get a button that does not have a template?

yes, just add the lines of the template at the end of the button line in the ui-lovelace

oh yes of course, did not think to tell you. sorry

I do not understand much about it - can you provide me with a sample of a ready-made button?

No i did not do what you want to do.I’m using template. Honestly i do not understand the « i do not like to use template » but whatever. Templates let you use the same code several time without making repetition.
Look what is defined inside a template (base for example) and add those lines at the end of the button definition

Hey @Mattias_Persson any idea what’s changed and/or how to fix this ( seems ) css issue on the side panel? It happened after last hass update.

Good afternoon everyone!)
@Mattias_Persson Thank you so much for your job!
I have such a question for everyone, sorry, maybe its a stupid…
What do I need to do to start using this lovelace panel design?
Copy all the files from github to the /hassio/homeassistant directory and then configure it for my system? Or do I need something else?
Please, write in detail!
Thank you in advance!

Hi.

Yes you can start by copying all the files.
And after that adjust step by step to fit your needs.

1 Like