-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add weekday to time contidion editor #6848
Conversation
I'll let Bram take the final look before merging. Also, I have only reviewed the code and not the actual implementation and usability. I may look at that later today |
@zsarnett thank you for that. |
No unfortunately this will not be in 0.115. Beta Cut was yesterday. Bug fixes and follow up PRs only for this release |
@bramkragten could you take a look at this? |
src/panels/config/automation/condition/types/ha-automation-condition-time.ts
Outdated
Show resolved
Hide resolved
src/panels/config/automation/condition/types/ha-automation-condition-time.ts
Outdated
Show resolved
Hide resolved
return css` | ||
.weekday-toggle { | ||
display: flex; | ||
height: 40px; |
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.
Why do we set the height to 40px? What is wrong with the default styling?
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.
If you don't set any day, it will trigger at every day, right? That is not clear from the UI |
Yes, that's right and I agree this isn't clear. Ideally, I should require at least one selected day and show warning/block saving if none are selected. What do you think about adding a title to the section and add a tooltip to it, something like here: #7006 (comment) |
Why not just turn the logic around and enable all switches by default? That would reflect the actual behavior without the need for explaining? |
@bramkragten I can do that, but how to inform the user that he will get the same behavior if he selects all or none? |
Saving it with none selected makes no sense, then it would not be true ever. So we should not allow that. Btw, an empty array will not result in the same behavior as all selected. Only having the weekday not set at all will. |
If I understand that correctly if someone deselects all days then the condition will always be False? So right, that shouldn't be allowed.
Is there a way to prevent saving automation/mark condition as not valid? I can show an error message (custom logic) but maybe there is something I can reuse. |
Well, we don't have to? As it would be logical that if you don't select any days it will not match ever? |
@bramkragten ok, I'll turn the logic around, and in future PR (with expansion panels) I'll add a tooltip with info that disabling all days will always make condition False. |
@bramkragten I've changed: @property({ attribute: false }) public condition!: TimeCondition to private _condition!: TimeCondition;
set condition(value:TimeCondition) {
this._condition = value;
this._condition.weekday = this._condition.weekday || ["mon","tue", "wed","thu","fri", "sat","sun"];
}
get condition() {
return this._condition;
} Is that fine? I want to assign all days if condition.weekday is empty or null. |
Just set the switches to checked when |
@bramkragten please take a final look at this. |
src/panels/config/automation/condition/types/ha-automation-condition-time.ts
Outdated
Show resolved
Hide resolved
@bramkragten @zsarnett thank you guys for the reviews! |
Breaking change
Proposed change
Replacement of #6786 (I messed up rebase, it is a small change, so it was easier to create new PR)

This is the first step to add weekday's support to time condition.
Next will be
ha-expand-panel
(#6726) that will allow us to hide (collapse) parts that aren't filledType of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: