ThePierre
(Pierre Constantin)
October 27, 2022, 3:02pm
1
hello
I have installed variable and habe a variable var.url_flight with an url
I want to use it in a iframe but it does work
working in template editor : my variable is {{states(‘var.url_flight’)}}
not working with iframe
type: iframe
url: {{states (’ var.url_flight ')}}
aspect_ratio: 75%
title: flight details
any help
The iframe card does not support templates. Place the whole card into config-template-card.
UlrichC
(Ulrich)
July 31, 2023, 7:51am
4
Could you please give me an example? I want to show a website as iframe with var in the url. Thanks.
Smth like
type: custom:config-template-card
entities:
- ....
card:
type: iframe
url: '${ ... add JS code here ...}'
...
Check docs for config-template-card for details.
An example:
How to calculate a route between 2 points (not sure if ALL countries are supported)
type: horizontal-stack
cards:
- type: entities
title: Yandex Maps
entities:
- type: section
label: From
- entity: input_number.test_latitude_1
name: Latitude
- entity: input_number.test_longitude_1
name: Longitude
- type: section
label: To
- entity: input_number.test_latitude_2
name: Latitude
- entity: input_number.test_longitude_2
name: Longitude
- type: custom:config-template-card
variables:
varLAT_FROM: states['input_number.test_latitude_1']
varLONG_FROM: states['input_number.test_longitude_1']
varLAT_TO: states['input_number.test_latitude_2']
varLONG_TO: states['input_number.test_longitude_2']
entities:
- ${varLAT_FROM.entity_id}
- ${varLONG_FROM.entity_id}
- ${varLAT_TO.entity_id}
- ${varLONG_TO.entity_id}
card:
type: iframe
aspect_ratio: '1:1'
url: >-
${
"https://yandex.ru/maps/?mode=routes&rtext=" +
varLAT_FROM.state +
"%2C" +
varLONG_FROM.state +
"~" +
varLAT_TO.state +
"%2C" +
varLONG_TO.state +
"&rtt=auto&ruri=~"
}