Oh, right. I can remove that forst class_set 'cause i already set a class here…
I’m leaving the dots in for now, just so that I can confirm that everything is still loading without me having to enable the Dyson fan to give me a measured temp.
I would say yes. You can have the very bottom image in the SVG the day image and then immediately above that have a night image. Use an input_boolean to determine when night and day is and use that to control the visibility of the night layer.
There are a heaps of ways to decide when night is but this is a simple one:
binary_sensor:
- platform: template
is_night_time:
friendly_name: "Is it Night Time Boolean"
value_template: >-
{{ is_state('sun.sun', 'below_horizon') }}
Then just a simple rule in your lovelace yaml:
rules:
- entities:
- binary_sensor.is_night_time
name: Show or Hide the Night Time Image
state_action:
service: floorplan.class_set
service_data:
class: '${(entity.state === "true") ? "always-visible" : "always-invisible"}'
You would then put your two images in your SVG with the night time one on top and label the night time one binary_sensor.is_night_time
Actually I had a typo I am not sure if you fixed it. In the rules input_boolean.is_night_time should be binary_sensor.is_night_time I have fixed it in my post above. If you did fix that or if it still doesn’t work you will need to be more specific as to what doesn’t work and what you tried to get it to work.
It’s not clear what you expect to happen. You are just setting a class when you hover? When you say it doesn’t work what do you observe? What do you expect to happen? Are you using the browser dev console to inspect the applied CSS classes? Please also supply your CSS.
Start by inspecting with the browser tools and you should be able to see the class that is applied to that element. See if it changes with the state change. However you will have the problem that if the attribute changes but the state does not then you won’t see any change in the floorplan. You might have to find a way around that. For example, make the entity sensor.date_time and then it will update each minute. If you do this then don’t forget you will have to use the hass entity that I showed above to get access to the required attribute.
Thank you for raising the question, and provide the needed information to look into the case.
Sadly the short answer is, that hover_action doesn’t allow that kind of action(s).
It’s executed in a more isolated flow. Personally I’d be worried about triggering things a bit too often, if we’re not spending extra time on limiting the executing while the user randomly mouse over a element. However, it shouldn’t be that hard, though. The code stack are currently a bit stuck, cause we’re waiting to roll out a interesting feature, hopefully in the upcoming weeks.
The more technical answer is:
We’re using the handleEntityIdSetHoverOver function in the loadBitmapImage and loadSvgImage flow.
For the entityInfo we’re looking at the rules, and check if hover_action is defined, and use our 'hover-info` solution to show the information.
But it’s possible to add the logics to our solution. I’ve already spend a few hours looking at that part of the code, just to be sure I won’t break anything. That part of the solution is created by OP, so I was not 100% sure about how to expand it.
Overwrite your existing floorplan.js, and secure that the old one are not hanging in the cache and playing with you.
With that said. Let me know what you think, and PLEASE respond in a new Discussion on GitHub where you create a ref. to the original question from this thread . That helps us have a better overview of each question, and sharing solutions in general. Thanks!
In the new thread on Github Discussion, please tell why you’re hardcoding hover as a class, instead of using :hover as the only selector, just so I understand that part, too.
For other people dropping by, please use the new thread: