Hi,Is it possible to show different cards depending on the status of a true / false sensor I want a card to be displayed if the sensor is true and a different card if the sensor is false?
I have an interesting issue. I’m using the code below and the card appears as a red line until I navigate to another view and then it loads properly. I’m using this on my tablets mounted to the wall with the custom header plug-in that has them in a kiosk mode so switching view’s is not normally possible. Any ideas on how to solve this?
- type: custom:card-templater
entities:
- sensor.time_date
card:
type: alarm-panel
style: |
.card-header {
font-size: 30px;
}
entity: alarm_control_panel.house_alarm
name_template: >-
{{as_timestamp(now()) | timestamp_custom('%A %b %d %I:%M %p') | replace(' 0',' ')}}
states:
- arm_away
- arm_home
- arm_night
What version are you using? If you are not on the latest version (0.0.9) can you try updating to that and see if it helps? That fixed an issue which was reported relating to the display of cards such as the iframe card when in panel mode (they would only take up part of the page). Although this doesn’t appear to be directly related to your issue, while reproducing the issue before creating the fix, I did get the same issue with the red line and the fix also seemed to have stopped that happening.
You can potentially do this by templating the type property using type_template, but this works best when the other options are the same between the different cards (e.g. switch between an entities or a glance card). For example:
type: 'custom:card-templater'
card:
type_template: >-
{{ "entities" if states.input_boolean.display_entities.state == "on" else "glance" }}
entities:
- light.light1
- light.light2
For anything other that that, it would probably be easier to use two Conditional cards in a Vertical Stack. You could still use the card-templater inside the Conditional card if you need to template other options in the cards.
I have Updated everything.
Hass Supervisor: 217
Home Assistant 0.108.5
Card Templater 0.0.9
It seems to work on my PC the first time but on my android phone and tablets I need to switch views for it to work properly.
I’m trying to change the state value with this configuration. But just can’t get it to work. What am I doing wrong? The state just showing 22 so the template is not applied at all.
card:
columns: 2
entities:
- entity: sensor.altandrr_access_control
state_template: >
{{ "One" if states.sensor.altandrr_access_control.state == "22" else
"Not One" }}
show_header_toggle: false
title: Places
type: entities
type: 'custom:card-templater'
The state_template option belongs under the entities collection of the card-templater rather than the templated card, like this:
card:
columns: 2
show_header_toggle: false
title: Places
type: entities
type: 'custom:card-templater'
entities:
- entity: sensor.altandrr_access_control
state_template: >
{{ "One" if states.sensor.altandrr_access_control.state == "22" else
"Not One" }}
(card-templater will pass its own entities to the templated card, so you don’t need it twice)
Super, thank you very much!
Is it only me thinking this sort of thing should be done in the backend with a template sensor?
Just trying to update this from Installed: 0.0.7 to 0.0.9 and get error
An error ocoured while processing
No module named ‘queueman’
Tried to step upgrade to 0.0.8 and get the same error.
Do I need to log an issue in Github?
I don’t use queueman in this card and that error looks like a Python error so, if it happens while trying to update, it looks more like an error in HACS (HACS does use the queueman package).
Thanks for the reply and for the project Steven. I will do some trouble shooting there.
Thank you for this awesome card. I was racking my brain for 3 days trying to get states into name:
fields. I tried to use config-tempate-card
but couldn’t get the syntax right, but yours just worked. Thank you!
Hi all!
I’m trying to template the bar-card, dynamically changing how the graph is displayed… if possible…
Based on reading I come up with following code for changing the target (2 charts for direct comparison, second one in the stack is actually templated):
type: 'custom:vertical-stack-in-card'
horizontal: true
cards:
- type: 'custom:card-templater'
card:
type: 'custom:bar-card'
entity: sensor.temp_max_1
direction: up
width: 40%
height: 150
min: 0
max: 30
target: 10
positions:
value: outside
name: 'off'
icon: 'off'
- type: 'custom:card-templater'
card:
type: 'custom:bar-card'
entity: sensor.temp_max_1
direction: up
width: 40%
height: 150
min: 0
max: 30
target_template: '{{ states(''input_number.watering_cycle'')|float}}'
positions:
value: outside
name: 'off'
icon: 'off'
Which gives following result:
As you can see it does not work… Graph on the right that should have target lowered to 4 is not showing at all, instead I get some strange highlight line at the top of the graph. It might mean that it is somehow working (something changing in bart-card confirguration), but the way I desire. Any idea?
I think it may be due to the templating engine always returning a string. To confirm this, could you try changing the non-templated one to have target: '10'
instead of target: 10
and see if it breaks it.
If that is the issue, I will need to work out how to solve it. I already implemented a fix for Boolean values (it casts “true” or “false” to a Boolean), but it won’t be as simple for integers or floats since it may depend on what the underlying card is expecting).
Edit: I noticed that you are missing the entities option for the templater, it should be something like this:
- type: 'custom:card-templater'
card:
type: 'custom:bar-card'
entity: sensor.temp_max_1
direction: up
width: 40%
height: 150
min: 0
max: 30
target_template: '{{ states(''input_number.watering_cycle'')|float}}'
positions:
value: outside
name: 'off'
icon: 'off'
entities:
- input_number.watering_cycle
That is currently needed so that it knows what entities to monitor for changes when processing the template.
Hi many thanks to Steven for making this card! very nice to see how easy you can apply tamplates. But I ran into a problem so hope you can help. I don’t know if it’s a bug or my setup today the question here:
I use the template card together with the pie chart, now it seems that the template card is getting in the way of real time updating of the pie chart. As soon as I apply a template the Pie chart only refreshes when refreshing the whole page. Is this something I can set?
type: 'custom:card-templater'
card:
type: 'custom:pie-chart-card'
entities:
- entity: counter.negative_hm2
name: Negative
- entity: counter.neutral_2_hm2
name: Neutral
- entity: counter.neutral_1_hm2
name: Neutral
- entity: counter.positive_hm2
name: Positief
title_template: '{{ states(''input_text.hm1'') }}'
total_amount: sensor.hm2
entity: input_text.hm1
I have run all the updates, use hassIO via virtualbox and edit and open in chrome.
hope you can help!
cheers Luuk
Try it like this and see if it helps:
type: 'custom:card-templater'
card:
type: 'custom:pie-chart-card'
entities:
- entity: counter.negative_hm2
name: Negative
- entity: counter.neutral_2_hm2
name: Neutral
- entity: counter.neutral_1_hm2
name: Neutral
- entity: counter.positive_hm2
name: Positief
title_template: '{{ states(''input_text.hm1'') }}'
total_amount: sensor.hm2
entities:
- input_text.hm1
hey! tnx for the fast reply, its to bad it dos not work i tryd to reboot and then test is but that did not work ether, is thare any place whare the card runst that is not real time?
cheers Luuk
Am using card-templater for the past 4+ months and it solved my needs. Thank you for that. But the page where the card has been using is getting crashed frequently. The only way is to refresh for web and restart the app in case of mobile. Could you please let me know what’s wrong?.
WebSocket is already in CLOSING or CLOSED state.
sendMessage @ bootstrap:2 (anonymous) @ bootstrap:2 subscribeMessage @ bootstrap:2 (anonymous) @ lovelace-card-templater.js:10 (anonymous) @ lovelace-card-templater.js:10 parseTemplate @ lovelace-card-templater.js:10 applyTemplate @ lovelace-card-templater.js:10 getCardConfig @ lovelace-card-templater.js:10 getCardConfig @ lovelace-card-templater.js:10 getCardConfig @ lovelace-card-templater.js:10 set hass @ lovelace-card-templater.js:10 (anonymous) @ hui-view.ts:51 value @ hui-view.ts:51 performUpdate @ bootstrap:2 _enqueueUpdate @ bootstrap:2
My config:
card:
entities:
- icon: 'mdi:router-wireless-settings'
name: DLink DHP1565 - Access Point
type: weblink
url_template: 'http://{{ states.device_tracker.dlinkap1.attributes.ip }}/'
- icon: 'mdi:router-wireless-settings'
name: DLink DIR655 - Access Point
type: weblink
url_template: 'http://{{ states.device_tracker.dlinkap2.attributes.ip }}/'
- icon: 'mdi:router-wireless-settings'
name: TP-Link TL-WA850RE - Range Extender
type: weblink
url_template: 'http://{{ states.device_tracker.tplinkre1.attributes.ip }}/'
- icon: 'mdi:router-wireless-settings'
name: Comfast CF-WR150N - Access Point
type: weblink
url_template: 'http://{{ states.device_tracker.comfastap1.attributes.ip }}/'
- icon: 'mdi:router-wireless-settings'
name: DLink DIR816L - Repeater
type: weblink
url_template: 'http://{{ states.device_tracker.dlinkre1.attributes.ip }}/'
show_header_toggle: false
title: Routers/Extenders
type: entities
entities:
- device_tracker.dlinkap1
- device_tracker.dlinkap2
- device_tracker.tplinkre1
- device_tracker.comfastap1
- device_tracker.dlinkre1
type: 'custom:card-templater'
The only thing I can think of is if you have briefly lost access to the Home Assistant server (do you get the “Connection lost. Reconnection…” popup?) which may interrupt the WebSocket connection it needs.
I’ll need to see if I can reproduce the issue first, and then I may be able to implement a fix to handle it.