-
Hi, I have a problem that I've googled, searched the community and other discussions for pointers but ultimately, I've found nothing that really fits my situation. Nor am I experienced enough to troubleshoot beyond basic levels and I'm now beyond confused, so I'm reaching out for some expert advice - I'm sure this is straightforward - I just can't see it. I've got a floorplan [background] svg that I want to change depending on the time of day. I've borrowed an example of a time of day sensor which is working well...
My yaml image config is:
I currently have 3 svgs created, 'day', 'evening', 'night' and I want the night one to be the default. In inkscape the following holds the background... The code I've added to the yaml rules is:
but nothing happens, it always shows floorplan_night. What am I doing wrong?! Thank you v much, Matt |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi It's great to see people trying. That's the only way to make progress in a new space. TL;DR: Use Answer: 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-test-evening.svg";
default:
return "/local/floorplan/__test/fp-test-default.svg";
} Please take a look at the Open the Inspect window in your browser, navigate to the console-window, and take a short time to look at the entity-object: Here you'll see that the "entity" contains more than a single value. It's an object, with multiple properties. You could also check if Here's my result, with the test- And here's the result with test- Bonus info: Here's a example with the new The element: area.office
entity: sensor.timeofday
tap_action: false
hover_action: false
state_action:
- action: call-service
service: floorplan.dataset_set
service_data:
key: timeofday
value: ${entity.state} Here's even more about Javascript Objects, if you're ready for a ride: https://www.w3schools.com/js/js_objects.asp |
Beta Was this translation helpful? Give feedback.
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: