Support for timestamp sensors in time trigger automation UI (#15292)

* Support for timestamp sensors in time trigger automation UI

* rename var

* simply filter function

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>

* rename var

* use new entity filter options

---------

Co-authored-by: Paul Bottein <paul.bottein@gmail.com>
This commit is contained in:
karwosts 2023-02-20 06:30:40 -08:00 committed by GitHub
parent 8754947133
commit d5fb924cb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 6 deletions

View File

@ -63,7 +63,14 @@ export class HaTimeCondition extends LitElement implements ConditionElement {
{
name: "after",
selector: inputModeAfter
? { entity: { domain: "input_datetime" } }
? {
entity: {
filter: [
{ domain: "input_datetime" },
{ domain: "sensor", device_class: "timestamp" },
],
},
}
: { time: {} },
},
{
@ -88,7 +95,14 @@ export class HaTimeCondition extends LitElement implements ConditionElement {
{
name: "before",
selector: inputModeBefore
? { entity: { domain: "input_datetime" } }
? {
entity: {
filter: [
{ domain: "input_datetime" },
{ domain: "sensor", device_class: "timestamp" },
],
},
}
: { time: {} },
},
{
@ -111,10 +125,12 @@ export class HaTimeCondition extends LitElement implements ConditionElement {
protected render() {
const inputModeBefore =
this._inputModeBefore ??
this.condition.before?.startsWith("input_datetime.");
(this.condition.before?.startsWith("input_datetime.") ||
this.condition.before?.startsWith("sensor."));
const inputModeAfter =
this._inputModeAfter ??
this.condition.after?.startsWith("input_datetime.");
(this.condition.after?.startsWith("input_datetime.") ||
this.condition.after?.startsWith("sensor."));
const schema = this._schema(
this.hass.localize,

View File

@ -26,7 +26,14 @@ export class HaTimeTrigger extends LitElement implements TriggerElement {
private _schema = memoizeOne(
(localize: LocalizeFunc, inputMode?: boolean) => {
const atSelector = inputMode
? { entity: { domain: "input_datetime" } }
? {
entity: {
filter: [
{ domain: "input_datetime" },
{ domain: "sensor", device_class: "timestamp" },
],
},
}
: { time: {} };
return [

View File

@ -2131,7 +2131,7 @@
},
"time": {
"type_value": "Fixed time",
"type_input": "Value of a date/time helper",
"type_input": "Value of a date/time helper or timestamp-class sensor",
"label": "Time",
"at": "At time",
"mode": "Mode"