Spinning fan color

I have a spinning fan in my floorplan. How can I change the color when it starts spinning? Do I need to change the svg source or can I use a fill function?

I tried this below with no luck
image

- entity: switch.office_fan
      element: switch.office_fan
      tap_action: toggle
      state_action:
        action: call-service
        service: floorplan.class_set
        service_data:
          fill: '${ entity.state === "on" ? "#FF7F7F" : "#BAF5B8" }'
          transition: '${ entity.state === "on" ? "fill 5s ease" : "" }'
          class: '${(entity.state === "on") ? "spinning" : ""}'

You have used class set but then tried to add a style. It is one or the other and you use class set or style set

1 Like

how would you go about either setting the class to change the color of the element when it spins?

or would you use image_set to change this image to a differen svg then use set_class?

I played around with the yaml code then css and can’t figure out a solution.

OK, here is my code so far. when I debug, it appears to call the correct images but for some reason, I don’t see them. Is there a way to find out if they are just off screen?

here is the code I’m using

- entity: switch.office_fan
      element: switch.office_fan
      tap_action: toggle
      state_action:
        - service: floorplan.image_set
          service_data: /local/floorplan/multi_floor/fan_${entity.state}.svg
        - service: floorplan.class_set
          service_data:
            class: '${(entity.state === "on") ? "spinning" : ""}'

see the fan_on, fan_off is called.

Yes you would add to the css by adding that fill and transition to the class. That may or may not work depending on what the fan image is. Yes replacing the image with a different one might be another solution.

Yes having the image fly off screen is a known possibility. This is usually indicated by the fan being visible and then disappearing when you turn it on. I am away from home at the moment but search the various threads here and you will find the css needed.

the fan spinning worked fine before I added the extra service to swap the image.

I used this method to keep the fan in place. I added the group in the SVG using textpad++

<g
   id="switch.office_fan_group"
   transform="translate(-79.85309,46.790904)"><g
     id="switch.office_fan"><path

when I added these lines my fan disappeared. I don’t even see it at all regardless of state

- service: floorplan.image_set
  service_data: /local/floorplan/multi_floor/fan_${entity.state}.svg

Turn on the logging or look in the console for errors. Can the icon be found?

there are no errors in the log. when the image initially loads, I see the fan flash then its gone. its like when the entity status is updates the image its gone. I’m guessing its out in space somewhere. not sure how to correct it.
the animation works fine with the element in the svg file. when I add the lines below to change the image thats where the problem is. I’m thinking, I may need to apply some position to the css so it doesn’t move?

- service: floorplan.image_set
  service_data: /local/floorplan/multi_floor/fan_${entity.state}.svg

You could start by removing the class set which would mean you will know if it is the css that is the problem.
Have a look at the thread here which is talking about making spinning fans work. Look above and below the link Share your Floorplan - #324 by keithh666

So I finally got it! here is the final code for that element. Now onto the next.

- entity: switch.office_fan
      element: switch.office_fan
      tap_action: toggle
      state_action:
        - service: floorplan.image_set
          service_data: /local/floorplan/multi_floor/fan_${entity.state}.svg
        - service: floorplan.class_set
          service_data:
            class: '${(entity.state === "on") ? "spinning" : ""}'
1 Like