Thanks for the answers, I read the articles but that did not enable me to solve my problem.
I did not do any web projects since 2012 so my knowledge is rather old^^
What I need is basically a value for Scaling that changes dynamically depending on the viewport.
The following things I was able to get from the articles:
1.)
card_mod:
style: |
ha-card {
{% if is_state('input_boolean.test_boolean','on') %}
--my-transform-style: translate(-50%,-50%) rotate(-0.25turn);
{% else %}
--my-transform-style: translate(-50%,-50%)
{% endif %}
}
I could create this my-transform-style but the if is checked within HA, not on the device. The information is there because I use Browser-Mod.
But I would need to:
- create a list of all devices in Browser-Mod
- check which of these have a binary-sensor with the same name as the device that is currently on and the sensor Browser-User’s value needs to be the name of the currently logged in user on my viewing device
- take the first item from the list and return Browser Width
I have no Idea how to write that kind of code within HA so next idea…
2.) I could use “mediaquery”, but I have no idea what the correct syntax is and how to combine that with my picture elements card-
3.) I could use card-mod and style like so:
type: picture-elements
card_mod:
style: |
ha-card
{
@media (min-width: 1921px) and (max-width: 3840px) {
--my-transform-style: translate(-50%,-50%) scale(0.1,0.1);
}
:|
@media (max-width: 500px) {
--my-transform-style: translate(-50%,-50%) scale(0.5,0.5);
}
}
and:
- entity: sensor.hmip_wth_2_000a9f298a14bc_actual_temperature
style:
left: 40%
top: 1.5%
transform: var(--my-transform-style)
type: state-badge
But I probably got the syntax all wrong it does not work at all.
4.)
The best solution for me would be using this:
style: |
ha-card {
{% set ANGLE = states('input_number.test_number') + 'deg' %}
--my-transform-style: translate(-50%,-50%) rotate({{ANGLE}});
}
With scale instead of angle and somehow get the viewport width of the browser from somewhere….
What is the best solution?
Regards
Martin