timestamp_custom uses local time by default, but if you set it’s third (first is to the left of the pipe in a filter) argument to false it’ll use UTC time and return the value you’re expecting. This is true for both ha-nunjucks and the Home Assistant default backend templating system. You can also delete the last set seconds line and omit seconds from the final time constructor.
With the suggested adjustments, I was able to implement the desired functionality.
By the way…
Great respect for your work. Your project offers a fantastic and relatively simple way to customize your system. It’s also a great problem solver when other cards simply don’t fit or don’t offer the necessary functionality.
I’m hitting a problem when trying to pass variables to scripts from a Custom Features Button using templated values. The nunjucks templating engine seems to be converting certain characters to html encoding, which nullifies my attempts to match specific strings in the called script.
For example supposeselect.spotify_albums has the value Yann Tiersen - The Lighthouse - Everything's Calm, comprised of a string in the form %artist% - %album%.
I pass a value for album to my script as follows:
{%- set artist = states('select.spotify_albums').split(' - ')[0] %}
{{ states('select.spotify_albums').split(artist ~ " - ")[1] }}
In Developer Tools > Template (which I recognise is using HA’s templating engine) this produces The Lighthouse - Everything's Calm as expected. But looking at the traces for the script when called from a Custom Features Button, it shows the album variable as:
The Lighthouse - Everything's Calm
which causes it to fail in a matching routine used in the script.
Is there a way I can code round this? Or should I not be expecting this to work?
That’s expected behavior with templates for both the HA default jinja backend and this card’s template system. ha-nunjucks has it’s own methods to format states, attribute names and values, numbers, dates, times, and datetimes using user settings as asked for in this issue and seen here in the ha-nunjucks README. But in testing while writing this I realized that I wasn’t taking these localization settings into account when doing so, so I’ve created a bug to fix later.
Fixed the ha-nunjucks number, date, time, and datetime translated template functions to respect user locale settings and released version 4.8.4 of this project and return the same results as Home Assistant’s default frontend logic. Although after I implemented it all I realized that you can also use state_translated to get the same result.
It also adds some fixes to toggle checkbox and input features to use newer Home Assistant theme style tokens, and makes it so that Material Design 3 buttons and sliders will now scale with --feature-height in their font size and border radii.
First of all, thank you for the great work and for continuing to update this card. It’s very useful.
I’m seeing two styling issues with custom:service-call input rows after recent updates:
The --feature-button-spacing variable I used before to control the horizontal space between the button/icon area and the input field no longer seems to have any effect. I specifically want to adjust the gap between the button and the input value horizontally.
In the dropdown styling section, when the dropdown is collapsed/minimized, it still leaves a visible white horizontal bar instead of hiding completely.
This used to work before, so I’m wondering if there was a layout/CSS selector change or if this is a regression. Is there a new recommended way to style the button/input spacing and fully hide the dropdown content when closed?
I'm on version 4.9.4 and have cleared cache.
The --feature-button-spacing variable I used before to control the horizontal space between the button/icon area and the input field no longer seems to have any effect. I specifically want to adjust the gap between the button and the input value horizontally.
--feature-button-spacing still works for me, none of the recent changes should have affected that. Where are you setting it? At the card or row level? Using the built in style options or card-mod? If set with card-mod at the card level the Home Assistant card may be overwriting it with it's own value for --feature-button-spacing. You can also try setting .row { gap: 16px } at the row level styles.
In the dropdown styling section, when the dropdown is collapsed/minimized, it still leaves a visible white horizontal bar instead of hiding completely.
The dropdown styles were heavily modified in the last release so this could be a bug, but I haven't been able to reproduce it on any browser or device. What device/browser/app are you seeing this on? Do you have any custom styles applied to it?
That did solve the problem, please let me know if you see better ways of styling it.
Regarding the --feature-button-spacing, the code below used to work:
Could you please share the config of the card shown in the release note, in order to recreate a tile card with the tile icon buttons to make it look similar to a regular one using only custom features card ? I am struggling to achieve a one to one copy, ie. with the name and state on 2 lines with different fonts (among other things).
Version 4.10 adds dynamic dropdown and selector options, and templatable feature values.
You can now define dropdown and selector options using either an entity attribute or a template that resolves to a list. The config of each option is defined using an option template object, which you can modify as needed.
If you do not define an entity for a feature, you can now instead define it's value using a template string or static value.
Thanks to @kristofferR for implementing dynamic options.
Edit: You can ignore this. I’ve figured it out. I had to add an alternate checked value for the toggle.
Thank you so much for the work you’ve put into this, as well as the help you’ve been giving the community! I have a question about the toggle, if you have a moment.
I’m trying to use a toggle to control a simple door lock … and by all appearances, it looks right. When I swipe the toggle to lock the door, it does indeed lock, but after about 3 seconds, the toggle flips back to its original state, rather than staying on the “locked” position. The door lock itself is uneffected by this flip. I’ve included the YAML for the toggle below: