custom-cards / flex-table-card

Highly Flexible Lovelace Card - arbitrary contents/columns/rows, regex matched, perfect to show appdaemon created content and anything breaking out of the entity_id + attributes concept
GNU General Public License v3.0
198 stars 23 forks source link

Using variable in css #94

Closed cfrets closed 1 year ago

cfrets commented 1 year ago

I have a table with energy prices for each hour.

Hour | Price 00-01 | 0.12 01-02 | 0.34 ...

I would like to change the background color on the row containing the price for the current hour.

When hardcoding the hour into the css selector, it works just fine, but when trying to use the current hour, it doesn't work. How do I make it use a variable?

This work: css: 'tbody tr:nth-child(18}) td': 'background-color: blue'

This doesn't work: css: 'tbody tr:nth-child({{ new Date().getHours() }}) td': 'background-color: blue' or css: 'tbody tr:nth-child({% new Date().getHours() %}) td': 'background-color: blue'

ildar170975 commented 1 year ago

Templates are not supported. Use card-mod.

cfrets commented 1 year ago

I fixed it with card_mod as suggested by @ildar170975 card_mod: style: | tbody tr:nth-child({{ now().hour }}) td { background-color: blue; }