-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a prefixed class set service #235
Conversation
Added a new floorplan service set_prefixed_class which finds a class with the provided prefix and sets it's value (string after last prefix separator)
Hi there, Thanks for the PR. Have you tested it? |
I have tested it on my setup and it works. I didn't add too much error handling, but in the cases where I had entered something incorrectly in the yaml I did get some uncaught exceptions. I don't believe that would be a problem and could give some info to users as to what went wrong if they open console. |
Thanks for the reply. There's one thing we need to talk about: |
Wasn't aware of the dataset in the element (not super familiar with HTML5 and latest CSS). Happy to adjust the code to work with datasets instead of setting it on class. Will update the PR once implemented. |
Thanks! 😊 |
Added a new service dataset_set to floorplan.
@exetico dataset seemed like a much more simple solution with far less code! Have a look if you can approve these changes. |
It looks great. Thank you for the fast pivot to the dataset suggestion 😊. I'll secure it work on my instance right away, and push it to the upstream. |
It's getting late, and It has been a long day... But.... This is giving me the expected temperature from my entity like ``: - service: floorplan.dataset_set
service_data: 'temperature:${entity.state}' But this always set the - service: floorplan.dataset_set
service_data:
key: temperature
state: ${entity.state}
Please review this part, or tell me that I'm simply too tired to review code right now 😄 ... |
Oh, damn. Your docs says |
@exetico I made a mistake in the docs! My bad... |
Fixing the docs mistake
No problem. Thanks for the PR and quick change to dataset. I've considered to create that part by myself, for a good period of time - but there's too much things to handle right now. I'd also like to mention that is also closes #179 😄 ! |
For people visiting this through the release-notes. Here's the how-to: Short-hand: - service: floorplan.dataset_set
service_data: 'temperature:${entity.state}' Long version: - service: floorplan.dataset_set
service_data:
key: temperature
value: ${entity.state} For more information, see the docs. |
Based on the request in #179 added a new floorplan service called class_prefixed_set.
The way it works:
Say we have a prefix ha-light-state and the entity state is on, this will generate a class ha-light-state-on.
If the state changes to off, the service will look at current classes on the element and will try to find a class that matches the prefix (the match it will perform will be ha-light-state-).
If it finds multiple matches it will take the last one, which could be undesirable, but it's up to the user to make sure the class prefix for this element is unique.
If the class with such prefix is found, it will be changed to ha-light-state-off
If the class does not exist, the class will be added.