Support time entities in automation time conditions/triggers selectors (#21069)

Co-authored-by: Simon Lamon <32477463+silamon@users.noreply.github.com>
This commit is contained in:
Mark Bergsma 2024-11-26 15:41:59 +01:00 committed by GitHub
parent bd0bfc1fbe
commit 39b00f1063
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View File

@ -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(

View File

@ -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.");

View File

@ -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%]",