ahhh perfect! Thank you
You rock dude!!! Iāve managed to use your integration perfectly, along with using the Philips icon repository you created but Iām struggling to have the āphilips circleā. Do you mind to share it?
Itās not my integration
The code for my āphilips circleā is in this post:
Thanks for answering so fast
I used that code But the code mentions custom:circle
icon which is not on the code you shared nor the icon repository. Maybe is somewhere else?
Well spotted, my mistake. This is from my other icon pack:
It should then be referenced as kongo09:circle
. I should update that sometimeā¦
in your card you should still add the custom_field it self. Right now, you only entered the styles for the custom_field.
see the last lines of Lovelace: Button card - #6239 by Mariusthvdb
there you point that field to your card entity, which is set to the timer you desire?
Ohā¦ with entiy.state the label appears, wonderfulā¦ Iām beginning to understand
But if I insert timer.scaldabagno the terminal give me an error:
custom_fields:
notification: >
[[[ return timer.scaldabagno; ]]]
ButtonCardJSTemplateError: ReferenceError: Canāt find variable: timer in āreturn timer.scaldabagno ;ā
The entity is correct:
that is because for Java script (which is the language these templates are in) you are now returning a āvariableā timer. You want to return the entity.state directly.
And how i tell to HA that i want a duration of timer? (The countdown)
I try with template but does not work.
now why dont you try what I have been suggesting you now for 3 timesā¦ and then show us the button result. entity.state should show as āidleā, like your screenshot shows. Or, ofcourse, when counting, it should show the remaining time.
This might require some extra work, because I am not sure if it update every second automaticallyā¦ but thats the next step.
first do as I asked, and use entity state.
O, and if you read the documentation, (and my remarks above): button-card uses Javascript (JS) templates, and not Jinja templates, like core HA does.
Your template will not work, and if you want an attribute, youād need something else. (I wont tell you now, because then you will still not enter that I asked you to )
(btw, these screenshots of the ui editor are not very useful. Better paste your correctly formatted yaml code, and a separate screenshot of the button.)
styles:
card:
- height: 7em
- border-top: 24px groove brown
- border-right: 14px groove gray
- border-left: 14px groove gray
- background: >-
repeating-linear-gradient(0deg, black 10px, gray 10px, silver
24px)
- background-blend-mode: darken
- border-radius: 1em 1em 0em 0em
Ok, here you are the screenshot and the code.
But, the entity.state return the state of input_boolean.scaldabagno_temporizzato, not the timer.scaldabagno status.
type: custom:button-card
entity: input_boolean.scaldabagno_temporizzato
name: Scaldabagno Timer
icon: mdi:thermometer-plus
custom_fields:
notification: |
[[[ return entity.state ]]]
styles:
img_cell:
- justify-content: start
- align-items: start
- padding-left: 10px
- padding-bottom: 10px
custom_fields:
notification:
- border: 1px solid var(--text-color-on)
- border-radius: 12px
- font-size: 11px
- font-weight: bold
- height: 18px
- line-height: 18px
- min-width: 12px
- padding: 0px 3px
- position: absolute
- right: 5%
- top: 10%
Thank you for your patience
right, thats cool, and now I see you dont need the entity at allā¦ sorry for that, I was distracted by the object_id.
now you need to call the state of timer.scaldabagno
and do that in JS like states['timer.scaldabagno'].state
.
in the template hooks:
[[[ return states['timer.scaldabagno'].state; ]]]
and since weāre in the learning mode, please forgive me to tell you to ādelimitā those JS lines with a semi-colon always, making sure it is the end of a line. just grow the habit.
Well well wellā¦ Now I see āIdleā when the button is OFF and āactiveā when the button is ON
The countdown is not yet visible.
Here you are the code:
type: custom:button-card
entity: input_boolean.scaldabagno_temporizzato
name: Scaldabagno Timer
icon: mdi:thermometer-plus
custom_fields:
notification: |
[[[ return states['timer.scaldabagno'].state; ]]]
styles:
img_cell:
- justify-content: start
- align-items: start
- padding-left: 10px
- padding-bottom: 10px
custom_fields:
notification:
- border: 1px solid var(--text-color-on)
- border-radius: 12px
- font-size: 11px
- font-weight: bold
- height: 18px
- line-height: 18px
- min-width: 12px
- padding: 0px 3px
- position: absolute
- right: 5%
- top: 10%
you might want to format you button a bit, or at least put in in a grid card with eg 4 column, so it gets resized. than you get a better feeling for the space you want it to use and the different relative proportions of the card sections. add 1/1 for square.
- type: grid
columns: 4
cards:
- type: custom:button-card
aspect_ratio: 1/1
triggers_update: timer.scaldabagno
what happens when the countdown is started, can you show that in the dev tools?
as said, it might need a āhackā that is to tell HA to update an entity every second. but maybe not, first add the timer to the triggers_update: option like above
If that doesnt help, you can implement an automation, that you only fire under certain conditions:
automation:
- alias: Second updater
id: Second updater
mode: restart
trigger:
platform: time_pattern
seconds: '/1'
condition:
condition: state
entity_id: input_boolean.second_updater
state: 'on'
action:
service: homeassistant.update_entity
entity_id:
- sensor.second_updater
- sensor.new_years_day_countdown
- sensor.since_new_years_day_counting
Iāve inserted your new lines of code.
The following screenshots show you the button and dev tools before I click on the button and after.
Iāve added one more screenshot that show you the timer bar in another my experiment.
Seems that the timer was been updated every seconds.
Thanks
@Mariusthvdb maybeā¦ you donāt have a timer to try to put it in a botton on you configuration?
To verify if you see āIdleā / āActiveā or if you see the minutes.
Maybe my config are wrongā¦
no sorry, but I guess you want the āremainingā attribute to be displayed?
you can eg make the color change on state (grey for idle, orange for active), so you can see that in the icon, and then have the attribute show the remaining time, (when active only)
[[[ states['timer.scaldabagno'].attributes.remaining; ]]]
and
styles:
icon:
- color: >
[[[ return entity.state === 'active' ? 'orange' ; 'grey'; ]]]
Yes, I would like the remaining value, the countdown.
Iāve inserted the āattributes.remainingā code but that does not work.
I canāt see the digits of the timer remaining.
Why?
Iāve try 2 solutions but they donāt work; here you are the 2 solutions tested:
[[[ states['timer.scaldabagno'].attributes.remaining; ]]]
[[[ return states['timer.scaldabagno'].attributes.remaining; ]]]
Actual code and below the screenshot of the result:
type: custom:button-card
aspect_ratio: 1/1
triggers_update: timer.scaldabagno
entity: input_boolean.scaldabagno_temporizzato
name: Scaldabagno Timer
icon: mdi:thermometer-plus
custom_fields:
notification: >
[[[ states['timer.scaldabagno'].attributes.remaining; ]]]
styles:
img_cell:
- justify-content: start
- align-items: start
- padding-left: 10px
- padding-bottom: 10px
custom_fields:
notification:
- border: 1px solid var(--text-color-on)
- border-radius: 12px
- font-size: 11px
- font-weight: bold
- height: 18px
- line-height: 18px
- min-width: 12px
- padding: 0px 3px
- position: absolute
- right: 5%
- top: 10%
About the color icon, for now, itās best if I focus on one piece of code at a time
Thx
You forgot/ need return
That is only available when active?