Skip to content

Change svg image based on entity state #244

Answered by exetico
m90att asked this question in Q&A
Discussion options

You must be logged in to vote

Hi

It's great to see people trying. That's the only way to make progress in a new space.

TL;DR: Use entity.state in your switch-statement, and you're golden.

Answer:
I've created the sensor so the day, evening and more works as expected.

My YAML looks like this:

element: area.office
entity: sensor.timeofday
tap_action: false
hover_action: false
state_action:
  - action: call-service
    service: floorplan.image_set
    service_data: |
        >
        console.log("Entity Info - Debug info:", entity);
        switch (entity.state) {
          case "day":
            return "/local/floorplan/__test/fp-test-day.svg";
          case "evening":
            return "/local/floorplan/__test/fp-…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@m90att
Comment options

@exetico
Comment options

Answer selected by m90att
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants