mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-15 05:16:34 +00:00
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:
parent
bd0bfc1fbe
commit
39b00f1063
@ -67,6 +67,7 @@ export class HaTimeCondition extends LitElement implements ConditionElement {
|
|||||||
entity: {
|
entity: {
|
||||||
filter: [
|
filter: [
|
||||||
{ domain: "input_datetime" },
|
{ domain: "input_datetime" },
|
||||||
|
{ domain: "time" },
|
||||||
{ domain: "sensor", device_class: "timestamp" },
|
{ domain: "sensor", device_class: "timestamp" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -99,6 +100,7 @@ export class HaTimeCondition extends LitElement implements ConditionElement {
|
|||||||
entity: {
|
entity: {
|
||||||
filter: [
|
filter: [
|
||||||
{ domain: "input_datetime" },
|
{ domain: "input_datetime" },
|
||||||
|
{ domain: "time" },
|
||||||
{ domain: "sensor", device_class: "timestamp" },
|
{ domain: "sensor", device_class: "timestamp" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -126,10 +128,12 @@ export class HaTimeCondition extends LitElement implements ConditionElement {
|
|||||||
const inputModeBefore =
|
const inputModeBefore =
|
||||||
this._inputModeBefore ??
|
this._inputModeBefore ??
|
||||||
(this.condition.before?.startsWith("input_datetime.") ||
|
(this.condition.before?.startsWith("input_datetime.") ||
|
||||||
|
this.condition.before?.startsWith("time.") ||
|
||||||
this.condition.before?.startsWith("sensor."));
|
this.condition.before?.startsWith("sensor."));
|
||||||
const inputModeAfter =
|
const inputModeAfter =
|
||||||
this._inputModeAfter ??
|
this._inputModeAfter ??
|
||||||
(this.condition.after?.startsWith("input_datetime.") ||
|
(this.condition.after?.startsWith("input_datetime.") ||
|
||||||
|
this.condition.after?.startsWith("time.") ||
|
||||||
this.condition.after?.startsWith("sensor."));
|
this.condition.after?.startsWith("sensor."));
|
||||||
|
|
||||||
const schema = this._schema(
|
const schema = this._schema(
|
||||||
|
@ -65,6 +65,7 @@ export class HaTimeTrigger extends LitElement implements TriggerElement {
|
|||||||
entity: {
|
entity: {
|
||||||
filter: [
|
filter: [
|
||||||
{ domain: "input_datetime" },
|
{ domain: "input_datetime" },
|
||||||
|
{ domain: "time" },
|
||||||
{ domain: "sensor", device_class: "timestamp" },
|
{ domain: "sensor", device_class: "timestamp" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -106,7 +107,9 @@ export class HaTimeTrigger extends LitElement implements TriggerElement {
|
|||||||
const entity =
|
const entity =
|
||||||
typeof at === "object"
|
typeof at === "object"
|
||||||
? at.entity_id
|
? at.entity_id
|
||||||
: at?.startsWith("input_datetime.") || at?.startsWith("sensor.")
|
: at?.startsWith("input_datetime.") ||
|
||||||
|
at?.startsWith("time.") ||
|
||||||
|
at?.startsWith("sensor.")
|
||||||
? at
|
? at
|
||||||
: undefined;
|
: undefined;
|
||||||
const time = entity ? undefined : (at as string | undefined);
|
const time = entity ? undefined : (at as string | undefined);
|
||||||
@ -127,6 +130,7 @@ export class HaTimeTrigger extends LitElement implements TriggerElement {
|
|||||||
if (Array.isArray(at)) {
|
if (Array.isArray(at)) {
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = this._data(this._inputMode, at);
|
const data = this._data(this._inputMode, at);
|
||||||
const showOffset =
|
const showOffset =
|
||||||
data.mode === MODE_ENTITY && data.entity?.startsWith("sensor.");
|
data.mode === MODE_ENTITY && data.entity?.startsWith("sensor.");
|
||||||
|
@ -3145,7 +3145,7 @@
|
|||||||
},
|
},
|
||||||
"time": {
|
"time": {
|
||||||
"type_value": "Fixed 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",
|
"label": "Time",
|
||||||
"at": "At time",
|
"at": "At time",
|
||||||
"offset": "[%key:ui::panel::config::automation::editor::triggers::type::sun::offset%]",
|
"offset": "[%key:ui::panel::config::automation::editor::triggers::type::sun::offset%]",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user