Skip to content

Commit 9148a2c

Browse files
committed
improve display of schedules with state 'completed'
1 parent c037bbe commit 9148a2c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/components/scheduler-item-row.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class SchedulerItemRow extends LitElement {
2323
try {
2424
const stateObj = this.hass.states[this.schedule.entity_id!];
2525
if (!stateObj) return html``;
26-
const disabled = stateObj.state == 'off';
26+
const disabled = ['off', 'completed'].includes(stateObj.state);
2727
const nextAction = this.schedule.entries[0].slots[this.schedule.next_entries[0] || 0].actions[0];
2828

2929
let icon = computeActionIcon(nextAction, this.config.customize);
@@ -52,10 +52,11 @@ export class SchedulerItemRow extends LitElement {
5252
</div>
5353
</div>
5454
<div class="state">
55-
<ha-entity-toggle
56-
.hass=${this.hass}
57-
.stateObj=${stateObj}
58-
></ha-entity-toggle>
55+
<ha-switch
56+
?checked=${['on', 'triggered'].includes(stateObj.state || '')}
57+
?disabled=${stateObj.state == 'completed'}
58+
@click=${this._toggleEnableDisable}
59+
></ha-switch>
5960
</div>
6061
6162
`;
@@ -114,6 +115,12 @@ export class SchedulerItemRow extends LitElement {
114115
this.dispatchEvent(myEvent);
115116
}
116117

118+
private _toggleEnableDisable(ev: Event) {
119+
ev.stopPropagation();
120+
const checked = !(ev.target as HTMLInputElement).checked;
121+
this.hass.callService('switch', checked ? 'turn_on' : 'turn_off', { entity_id: this.schedule.entity_id });
122+
}
123+
117124

118125
static get styles(): CSSResultGroup {
119126
return css`

0 commit comments

Comments
 (0)