Use generic alarm entity and consistent time domain labels

This commit is contained in:
Jindrich.Stepan
2026-10-05 00:52:32 +02:00
parent 81ca4cfb53
commit 326c195dfd
4 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ hide:
name: true name: true
``` ```
### Time entity ### `time` entity
```yaml ```yaml
type: custom:time-picker-card type: custom:time-picker-card
+1 -1
View File
@@ -5,7 +5,7 @@ import { customElement, property } from 'lit/decorators.js';
import { TimePickerCardConfig } from './types'; import { TimePickerCardConfig } from './types';
const NAME_TO_LABEL_MAP: Record<string, string> = { const NAME_TO_LABEL_MAP: Record<string, string> = {
entity: 'Time or input_datetime entity id', entity: 'time or input_datetime entity id',
name: 'Name', name: 'Name',
hour_step: 'Hour step', hour_step: 'Hour step',
minute_step: 'Minute step', minute_step: 'Minute step',
+1 -1
View File
@@ -192,7 +192,7 @@ export class TimePickerCard extends LitElement implements LovelaceCard {
if (domain === TIME_ENTITY_DOMAIN) { if (domain === TIME_ENTITY_DOMAIN) {
const match = /^(\d{2}):(\d{2}):(\d{2})$/.exec(this.entity.state); const match = /^(\d{2}):(\d{2}):(\d{2})$/.exec(this.entity.state);
if (!match || Number(match[1]) > 23 || Number(match[2]) > 59 || Number(match[3]) > 59) { if (!match || Number(match[1]) > 23 || Number(match[2]) > 59 || Number(match[3]) > 59) {
return Partial.error('Time entity has no valid HH:MM:SS value', this.config); return Partial.error('The time entity has no valid HH:MM:SS value', this.config);
} }
[hour, minute, second] = match.slice(1).map(Number); [hour, minute, second] = match.slice(1).map(Number);
} else { } else {
+2 -2
View File
@@ -17,7 +17,7 @@ class ErrorCardStub extends HTMLElement {
customElements.define('hui-error-card', ErrorCardStub); customElements.define('hui-error-card', ErrorCardStub);
const ENTITY_ID = 'input_datetime.alarm'; const ENTITY_ID = 'input_datetime.alarm';
const TIME_ENTITY_ID = 'time.irrigation_schema_1_start_time'; const TIME_ENTITY_ID = 'time.alarm_time';
/** YAML is untyped at runtime, so setConfig has to cope with shapes the type forbids. */ /** YAML is untyped at runtime, so setConfig has to cope with shapes the type forbids. */
const invalidConfig = (config: Record<string, unknown>): TimePickerCardConfig => const invalidConfig = (config: Record<string, unknown>): TimePickerCardConfig =>
@@ -36,7 +36,7 @@ const timeEntity = (state = '07:30:00'): HassEntity => ({
...alarm(7), ...alarm(7),
entity_id: TIME_ENTITY_ID, entity_id: TIME_ENTITY_ID,
state, state,
attributes: { friendly_name: 'Irrigation start' }, attributes: { friendly_name: 'Alarm time' },
}); });
const createHass = (entity: HassEntity = alarm(7)): HomeAssistant => const createHass = (entity: HassEntity = alarm(7)): HomeAssistant =>