Hi, I’ve an issue in hidding/showing in my FloorPlan a layer (object) based on an entity.state value.
I want to show a box with a battery warning (if this value is low) beside of temperature humidity.
context :
I edit my .yaml on an external editor and use git to sync it on HomeAssistant.
I use Floorplan base base on a svg file :
- type: custom:floorplan-card
config:
image: /local/plan-maison.svg
stylesheet: /local/multifloor.css
My FloorPlan is base on the ‘Multi Floor Example’. All seems ok, I can change floor and I’m able to show inside the value of my sensor on each floor (temperature/humidity).
I add a box in my svg and also an icon with right ID : [sensor.salle_de_bain_box, sensor.salle_de_bain_low, sensor.salle_de_bain_latency] (latency is for a future usage).
If I use the code bellow I can check that hiding is functional.
- entity: sensor.salle_de_bain_battery
service: floorplan.class_set
service_data:
class: |
>
var power = 2.5;
if (power < 1)
return "layer-visible";
else
return "layer-invisible";
elements:
- sensor.salle_de_bain_box
- sensor.salle_de_bain_low
If I change manually inside code the value of ‘power’ it works.
I’ve 2 separate element : [sensor.salle_de_bain_box, sensor.salle_de_bain_low] because I want to be able to also show latency trouble in the same box.
I’ve tried to change ‘var power = 2.5;’ to one of the following but with no chance :
- var power = states(‘entity.state’);
- var power = states(entity.state);
- var power = change ‘var power = 2.5;’ to states(‘sensor.salle_de_bain_battery’);
- var power = states(‘sensor.salle_de_bain_battery’) | float(1);
- var power = (entity.attributes.battery);
- var power = states(sensor.chambre_battery.state);
- var power = states.sensor.salle_de_bain_battery.state;
In the dev tool (developer-tools/template) I can make it work like this :
How can I make it works inside my .yaml ?
Thanks.