-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Handle sequences under parallel actions #18470
Conversation
I think it would be helpful for review purposes if you include a screenshot of what your proposed UI looks like. Personally I do feel like this is an important missing component in the UI editor, I was actually looking for something like this recently and didn't even realize that parallel actions supported this sequential mode. However IMO I'm not sure that making every action into a sequence is the best UI, feels a bit cluttery to me, and possibly a bit confusing, as there are now multiple "add action" buttons on the screen, and it may not be explicitly clear that these groups are executed sequentially, I didn't see any indication of "sequential" in the displayed text. Maybe one possibility could be that when you click on "add action" in a parallel block, one of the choices in the dropdown could say "Run in sequence", and then selecting that would add the sequential action block, and leave the other items displayed as usual? Just a thought. |
I'd like to add screenshots, but my docker updated and now it's not possible to run HA in dev container - see https://community.home-assistant.io/t/failing-to-build-a-dev-container/529524/2 |
@karwosts , I managed to make my prod home assistant to use development frontend, and gt the screenshot from it. As you see, it's very similar to "choose" action. The main button, adding new "parallel branch", is called "Add parallel actions", while inside branch, the button is "Add action", same as everywhere else: |
@matthiasdebaat , is there anything else needed to merge this? |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, I was a couple of weeks offline. Thanks for making a UI for this! To fully understand it, can you share the YAML of your example? In conditions, every option is also collapsible. Is there a reason why you didn't use that same pattern here? |
Good idea about makingit collapsible, will look into it.
|
Not sure why it messes up the formatting when I put it in as "code" though... |
If you create it with a collapsible like conditions, I think it's good UI-wise. |
src/panels/config/automation/action/types/ha-automation-action-parallel.ts
Outdated
Show resolved
Hide resolved
Is there anything else needed @bramkragten @matthiasdebaat ? |
UI looks great, thanks! |
Cool, can it be merged then, please? |
Yes please, i am very much looking forward to this feature, since i am currently migrating my automations from AppDaemon to HA native, and i would need this UI element to complete the last automation which i would need to create in YAML otherwise. |
3de43ba
to
8c0f67e
Compare
I updated the PR to work with the latest updates of the automation reorder modes. About the PR itself: I think it is OK to add sequences to parallel actions, but I don't think this should be the default. Parallel actions are already pretty complicated and adding another layer in the form of sequences makes it even more complicated. I would propose to keep the default as single actions, and add a new button Sequences will then be supported in the UI, but the current experience is not made more complicated. |
Sequence actions also added via UI is very welcome, i handle mine via yaml in nested parallels but having them clean via the new building block would be very nice. |
Yes, that seems like a good solution. @surfingbytes is there any chance you are willing to implement the proposed solution? |
That is not possible to do in ha-automation-action-parallel. However, it will be possble to do by creating new class ha-automation-action-sequence, which could then be added anywhere via either "Add action" or "Add building block" -> there would be new action type "sequence". To me, it looks like a clean solution, but @bramkragten please confirm, before I start working on it. Thank you. |
Thank you. I'll create this new panel type for sequence, and instead of adding it to standard action types, I'll just add new button to parallel action. |
Can you please check it again @karwosts ? Parallel component is reverted to the same state as in "dev", just new "Add sequence of actions" button is added. New Sequence component is created. |
@surfingbytes can those three buttons be aligned in one line? |
You're not waiting for me, you need to wait for one of the maintainers to bless this.
I won't opine on if this is better as one row or two, but I think this could be done by adding a |
Good idea, thanks. Unfortunately it didn't work when I tried. Either I'm doing something wrong, or it has to do something with the fact that in this case, it would be parent adding elements to slot of it's child. The usage of slot I found in source code is always child adding elements to it's parent's slot. Anyway, is having it in one line necessary? There are other components (Choose, If-Then) that has commands in 2 lines. If it can be left in 2 lines, is there anything else that needs to be done to get this approved? |
I don't know if it's necessary, I just replied out of curiousity and a learning exercise. Anyway I think it does work, I tried like this: in ha-automation-action:
In ha-automation-action-parallel
You don't have to do it this way, I just mentioned as you had said you were trying to put them on one line. Sorry review is taking a while, thanks for your patience and your contribution! |
@karwosts , thank you for the example with slot. However, that i exactly what I did (and you can see it in the last commit), but not a single thing changed in UI - it's still in 2 rows. And when I put "test" string into the slot in ha-automation-action, the "test" is shown on the first line. But button remains on the second one. Really strange, but I don't know what is wrong with it. @Misiu is this requirement to get it approved? If not, can it be approved please? |
@@ -35,9 +37,33 @@ export class HaParallelAction extends LitElement implements ActionElement { | |||
@value-changed=${this._actionsChanged} | |||
.hass=${this.hass} | |||
></ha-automation-action> | |||
<ha-button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have the button after the automation action, it should be inside it:
<ha-automation-action
...
>
<ha-button ...></ha-button>
</ha-automation-action>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - just one small nit for grammar.
🎉 👏
Very excited for this change to land and be released! 🙏
Sorry for the late reply. |
@matthiasdebaat , if this UI is ok, could you please approve it? |
src/data/script.ts
Outdated
export interface ParallelAction extends BaseAction { | ||
parallel: ManualScriptConfig | Action | (ManualScriptConfig | Action)[]; | ||
parallel: SequenceAction[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should still accept config that is not in a list right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this was forgotten there and is now fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this look good now @bramkragten , or do I need to fix anything more?
We've discussed this PR with the team, and came to the conclusion that there is a simpler way; that also address other issues. Instead of trying to handle this for the parallel actions, the idea is to add a new building block: This solves a bunch of other use cases and removes almost all design decisions/exceptions we need to make. Building blocks are already generally available for the parallel action. Adding sequence to that, removes the need for extra buttons and what not. ../Frenck |
Thanks @frenck . When do you think we could expect that new functionality? Also, even if it's not going forward with this PR, I think some of these changes could come handy - for example ha-automation-action-sequence.ts and script_i18n.ts - as the GUI will still be needed. |
Well, it needs frontend support; recommended would be to build this frontend feature against that branch of that PR.
I think we can adjust/adopt this PR instead? Would you be able to do that? ../Frenck |
I've opened up an alternative PR on the building block approach instead. |
Oh, before I was able to get to this, I see it's already done. Big thanks! |
Proposed change
Currently, parallel action can run only single actions in parallel. However, you may need to run sequences of actions in parallel, for example sequence of actions "Robo vac go to bathroom", "wait for mop to be replaced", "clean house" in parallel with another sequence "morning announcements".
Currently, when parallel action contains sequence, it is not possible to edit in UI. This change allows to display it. Most logic was copied from "choose action"- without conditions of course. Right before the parallel action is rendered, it converts all standalone actions into sequence, so everything is displayed the same way.
This is replacement of stale PR 14166 which is impossible to update to latest codebase.
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: