@raineworks/ha-dashboards 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -2
- package/dist/house.js +461 -0
- package/dist/mcp.js +1252 -0
- package/dist/types/kit/src/house.d.ts +8 -0
- package/dist/types/ui/src/lib/bedtime.d.ts +122 -0
- package/dist/types/ui/src/lib/color.d.ts +4 -0
- package/dist/types/ui/src/lib/hass-store.d.ts +46 -0
- package/dist/types/ui/src/lib/house-config.d.ts +97 -0
- package/dist/types/ui/src/lib/household.d.ts +33 -0
- package/dist/types/ui/src/lib/labels.d.ts +11 -0
- package/dist/types/ui/src/lib/lights.d.ts +204 -0
- package/dist/types/ui/src/lib/music.d.ts +489 -0
- package/dist/types/ui/src/lib/people.d.ts +119 -0
- package/dist/types/ui/src/lib/service-calls.d.ts +19 -0
- package/dist/types/ui/src/lib/text.d.ts +15 -0
- package/dist/types/ui/src/lib/time.d.ts +19 -0
- package/dist/types/ui/src/lib/tv.d.ts +156 -0
- package/dist/types/ui/src/lib/values.d.ts +11 -0
- package/dist/types/ui/src/types/homeassistant.d.ts +130 -0
- package/package.json +35 -5
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a house's own config repository checks its settings against: the parser the dashboards read
|
|
3
|
+
* `house.yaml` with, and the bedtime routines they describe. Published as `@raineworks/ha-dashboards/house`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export { BEDTIME_STEP_KINDS, type BedtimeRoutine, type BedtimeStep, type BedtimeStepKind, HOME_ROUTINE, } from '../../ui/src/lib/bedtime';
|
|
8
|
+
export { type HouseConfig, mergeHouseSources, parseHouseConfig } from '../../ui/src/lib/house-config';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bedtime: each room's bedtime toggle and Home Bedtime, the rooms a member can put to bed, and
|
|
3
|
+
* what Home Bedtime's routine does, as its confirm dialog lists it.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { HassEntity, HomeAssistant } from '../types/homeassistant';
|
|
8
|
+
/**
|
|
9
|
+
* HA label on each room's bedtime toggle, in its room's area: the raineworks_dashboards
|
|
10
|
+
* integration's `switch`, else a house's own `input_boolean` (before the integration had them).
|
|
11
|
+
*/
|
|
12
|
+
export declare const BEDTIME_LABEL = "bedtime";
|
|
13
|
+
/** The whole house's bedtime toggle: on once every room is, and turning it on turns them all on. */
|
|
14
|
+
export declare const HOME_BEDTIME = "switch.home_bedtime";
|
|
15
|
+
/** A house's own, before the integration's. */
|
|
16
|
+
export declare const FORMER_HOME_BEDTIME = "input_boolean.home_bedtime";
|
|
17
|
+
/** The domains a bedtime toggle can be (a `watch`). */
|
|
18
|
+
export declare const BEDTIME_DOMAINS: readonly ["switch", "input_boolean"];
|
|
19
|
+
/** Home Bedtime in this house: the integration's switch, else a house's own input_boolean. */
|
|
20
|
+
export declare function homeBedtimeEntity(states: Record<string, unknown> | undefined): string;
|
|
21
|
+
/** Whether an entity is Home Bedtime (either kind). */
|
|
22
|
+
export declare const isHomeBedtime: (entityId: string) => entityId is "switch.home_bedtime" | "input_boolean.home_bedtime";
|
|
23
|
+
/** `turn_on` / `turn_off` for a bedtime toggle, in its own domain. */
|
|
24
|
+
export declare const bedtimeService: (entityId: string, on: boolean) => [string, string];
|
|
25
|
+
/** A room (an area) with a bedtime toggle. */
|
|
26
|
+
export interface BedtimeRoom {
|
|
27
|
+
areaId: string;
|
|
28
|
+
/** The area's name ("Sam's Room"). */
|
|
29
|
+
name: string;
|
|
30
|
+
/** Its bedtime toggle. */
|
|
31
|
+
entityId: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Each area's bedtime toggle: labeled `switch`es (the integration's) or `input_boolean`s with an area
|
|
35
|
+
* (their own, else their device's); a switch wins where an area has both (a house moving to them).
|
|
36
|
+
*/
|
|
37
|
+
export declare function discoverBedtimeToggles(hass: Pick<HomeAssistant, 'entities' | 'devices'>): Record<string, string>;
|
|
38
|
+
/** Every room with a bedtime toggle, by name. */
|
|
39
|
+
export declare function bedtimeRooms(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'areas'>): BedtimeRoom[];
|
|
40
|
+
/** The signed-in household member's room, as its area id: their person entity's area in Home Assistant. */
|
|
41
|
+
export declare function memberArea(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'states' | 'user'>): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* The signed-in household member's room: their person entity's area in Home Assistant (a parent's might be
|
|
44
|
+
* the Master Suite, whose toggle covers the Ensuite too), with its bedtime toggle; none for an
|
|
45
|
+
* account that isn't a member, a member without a room, or a room without a toggle.
|
|
46
|
+
*/
|
|
47
|
+
export declare function memberBedtimeRoom(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'areas' | 'states' | 'user'>): BedtimeRoom | undefined;
|
|
48
|
+
/** A room besides the signed-in member's own, as their bedtime dialog shows it (`otherBedtimeRooms`). */
|
|
49
|
+
export interface OtherBedtimeRoom extends BedtimeRoom {
|
|
50
|
+
/** Its bedtime is on already. */
|
|
51
|
+
on: boolean;
|
|
52
|
+
/** First names of its household members at home: with anyone home, it's theirs to start. */
|
|
53
|
+
home: string[];
|
|
54
|
+
/** First names of its household members away. */
|
|
55
|
+
away: string[];
|
|
56
|
+
/** Can be put to bed from here: still off, and nobody assigned to it is home. */
|
|
57
|
+
pickable: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Every room besides the signed-in member's own, for their bedtime dialog: whether it's in bedtime
|
|
61
|
+
* already, and who's home and away there (household members, `isHouseholdMember()`, assigned by their
|
|
62
|
+
* person's area). One still off whose people are all away (or that has none) can be put to bed along
|
|
63
|
+
* with the member's own; one with someone home is theirs to start, so it only shows its state.
|
|
64
|
+
*/
|
|
65
|
+
export declare function otherBedtimeRooms(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'areas' | 'states' | 'user'>): OtherBedtimeRoom[];
|
|
66
|
+
/**
|
|
67
|
+
* The room in bedtime (its own toggle on; Home Bedtime alone doesn't count) holding any of these
|
|
68
|
+
* entities (lights, a scene's switch), by their area: turning them on there asks first. Anything
|
|
69
|
+
* labeled Stays on at bedtime (`BEDTIME_KEEP_LABEL`) never asks.
|
|
70
|
+
*/
|
|
71
|
+
export declare function bedtimeRoomOf(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'areas'>, states: Record<string, HassEntity>, entityIds: string[]): BedtimeRoom | undefined;
|
|
72
|
+
/** What a step can be about, for its icon. */
|
|
73
|
+
export declare const BEDTIME_STEP_KINDS: readonly ["rooms", "lights", "media", "speaker", "fan", "covers", "locks", "climate", "alert", "panels"];
|
|
74
|
+
/** What a step is about, for its icon. */
|
|
75
|
+
export type BedtimeStepKind = (typeof BEDTIME_STEP_KINDS)[number];
|
|
76
|
+
/** One thing a bedtime routine does, as its confirm dialog says it. */
|
|
77
|
+
export interface BedtimeStep {
|
|
78
|
+
kind: BedtimeStepKind;
|
|
79
|
+
/** The step in a sentence ("Closes every curtain, blind and garage door"). */
|
|
80
|
+
text: string;
|
|
81
|
+
/**
|
|
82
|
+
* The Home Assistant actions that do it in the routine's automation (`light.turn_off`, ...); a
|
|
83
|
+
* test checks they're exactly the actions the automation runs, so this list can't fall behind it.
|
|
84
|
+
* Empty for what another automation does (the LEDs, the rooms put to bed).
|
|
85
|
+
*/
|
|
86
|
+
actions: string[];
|
|
87
|
+
}
|
|
88
|
+
/** What a bedtime toggle's routine does, as its confirm dialog lists it. */
|
|
89
|
+
export interface BedtimeRoutine {
|
|
90
|
+
/** The zone it's for, as its dialog names it ("Master Suite and Ensuite"). */
|
|
91
|
+
zone: string;
|
|
92
|
+
/** Its steps, in the order they happen. */
|
|
93
|
+
steps: BedtimeStep[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* What Home Bedtime does when it turns on: automations/bedtime_home.yaml, plus the rooms put to bed
|
|
97
|
+
* (the integration keeps them in step) and the dimmed status lights (the integration's Bedtime option). Kept in step by
|
|
98
|
+
* bedtime-routines.test.ts.
|
|
99
|
+
*/
|
|
100
|
+
export declare const HOME_ROUTINE: BedtimeRoutine;
|
|
101
|
+
/**
|
|
102
|
+
* The label for what a bedtime routine leaves alone (a night light, a TV with a sleep timer): the
|
|
103
|
+
* routines skip it, and so do their confirm dialogs' lists.
|
|
104
|
+
*/
|
|
105
|
+
export declare const BEDTIME_KEEP_LABEL = "stays_on_at_bedtime";
|
|
106
|
+
/** Up to three names, then how many more ("Left Lamp, Right Lamp, Floor Lamp and 2 more"). */
|
|
107
|
+
export declare function someNames(names: string[], max?: number): string;
|
|
108
|
+
/**
|
|
109
|
+
* What a room's bedtime turns off by label, the way automations/bedtime_rooms.yaml finds it: in the
|
|
110
|
+
* toggle's own area, its lights labeled Household Light and TVs labeled Household TV (off), its
|
|
111
|
+
* speakers labeled Household Speaker (stopped) and its curtains and blinds (closed, a cover group
|
|
112
|
+
* standing for its members), leaving out anything labeled Stays on at bedtime. A step for each kind
|
|
113
|
+
* the room has, naming them; none for a toggle in no area.
|
|
114
|
+
*/
|
|
115
|
+
export declare function labeledBedtimeSteps(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'areas'>, states: Record<string, HassEntity>, toggle: string): BedtimeStep[];
|
|
116
|
+
/**
|
|
117
|
+
* A room's whole bedtime routine, as its confirm dialog lists it: what it turns off by label
|
|
118
|
+
* (`labeledBedtimeSteps()`), then the room's extras from the house settings' `bedtime_routines`
|
|
119
|
+
* (what no label can say: a fan turned on, a speaker in the next room), for the zone the settings
|
|
120
|
+
* name, else the room's own name.
|
|
121
|
+
*/
|
|
122
|
+
export declare function bedtimeRoutineFor(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'areas'>, states: Record<string, HassEntity>, toggle: string, extras: BedtimeRoutine | undefined): BedtimeRoutine;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Convert a Home Assistant hs_color (hue 0-360, saturation 0-100) to RGB at full value. */
|
|
2
|
+
export declare function hsToRgb(h: number, s: number): [number, number, number];
|
|
3
|
+
/** Approximate RGB of white light at a color temperature (Tanner Helland's fit, 1000–40000 K). */
|
|
4
|
+
export declare function kelvinToRgb(kelvin: number): [number, number, number];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hass store the cards keep their `hass` in, and what selectors need to read from it cheaply:
|
|
3
|
+
* which entities an update changed, whether that touches a selector, and structural equality.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { HassEntity, HomeAssistant } from '../types/homeassistant';
|
|
8
|
+
/**
|
|
9
|
+
* The latest `hass` object, outside the component tree. Home Assistant hands the card a new one
|
|
10
|
+
* on every state change in the house (several a second: CPU, power and audio level sensors), so
|
|
11
|
+
* components subscribe to the parts they show (`useHassSelector`) instead of all re-rendering.
|
|
12
|
+
*/
|
|
13
|
+
export interface HassStore {
|
|
14
|
+
/** The latest hass, or null before the first. */
|
|
15
|
+
get(): HomeAssistant | null;
|
|
16
|
+
/** Store a new hass and tell every subscriber (nothing when it's the same object). */
|
|
17
|
+
set(hass: HomeAssistant | null): void;
|
|
18
|
+
/** Entity ids whose state the last `set` changed, or null when anything may have (registries, first hass). */
|
|
19
|
+
changed(): ReadonlySet<string> | null;
|
|
20
|
+
/** Call `listener` after every `set`; returns the function that stops it. */
|
|
21
|
+
subscribe(listener: () => void): () => void;
|
|
22
|
+
}
|
|
23
|
+
/** A new store holding `initial`. A subscriber that throws is logged, and the rest still hear. */
|
|
24
|
+
export declare function createHassStore(initial?: HomeAssistant | null): HassStore;
|
|
25
|
+
/**
|
|
26
|
+
* The entity ids whose state object differs between two hass objects (Home Assistant replaces only
|
|
27
|
+
* the changed ones), or null when something else changed too.
|
|
28
|
+
*/
|
|
29
|
+
export declare function changedEntities(prev: HomeAssistant | null, next: HomeAssistant | null): Set<string> | null;
|
|
30
|
+
/** Which entities a selector reads: domains (`['light', 'switch']`) or a test on the entity id. */
|
|
31
|
+
export type EntityWatch = readonly string[] | ((entityId: string) => boolean);
|
|
32
|
+
/** Whether an update that changed `changed` (null: anything) can affect a selector watching `watch`. */
|
|
33
|
+
export declare function touches(changed: ReadonlySet<string> | null, watch: EntityWatch | undefined): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Structural equality for what selectors return: plain objects, arrays, primitives, Dates and
|
|
36
|
+
* Sets/Maps by identity. Home Assistant keeps an unchanged entity's state object across updates,
|
|
37
|
+
* so most comparisons end at the identity check.
|
|
38
|
+
*/
|
|
39
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
40
|
+
/** The states whose entity id passes `test` (a selector's slice of `hass.states`). */
|
|
41
|
+
export declare function pickStates(states: Record<string, HassEntity> | undefined, test: (entityId: string) => boolean): Record<string, HassEntity>;
|
|
42
|
+
/**
|
|
43
|
+
* Resolves true once `test` holds for the store's hass (checked now and on each update), or false
|
|
44
|
+
* after `timeoutMs`: for keeping an action's busy state until Home Assistant reports its effect.
|
|
45
|
+
*/
|
|
46
|
+
export declare function waitForHass(store: HassStore, test: (hass: HomeAssistant) => boolean, timeoutMs: number): Promise<boolean>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The house's settings: what every dashboard needs to know about this house that discovery can't
|
|
3
|
+
* tell (which speaker announces, which voice speaks, which sensors are the washer's). One object for
|
|
4
|
+
* the whole page, given to every card as its `house` option (`house: !include ../house.yaml` in each
|
|
5
|
+
* dashboards/*.yaml), so the source names no entity of its own. Anything left out falls back to
|
|
6
|
+
* discovery, or leaves its feature off: a house with no settings at all still gets a dashboard.
|
|
7
|
+
* Libraries read it with `houseConfig()`, components with `useHouseConfig()` (context/HouseConfig.tsx).
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { type BedtimeRoutine } from './bedtime';
|
|
12
|
+
import type { LiveInput } from './music';
|
|
13
|
+
/** A washer's or dryer's sensors (SmartThings: machine state, job state, time remaining). */
|
|
14
|
+
export interface ApplianceEntities {
|
|
15
|
+
/** What the header calls it ("Washer"). */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Entity ids of its machine state, job state and time remaining sensors. */
|
|
18
|
+
machineState: string;
|
|
19
|
+
jobState: string;
|
|
20
|
+
timeRemaining: string;
|
|
21
|
+
}
|
|
22
|
+
/** A thermostat the climate card shows, from the house settings. */
|
|
23
|
+
export interface ThermostatZone {
|
|
24
|
+
entityId: string;
|
|
25
|
+
/** What the climate card calls it ("Main Floor"); else the entity's own name. */
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
/** How the house speaks (announcements, Assist's answers). */
|
|
29
|
+
export interface HouseTts {
|
|
30
|
+
/** The house's text-to-speech entity; else the first `tts.*` Home Assistant has. */
|
|
31
|
+
engine?: string;
|
|
32
|
+
/** Its voice, named on every call so a change of the engine's default never changes it. */
|
|
33
|
+
voice?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The engine speaks an answer as it's written (Home Assistant's streaming TTS), so Assist runs
|
|
36
|
+
* speak through it themselves.
|
|
37
|
+
*/
|
|
38
|
+
streaming: boolean;
|
|
39
|
+
/** Spoken with when the engine fails (an outage, a limit reached). */
|
|
40
|
+
fallback?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The house's settings, parsed (`parseHouseConfig`): `laundry`, `liveInputs`, `tts`, `bedtimeRoutines` and
|
|
44
|
+
* `modules` are always there (empty when unset), the rest optional.
|
|
45
|
+
*/
|
|
46
|
+
export interface HouseConfig {
|
|
47
|
+
/** The speaker that announces for the house (the kitchen timer, the Daily dialog's first pick). */
|
|
48
|
+
announceSpeaker?: string;
|
|
49
|
+
/** The weather entity; else the first `weather.*`. */
|
|
50
|
+
weather?: string;
|
|
51
|
+
/** The alarm panel; else the first Alarmo panel, else the first `alarm_control_panel.*`. */
|
|
52
|
+
alarmPanel?: string;
|
|
53
|
+
/** The thermostats the climate card shows; else every visible `climate.*`. */
|
|
54
|
+
thermostats?: ThermostatZone[];
|
|
55
|
+
/** The washer and dryer; none = no laundry in the header. */
|
|
56
|
+
laundry: {
|
|
57
|
+
washer?: ApplianceEntities;
|
|
58
|
+
dryer?: ApplianceEntities;
|
|
59
|
+
};
|
|
60
|
+
/** The guest Wi-Fi's QR code image (UniFi's, per WLAN); none = no Guest Wi-Fi item. */
|
|
61
|
+
guestWifiQr?: string;
|
|
62
|
+
/** Live audio inputs Music Assistant plays (a turntable). */
|
|
63
|
+
liveInputs: LiveInput[];
|
|
64
|
+
/** The house's voice. */
|
|
65
|
+
tts: HouseTts;
|
|
66
|
+
/** The birthdays calendar; else the one named "Birthdays". */
|
|
67
|
+
birthdayCalendar?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Each room's bedtime extras, by toggle: what its routine does beyond what it turns off by label
|
|
70
|
+
* (a fan turned on, a speaker in the next room), and the zone its confirm names. The confirm lists
|
|
71
|
+
* the labeled lights, TVs, speakers and curtains itself (`bedtimeRoutineFor()` in lib/bedtime.ts).
|
|
72
|
+
*/
|
|
73
|
+
bedtimeRoutines: Record<string, BedtimeRoutine>;
|
|
74
|
+
/** Modules turned off (`false`), by id (lib/modules.ts); the rest are on while detected. */
|
|
75
|
+
modules: Record<string, boolean>;
|
|
76
|
+
}
|
|
77
|
+
type Raw = Record<string, unknown>;
|
|
78
|
+
/**
|
|
79
|
+
* The card's `house` option (snake_case YAML) as the house's settings: anything missing or not the
|
|
80
|
+
* right shape is left out (falling back to discovery), never an error, so a typo costs one feature
|
|
81
|
+
* and not the dashboard.
|
|
82
|
+
*/
|
|
83
|
+
export declare function parseHouseConfig(raw: unknown): HouseConfig;
|
|
84
|
+
/** The house's settings (the card's `house` option over the integration's). */
|
|
85
|
+
export declare const houseConfig: () => HouseConfig;
|
|
86
|
+
/**
|
|
87
|
+
* The settings from both sources: the integration's (its options' House and Laundry) and the
|
|
88
|
+
* card's `house` option (house.yaml), the card's winning key by key where both set one.
|
|
89
|
+
*/
|
|
90
|
+
export declare function mergeHouseSources(integration: unknown, card: unknown): Raw;
|
|
91
|
+
/** Set from a card's `house` option; listeners hear only a real change. */
|
|
92
|
+
export declare function setHouseConfig(raw: unknown): void;
|
|
93
|
+
/** Set from the integration's `raineworks_dashboards/info` (its `house`). */
|
|
94
|
+
export declare function setIntegrationHouse(raw: unknown): void;
|
|
95
|
+
/** Call `listener` whenever the house settings change; returns the function that stops it. */
|
|
96
|
+
export declare function subscribeHouseConfig(listener: () => void): () => void;
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who the household is: the people the dashboards list, message, assign chores to and greet. With
|
|
3
|
+
* the raineworks_dashboards integration loaded, it says (`raineworks_dashboards/info`: a Warden
|
|
4
|
+
* group's members, when one is picked in its options); without it, every person with a device
|
|
5
|
+
* tracker, which leaves out the admin account and pets. One list for the page, set by
|
|
6
|
+
* definePanelElement once the integration answers.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { HassEntity, HomeAssistant } from '../types/homeassistant';
|
|
11
|
+
/** The integration's household (person entity ids), or null when it hasn't said (or isn't there). */
|
|
12
|
+
export declare const householdIds: () => ReadonlySet<string> | null;
|
|
13
|
+
/** Set from the integration's answer (null: back to everyone with a device tracker). */
|
|
14
|
+
export declare function setHousehold(ids: readonly string[] | null): void;
|
|
15
|
+
/** Whether a person entity is a household member. */
|
|
16
|
+
export declare function isHouseholdMember(person: HassEntity | undefined): person is HassEntity;
|
|
17
|
+
/** The integration's name for itself, in `hass.config.components`. */
|
|
18
|
+
export declare const INTEGRATION = "raineworks_dashboards";
|
|
19
|
+
/**
|
|
20
|
+
* Ask the integration who the household is (when it's loaded) and set it, with its house settings
|
|
21
|
+
* (`setIntegrationHouse()`); resolves true when that changed the household. Without the
|
|
22
|
+
* integration, or when it can't answer, nothing changes.
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadHousehold(hass: Pick<HomeAssistant, 'callWS' | 'config'>): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Where one of the house's actions goes: the integration's own (`raineworks_dashboards.<name>`)
|
|
27
|
+
* when it has it, else the house's script of that name (the same fields).
|
|
28
|
+
*/
|
|
29
|
+
export declare function houseAction(hass: Pick<HomeAssistant, 'services'>, name: string): [domain: string, service: string];
|
|
30
|
+
/** Where a push to household phones goes (`houseAction()`). */
|
|
31
|
+
export declare const notifyPeopleAction: (hass: Pick<HomeAssistant, "services">) => [domain: string, service: string];
|
|
32
|
+
/** Where a to-do item's push to whom it's for goes (`houseAction()`). */
|
|
33
|
+
export declare const todoAssigneeAction: (hass: Pick<HomeAssistant, "services">) => [domain: string, service: string];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Labels in the entity registry: whether a house uses one at all.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { HomeAssistant } from '../types/homeassistant';
|
|
7
|
+
/**
|
|
8
|
+
* Whether any entity in the registry carries `label`: a label that picks what the dashboards list
|
|
9
|
+
* (Household Speaker, Household TV) takes over from discovery only once a house uses it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function labelInUse(entities: HomeAssistant['entities'] | null | undefined, label: string): boolean;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lighting discovery and shaping: which lights and Stateful Scenes each floor and room has, what
|
|
3
|
+
* a light's controls can do, and how a light that's on looks.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { HassEntity, HomeAssistant } from '../types/homeassistant';
|
|
8
|
+
/** HA label on room lighting (smart bulbs and switches); indicator LEDs and appliance lights don't carry it. */
|
|
9
|
+
export declare const HOUSEHOLD_LIGHT_LABEL = "household_light";
|
|
10
|
+
/** Which controls a light's row offers. */
|
|
11
|
+
export interface LightCapabilities {
|
|
12
|
+
/** Has a brightness level (any color mode other than plain on/off). */
|
|
13
|
+
dimmable: boolean;
|
|
14
|
+
/** Has color, color temperature or effects for the adjust dialog. */
|
|
15
|
+
adjustable: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A room tile's status line: how many of its lights are on ("Off", "1 on", "All on"), then the
|
|
19
|
+
* scene that's on ("2 on · Dinner"); "Bedtime" first while the room is in bedtime. A room with no
|
|
20
|
+
* lights says only its scene, or "Scenes".
|
|
21
|
+
*/
|
|
22
|
+
export declare function roomSummary(room: {
|
|
23
|
+
/** Its lights that are on. */
|
|
24
|
+
onCount: number;
|
|
25
|
+
/** All its lights. */
|
|
26
|
+
lightCount: number;
|
|
27
|
+
/** The name of its scene that's on, if one is. */
|
|
28
|
+
activeScene?: string;
|
|
29
|
+
/** Whether the room is in bedtime. */
|
|
30
|
+
bedtime?: boolean;
|
|
31
|
+
}): string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether a light's row shows its dimmer and colors button: while it's on, or while its dimmer is
|
|
34
|
+
* held (a drag that started while it was on keeps its slider until it's let go). A light that's off
|
|
35
|
+
* shows only its toggle and name, so a room of lights that are off stays a short, quiet list.
|
|
36
|
+
*/
|
|
37
|
+
export declare function showsLightControls(isOn: boolean, dimmerHeld: boolean): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* What a light's controls can do, from `supported_color_modes` / `effect_list`. A light that
|
|
40
|
+
* hasn't reported its modes (unavailable) keeps the dimmer, disabled, so its row doesn't jump.
|
|
41
|
+
*/
|
|
42
|
+
export declare function lightCapabilities(entity: HassEntity | undefined): LightCapabilities;
|
|
43
|
+
/** What a light that's on looks like: its color, white temperature, or running effect. */
|
|
44
|
+
export interface LightAppearance {
|
|
45
|
+
/** CSS color of the light (its reported RGB, else from its temperature). */
|
|
46
|
+
color?: string;
|
|
47
|
+
/** White light at a color temperature. */
|
|
48
|
+
kelvin?: number;
|
|
49
|
+
/** A running effect, as named by the light ("Candle"). */
|
|
50
|
+
effect?: string;
|
|
51
|
+
/** Short description for a status line: the effect, "2700 K", or "Color". */
|
|
52
|
+
detail: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* How a light that's on looks, for lights with color, temperature or effects: undefined when it's
|
|
56
|
+
* off, or a plain dimmable/on-off light with nothing to show.
|
|
57
|
+
*/
|
|
58
|
+
export declare function lightAppearance(entity: HassEntity | undefined): LightAppearance | undefined;
|
|
59
|
+
/** One effect in the adjust dialog: its name as the first light lists it, and each light's own spelling of it. */
|
|
60
|
+
export interface AdjustEffect {
|
|
61
|
+
/** The effect's name, as the first light that has it spells it. */
|
|
62
|
+
name: string;
|
|
63
|
+
/** Light id → the effect's name in that light's `effect_list`. */
|
|
64
|
+
lights: Record<string, string>;
|
|
65
|
+
}
|
|
66
|
+
/** What the colors dialog can set on a light or a room's lights, and what they show now. */
|
|
67
|
+
export interface AdjustCapabilities {
|
|
68
|
+
/** Lights with a white color temperature, over the widest range any has (each clamps to its own). */
|
|
69
|
+
temperature?: {
|
|
70
|
+
ids: string[];
|
|
71
|
+
minKelvin: number;
|
|
72
|
+
maxKelvin: number;
|
|
73
|
+
};
|
|
74
|
+
/** Lights with full color. */
|
|
75
|
+
color?: {
|
|
76
|
+
ids: string[];
|
|
77
|
+
};
|
|
78
|
+
/** Every effect any light has (matched by name, ignoring case), in the order the lights list them. */
|
|
79
|
+
effects: AdjustEffect[];
|
|
80
|
+
/** A white temperature a light that's on shows. */
|
|
81
|
+
kelvin?: number;
|
|
82
|
+
/** A color a light that's on shows. */
|
|
83
|
+
rgb?: [number, number, number];
|
|
84
|
+
/** That color's hue in degrees, when the light reports `hs_color`. */
|
|
85
|
+
hue?: number;
|
|
86
|
+
/** The effect a light that's on runs. */
|
|
87
|
+
effect?: string;
|
|
88
|
+
/**
|
|
89
|
+
* How to stop an effect on each light: the light's own "no effect" name (`off`, `None`, `solid`),
|
|
90
|
+
* so a light that calls it `none` isn't sent `off`.
|
|
91
|
+
*/
|
|
92
|
+
effectOff: Record<string, string>;
|
|
93
|
+
}
|
|
94
|
+
/** `{ light: value }` as one entry per value with its lights, for one service call each. */
|
|
95
|
+
export declare function byValue(record: Record<string, string>): [string, string[]][];
|
|
96
|
+
/**
|
|
97
|
+
* What the colors dialog offers for these lights (one fixture, or a room's): each setting with the
|
|
98
|
+
* lights that support it, so a room sends a color only to its color bulbs. Current values come from
|
|
99
|
+
* the first light that's on and shows one. Missing (unknown) entities are skipped.
|
|
100
|
+
*/
|
|
101
|
+
export declare function adjustCapabilities(entities: (HassEntity | undefined)[]): AdjustCapabilities;
|
|
102
|
+
/** The entity's area: its own, else its device's (like Home Assistant resolves it). */
|
|
103
|
+
export declare function entityArea(hass: Pick<HomeAssistant, 'entities' | 'devices'>, entityId: string): string | undefined;
|
|
104
|
+
/** `light.*` entities carrying the label (hidden ones skipped), sorted by entity id. */
|
|
105
|
+
export declare function labeledLights(hass: Pick<HomeAssistant, 'entities'>, label?: string): string[];
|
|
106
|
+
/** A room on a floor with its labeled lights. */
|
|
107
|
+
export interface FloorRoom {
|
|
108
|
+
/** The room's Home Assistant area id. */
|
|
109
|
+
areaId: string;
|
|
110
|
+
/** The area's name. */
|
|
111
|
+
name: string;
|
|
112
|
+
/** Its lights, by name, each named without the room's name in front ("Floor Lamp"). */
|
|
113
|
+
lights: {
|
|
114
|
+
id: string;
|
|
115
|
+
name: string;
|
|
116
|
+
}[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Labeled lights on one floor, grouped by area (rooms sorted by name, lights by name). Names come
|
|
120
|
+
* from the registry override, else the state's friendly name.
|
|
121
|
+
*/
|
|
122
|
+
export declare function discoverFloorRooms(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'areas'>, states: Record<string, HassEntity>, floorId: string, label?: string,
|
|
123
|
+
/** The labeled lights, when the caller has them already (every floor asks for the same ones). */
|
|
124
|
+
lights?: string[]): FloorRoom[];
|
|
125
|
+
/** The floors, those named in `order` first (in that order), the rest by level, top floor first. */
|
|
126
|
+
export declare function floorsInOrder(floors: HomeAssistant['floors'], order: string[]): import("../types/homeassistant").HassFloor[];
|
|
127
|
+
/** A floor with the rooms that have labeled lights. */
|
|
128
|
+
export interface HouseFloor {
|
|
129
|
+
/** The Home Assistant floor id. */
|
|
130
|
+
floorId: string;
|
|
131
|
+
/** The floor's name. */
|
|
132
|
+
name: string;
|
|
133
|
+
/** Its rooms with lights, by name. */
|
|
134
|
+
rooms: FloorRoom[];
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Floor ids from `home` outward: the home floor, then the others nearest first by level (an upper
|
|
138
|
+
* floor before a lower one the same distance away). For a panel listing every light, its own first.
|
|
139
|
+
*/
|
|
140
|
+
export declare function floorsNearestFirst(floors: HomeAssistant['floors'], home: string): string[];
|
|
141
|
+
/**
|
|
142
|
+
* Every floor with labeled lights, each with its rooms (as `discoverFloorRooms`). Floors named in
|
|
143
|
+
* `order` come first, in that order; the rest follow by level, top floor first.
|
|
144
|
+
*/
|
|
145
|
+
export declare function discoverHouseFloors(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'areas' | 'floors'>, states: Record<string, HassEntity>, order?: string[], label?: string): HouseFloor[];
|
|
146
|
+
/** A room's Stateful Scene. */
|
|
147
|
+
export interface RoomScene {
|
|
148
|
+
/** Stateful Scenes switch (`switch.<room>_<scene>_stateful_scene`). */
|
|
149
|
+
id: string;
|
|
150
|
+
/** The scene's name without the room's name or "Stateful Scene" ("Wind Down"). */
|
|
151
|
+
name: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* HA label on a Stateful Scenes switch only its room's people see: household members assigned to
|
|
155
|
+
* the scene's room (their person entity's area). Nobody else, and no wall panel, lists it.
|
|
156
|
+
*/
|
|
157
|
+
export declare const PRIVATE_SCENE_LABEL = "private_scene";
|
|
158
|
+
/**
|
|
159
|
+
* Stateful Scenes switches grouped by area ("Wind Down Stateful Scene" → "Wind Down"), Default
|
|
160
|
+
* first, then by name. Scenes without an area are skipped, and so are private ones
|
|
161
|
+
* (`PRIVATE_SCENE_LABEL`) outside `memberArea`, the signed-in household member's room.
|
|
162
|
+
*/
|
|
163
|
+
export declare function discoverRoomScenes(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'areas'>, states: Record<string, HassEntity>, memberArea?: string): Record<string, RoomScene[]>;
|
|
164
|
+
/**
|
|
165
|
+
* The lights a Stateful Scenes switch sets: its scene entity's `entity_id` list. The switch doesn't
|
|
166
|
+
* name its scene, so match by name ("Passion Stateful Scene" → the scene "Passion") among scenes
|
|
167
|
+
* whose lights are in the switch's room (several rooms have a "Default").
|
|
168
|
+
*/
|
|
169
|
+
export declare function sceneLights(hass: Pick<HomeAssistant, 'entities' | 'devices'>, states: Record<string, HassEntity>, switchId: string): string[];
|
|
170
|
+
/** The distinct colors of lights that are on (in order), and whether any runs an effect: for a color ring. */
|
|
171
|
+
export declare function ringColors(entities: (HassEntity | undefined)[]): {
|
|
172
|
+
colors: string[];
|
|
173
|
+
effect: boolean;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* A fill in the lights' own colors, for the control of a light or scene that's on: one color, or a
|
|
177
|
+
* diagonal blend of several; with a dark or light foreground, whichever reads on it (from the
|
|
178
|
+
* colors' average luminance). None without colors (a plain dimmable bulb, or before Home Assistant
|
|
179
|
+
* reports a light that was just turned on): the theme's accent then.
|
|
180
|
+
*/
|
|
181
|
+
export declare function lightFill(colors: string[]): {
|
|
182
|
+
background: string;
|
|
183
|
+
color: string;
|
|
184
|
+
foreground: string;
|
|
185
|
+
} | undefined;
|
|
186
|
+
/** A floor with the rooms that have Stateful Scenes. */
|
|
187
|
+
export interface HouseSceneFloor {
|
|
188
|
+
/** The Home Assistant floor id. */
|
|
189
|
+
floorId: string;
|
|
190
|
+
/** The floor's name. */
|
|
191
|
+
name: string;
|
|
192
|
+
/** Its rooms with scenes, by name: each its area id, name and scenes. */
|
|
193
|
+
rooms: {
|
|
194
|
+
areaId: string;
|
|
195
|
+
name: string;
|
|
196
|
+
scenes: RoomScene[];
|
|
197
|
+
}[];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Every room's Stateful Scenes (as `discoverRoomScenes`), by floor in `order` (floors not in it
|
|
201
|
+
* follow by level, top floor first) and by room name within a floor. Floors and rooms without
|
|
202
|
+
* scenes are left out. `memberArea`: the signed-in household member's room, whose private scenes show.
|
|
203
|
+
*/
|
|
204
|
+
export declare function discoverHouseScenes(hass: Pick<HomeAssistant, 'entities' | 'devices' | 'areas' | 'floors'>, states: Record<string, HassEntity>, order?: string[], memberArea?: string): HouseSceneFloor[];
|