I have a few things that won’t change color (set class) in my floorplan. I’ve made this super-simplified version for testing:
With this yaml:
type: custom:floorplan-card
config:
image:
location: /local/floorplan/tesla/test.svg
cache: false
stylesheet:
location: /local/floorplan/tesla/test.css
cache: false
console_log_level: warn
defaults:
hover_action: hover-info
tap_action: more-info
hold_action: more-info
rules:
- name: Car
entities:
- entity: input_boolean.guest_mode
element: car
state_action:
- service: floorplan.class_set
service_data: '${(entity.state === "on") ? "icon-stroke-red" : "icon-stroke-grey"}'
- name: Line
entities:
- entity: input_boolean.guest_mode
element: line
state_action:
- service: floorplan.class_set
service_data: '${(entity.state === "on") ? "icon-stroke-red" : "icon-stroke-grey"}'
- name: Line Group
entities:
- entity: input_boolean.guest_mode
element: line-group
state_action:
- service: floorplan.class_set
service_data: '${(entity.state === "on") ? "icon-stroke-red" : "icon-stroke-grey"}'
- name: Line Group
entities:
- entity: input_boolean.guest_mode
element: rect
state_action:
- service: floorplan.class_set
service_data: '${(entity.state === "on") ? "icon-fill-red" : "icon-fill-grey"}'
- name: Line Group
entities:
- entity: input_boolean.guest_mode
element: rect-group
state_action:
- service: floorplan.class_set
service_data: '${(entity.state === "on") ? "icon-fill-red" : "icon-fill-grey"}'
- name: Line Group
entities:
- entity: input_boolean.guest_mode
element: lock
state_action:
- service: floorplan.class_set
service_data: '${(entity.state === "on") ? "icon-fill-red" : "icon-fill-grey"}'
- name: Line Group
entities:
- entity: input_boolean.guest_mode
element: line-rect
state_action:
- service: floorplan.class_set
service_data: >-
${(entity.state === "on") ? "icon-stroke-and-fill-red" :
"icon-stroke-and-fill-grey"}
and this in the css
/* Stroke icon binary state */
.icon-stroke-red {
stroke: #b20000 !important;
stroke-opacity: 1 !important;
}
.icon-stroke-grey {
stroke: #5a5a5a !important;
stroke-opacity: 1 !important;
}
/* Fill icon binary state */
.icon-fill-red {
fill: #b20000 !important;
fill-opacity: 1 !important;
}
.icon-fill-grey {
fill: #5a5a5a !important;
fill-opacity: 1 !important;
}
/* Stroke And Fill icon binary state */
.icon-stroke-and-fill-red {
fill: #b20000 !important;
fill-opacity: 1 !important;
stroke: #b20000 !important;
stroke-opacity: 1 !important;
}
.icon-stroke-and-fill-grey {
fill: #5a5a5a !important;
fill-opacity: 1 !important;
stroke: #5a5a5a !important;
stroke-opacity: 1 !important;
}
As soon as something is a group, the class is not set. Here’s the svg, and this is what it looks like in HA with input_boolean.guest_mode
“on”:
Only the “single” objects (lock
, line
, and rect
) works. Anything else (anything blue) does not, and the only common feature I can think of, is that they’re all “groups”.
Of course, if I select any of the groups in inkscape and set the stroke or fill color, respectively, that works as expected.
Is there something special you need to do to assign a class to an svg “group”?