Closed murcin closed 1 year ago
have you tried this? secondary info: "zapisana: %variables.s_set:state °C"
yes I`ve try...
- entity: >
[[[ return variables.s_set ]]]
name: 'Zadana temp.:'
type: custom:numberbox-card
secondary_info: >
[[[ return "zapisana: %variables.s_set:state °C" ]]]
here is two options: 1) what I have right now 2) your solution - shows text - not value from entity
BTW - when I using in dashboard I can use direct access to entity - thats work... but I want to use like above with custom:button-card to have something like template
- entity: input_number.therm_julia
type: custom:numberbox-card
secondary_info: |
zapisana:<b style="color:white"> %sensor.tempset_julia:state °C</b>
try %%
as it may be escaping
[[[ return "zapisana: %%variables.s_set:state °C" ]]]
add %% makes the same but with % sign
instead of
secondary_info: >
[[[ return "zapisana: %variables.s_set:state °C" ]]]
have you tried
secondary_info: "zapisana: %variables.s_set:state °C"
as the first one is sending the variables directly to the card and do not get the updated information
I try it - not working :( first entity - working - not refreshing data second entity - not working, everything what I put wit " " or ' ' sign - does it as text...
how about if you put this way?
secondary_info: |
zapisana: %variables.s_set:state °C
without % we can see text...
with % got error with saving:
@murcin You keep using "[[[ ... ]]]" - WHY ? And you have been proposed several times not to use it. These "[[[ ...]]]" brackets are NOT specified in the docs (as well as "return") - then probably you should not use it.
you mean on line where is -entity? - because Ive used variables from custom:button-card - and line like this doesn
t work
and as I wrote above - when I try to use like this - shows me text:
and when I try to add % sign got error and can`t save file:
here I have small example and I think thats not problem with syntax... but your code can
t read variable state, have a look below, first example WORKS and there is
secondary_info: >
that works: %input_number.therm_gabinet:state °C
second the same but should read variable state: secondary_info: > that works: %variables.s_set:state °C
you mean on line where is -entity?
No, I guessed that this is a part of button-card. And you should NOT test your issue with "secondary_info" inside ANOTHER card. A code for testing your issue should be as simple as possible.
Two things are probably here:
First test your numberbox card OUTSIDE button-card.
I dont think that custom:button-card have any problem because I set variable to custom:numberbox-card and that
work, I made small experience:
1 entity as variable, secondary info from input_number - WORKS 2 entity as variable, secondary info from variable - DOESN`T work 3 entity as variable no custom:numberbox-card just entity - refreshing data works
so that`s mean custom:numberbox-card can read entity from variable correctly but reading secondary info not.
It looks like variables get out of scope or not available to numberbox.
I cannot test about the variables, if your first example works with input_number then numberbox is working correctly
Consider this example:
type: vertical-stack
cards:
- type: custom:button-card
name: "[ static text ]"
<<: &ref_settings
variables:
SENSOR: '[[[return entity.entity_id]]]'
entity: input_number.test_parrots
styles:
grid:
- grid-template-areas: '"i" "n" "numberbox"'
- grid-template-columns: 1fr
- grid-template-rows: 32px min-content min-content
custom_fields:
numberbox:
card:
type: custom:numberbox-card
entity: input_number.test_parrots
secondary_info: >-
[[[ return "<b style='color:red'>" + "static" + "</b>"]]]
- type: custom:button-card
name: "[ variable.xxx ]"
<<: *ref_settings
custom_fields:
numberbox:
card:
type: custom:numberbox-card
entity: input_number.test_parrots
secondary_info: >-
[[[ return "<b style='color:red'>" + states[variables.SENSOR].state + "</b>"]]]
- type: custom:button-card
name: "%entity"
<<: *ref_settings
custom_fields:
numberbox:
card:
type: custom:numberbox-card
entity: input_number.test_parrots
secondary_info: >-
<b style='color:red'> %input_number.test_parrots:state </b>
- type: custom:button-card
name: "% [ variable ]"
<<: *ref_settings
custom_fields:
numberbox:
card:
type: custom:numberbox-card
entity: input_number.test_parrots
secondary_info: >-
<b style='color:red'> %[[[return variables.SENSOR]]]:state </b>
cases 1, 2 - button-card-like templates are used ("[[[ ... ]]]"). cases 3, 4 - numberbox-like templates are used ("% ... ").
Note that you may combine html-formatting from "numberbox" and button-card-like templates (cases 1, 2).
Case 4 - does not work. It happens probably due to an order of resolving: first numberbox-level template is resolved (and fails), then button-card-level template is resolved (which fails too).
Regarding "no refresh". In my test, when I press "+ / -" buttons, the "secondary_info" is refreshed too - after a couple of seconds. Earlier I wrote about "monitored entities" - I meant a bit different situation: pressing "+ / -" affects some entity which is NOT defined as the MAIN entity for the button card, check here.
As a conclusion - this is not a bug of numberbox!
when I set secondary info as some entities that automatically not refreshing In this example I`ve use browser_mod.popup and shows variables
- entity: > [[[ return variables.s_set ]]] name: 'Zadana temp.:' type: custom:numberbox-card secondary info: > [[[ return 'zapisana: ' + states[variables.s_set].state + '°C' ]]]
I upload screen because formatting not works perfectly...after press + or - variable one line below change with secondary_info "Teraz" - means "Now" but secondary info from numberbox-card not refreshing: