From 39b00f1063b4517e7a9ee50665837e883858c89a Mon Sep 17 00:00:00 2001 From: Mark Bergsma Date: Tue, 26 Nov 2024 15:41:59 +0100 Subject: [PATCH] Support time entities in automation time conditions/triggers selectors (#21069) Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com> --- .../condition/types/ha-automation-condition-time.ts | 4 ++++ .../automation/trigger/types/ha-automation-trigger-time.ts | 6 +++++- src/translations/en.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/panels/config/automation/condition/types/ha-automation-condition-time.ts b/src/panels/config/automation/condition/types/ha-automation-condition-time.ts index c7254d234f..07ed5d4e4b 100644 --- a/src/panels/config/automation/condition/types/ha-automation-condition-time.ts +++ b/src/panels/config/automation/condition/types/ha-automation-condition-time.ts @@ -67,6 +67,7 @@ export class HaTimeCondition extends LitElement implements ConditionElement { entity: { filter: [ { domain: "input_datetime" }, + { domain: "time" }, { domain: "sensor", device_class: "timestamp" }, ], }, @@ -99,6 +100,7 @@ export class HaTimeCondition extends LitElement implements ConditionElement { entity: { filter: [ { domain: "input_datetime" }, + { domain: "time" }, { domain: "sensor", device_class: "timestamp" }, ], }, @@ -126,10 +128,12 @@ export class HaTimeCondition extends LitElement implements ConditionElement { const inputModeBefore = this._inputModeBefore ?? (this.condition.before?.startsWith("input_datetime.") || + this.condition.before?.startsWith("time.") || this.condition.before?.startsWith("sensor.")); const inputModeAfter = this._inputModeAfter ?? (this.condition.after?.startsWith("input_datetime.") || + this.condition.after?.startsWith("time.") || this.condition.after?.startsWith("sensor.")); const schema = this._schema( diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-time.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-time.ts index 25345f9985..e72a60dd02 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-time.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-time.ts @@ -65,6 +65,7 @@ export class HaTimeTrigger extends LitElement implements TriggerElement { entity: { filter: [ { domain: "input_datetime" }, + { domain: "time" }, { domain: "sensor", device_class: "timestamp" }, ], }, @@ -106,7 +107,9 @@ export class HaTimeTrigger extends LitElement implements TriggerElement { const entity = typeof at === "object" ? at.entity_id - : at?.startsWith("input_datetime.") || at?.startsWith("sensor.") + : at?.startsWith("input_datetime.") || + at?.startsWith("time.") || + at?.startsWith("sensor.") ? at : undefined; const time = entity ? undefined : (at as string | undefined); @@ -127,6 +130,7 @@ export class HaTimeTrigger extends LitElement implements TriggerElement { if (Array.isArray(at)) { return nothing; } + const data = this._data(this._inputMode, at); const showOffset = data.mode === MODE_ENTITY && data.entity?.startsWith("sensor."); diff --git a/src/translations/en.json b/src/translations/en.json index 73747267f5..62ae6c2c43 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -3145,7 +3145,7 @@ }, "time": { "type_value": "Fixed time", - "type_input": "Value of a date/time helper or timestamp-class sensor", + "type_input": "Value of a date/time helper, time entity or timestamp-class sensor", "label": "Time", "at": "At time", "offset": "[%key:ui::panel::config::automation::editor::triggers::type::sun::offset%]",