Support limits in sensor card editor (#24358)

* Support `limits` in sensor card editor

* Add new translation keys for limit min/max
This commit is contained in:
Flo Edelmann 2025-02-25 10:19:13 +01:00 committed by GitHub
parent bb672d0272
commit db5036aed3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 1 deletions

View File

@ -32,6 +32,12 @@ const cardConfigStruct = assign(
detail: optional(number()),
theme: optional(string()),
hours_to_show: optional(number()),
limits: optional(
object({
min: optional(number()),
max: optional(number()),
})
),
})
);
@ -83,6 +89,20 @@ const SCHEMA = [
},
],
},
{
type: "grid",
name: "limits",
schema: [
{
name: "min",
selector: { number: { mode: "box" } },
},
{
name: "max",
selector: { number: { mode: "box" } },
},
],
},
] as const;
@customElement("hui-sensor-card-editor")
@ -143,6 +163,14 @@ export class HuiSensorCardEditor
return this.hass!.localize(
"ui.panel.lovelace.editor.card.sensor.graph_type"
);
case "min":
return this.hass!.localize(
"ui.panel.lovelace.editor.card.sensor.limit_min"
);
case "max":
return this.hass!.localize(
"ui.panel.lovelace.editor.card.sensor.limit_max"
);
default:
return this.hass!.localize(
`ui.panel.lovelace.editor.card.generic.${schema.name}`

View File

@ -7120,7 +7120,9 @@
"name": "Sensor",
"show_more_detail": "Show more detail",
"graph_type": "Graph type",
"description": "The Sensor card gives you a quick overview of your sensors state with an optional graph to visualize change over time."
"description": "The Sensor card gives you a quick overview of your sensors state with an optional graph to visualize change over time.",
"limit_min": "Minimum value",
"limit_max": "Maximum value"
},
"todo-list": {
"name": "To-do list",