From f5d7a7ece2b76e6cac3c4dbda8e5ef0cfb250469 Mon Sep 17 00:00:00 2001 From: Shannon Hochkins Date: Mon, 29 Jan 2024 15:31:29 +1100 Subject: [PATCH 1/2] gitflow-feature-stash: small-updates --- ROADMAP.md | 9 +- package-lock.json | 8 +- package.json | 2 + packages/components/LICENCE.md | 18 +- packages/components/package.json | 6 +- .../src/Cards/SidebarCard/index.tsx | 13 +- .../Entity/Climate/ClimateControls/data.ts | 2 +- .../Entity/Climate/ClimateControls/index.tsx | 3 +- packages/components/src/index.ts | 1 + packages/core/LICENCE.md | 18 +- packages/core/package.json | 9 +- .../core/scripts/sync-user-types/constants.ts | 5 + .../types/autogenerated-types-by-domain.ts | 59 +- packages/core/src/types/supported-services.ts | 806 +++++++++--------- 14 files changed, 498 insertions(+), 461 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 2111d87f..a1aa4ffd 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,5 +1,5 @@ # Roadmap -These are listed in order of priority, but are subject to change. I will attempt to release something every 1-2 weeks depending on my own circumstances. +These are listed in order of priority, but are subject to change. I will attempt to release something every 1-2 months depending on my own circumstances. ### Short Term @@ -7,12 +7,5 @@ These are listed in order of priority, but are subject to change. I will attempt * VacuumCard - a card to display vacuum entities * ButtonCard - Different layout designs, including slider indicator for brightness and curtain position etc * AreaCard - Allow alternate layouts, users may not just want a picture of the area but rather an icon / name layout -* History - include existing history information on all cards as popup similar to home assistant -* Theme - allow individual components to display different theme control, either by a hue shift or global change * Architecture - currently, @hakit/components is bundled in one big package, I would like to change this so assets are bundled separately and only loaded when needed to reduce bundle size - - -### Long Term - -* Full responsive layouts with the hope of an editor with drag and drop support. diff --git a/package-lock.json b/package-lock.json index d713ab10..74a56d6d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24674,7 +24674,7 @@ }, "packages/components": { "name": "@hakit/components", - "version": "3.1.0", + "version": "3.1.1", "license": "ISC", "devDependencies": { "@emotion/babel-plugin": "^11.x", @@ -24691,7 +24691,7 @@ "@emotion/react": ">=11.x", "@emotion/styled": ">=11.x", "@fullcalendar/react": ">=6.x.x", - "@hakit/core": "^3.0.5", + "@hakit/core": "^3.1.1", "@use-gesture/react": ">=10.x", "autolinker": ">=4.x", "framer-motion": ">=10.x", @@ -24709,7 +24709,7 @@ }, "packages/core": { "name": "@hakit/core", - "version": "3.1.0", + "version": "3.1.1", "license": "ISC", "bin": { "hakit-sync-types": "dist/sync/cli/cli.js" @@ -24807,7 +24807,7 @@ } }, "packages/create-hakit": { - "version": "1.1.1", + "version": "1.1.2", "license": "ISC", "dependencies": { "create-vite": "latest" diff --git a/package.json b/package.json index 9855ae64..15cb4fd6 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,12 @@ "test:components": "npm run test --workspace=@hakit/components", "test:core": "npm run test --workspace=@hakit/core", "build": "VITE_CJS_TRACE=true npm run build:core && npm run build:components && npm run build:create", + "postbuild": "npm run type-check --workspaces --if-present", "build:core": "npm run build --workspace=@hakit/core", "build:create": "npm run build --workspace=create-hakit", "build:components": "npm run build --workspace=@hakit/components", "build:storybook": "BUILD_STORYBOOK=true storybook build", + "watch:build:components": "npm run watch:build --workspace=@hakit/components", "watch:build:core": "npm run watch:build --workspace=@hakit/core", "watch:build:sync-script": "npm run watch:build:sync-script --workspace=@hakit/core", diff --git a/packages/components/LICENCE.md b/packages/components/LICENCE.md index f71a8065..4663d10c 100644 --- a/packages/components/LICENCE.md +++ b/packages/components/LICENCE.md @@ -1,5 +1,19 @@ Proprietary License -All rights reserved. This software and its accompanying documentation are protected by intellectual property laws and international treaties. Unauthorized use, reproduction, distribution, or modification of this software, in whole or in part, without the explicit permission of the author, is strictly prohibited. +All rights reserved. This software and its accompanying documentation ("Software") are the intellectual property of Shannon Hochkins and are protected under intellectual property laws and international treaties. -For licensing inquiries and permissions, please contact the author at mail@shannonhochkins.com. +1. Usage Restrictions: Any use, reproduction, distribution, or modification of this Software, in whole or in part, for any purpose, including commercial purposes, is strictly prohibited without the explicit prior written permission of the author, Shannon Hochkins, except as may be allowed by any applicable laws. + +2. Commercial Use: Specifically, commercial use, including but not limited to resale, redistribution for commercial gain, or incorporation of this Software into a commercial product or service, is expressly prohibited without obtaining a separate commercial license from the author. + +3. No Sub-Licensing: This license does not permit sub-licensing, resale, or redistribution of any kind. + +4. Disclaimer of Warranties: This Software is provided "as is" and "as available", without any warranties of any kind, either express or implied, including but not limited to warranties of merchantability or fitness for a particular purpose. The entire risk as to the quality and performance of the Software is with you. + +5. Limitation of Liability: In no event shall the author be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Software or the use or other dealings in the Software. + +6. Termination: This License and the rights granted hereunder will terminate automatically upon any breach by you of the terms of this License. + +7. Governing Law: This License shall be governed by the laws of Australia, without regard to its conflict of law principles. + +8. Contact Information: For licensing inquiries, permissions, or further information, please contact the author at mail@shannonhochkins.com. \ No newline at end of file diff --git a/packages/components/package.json b/packages/components/package.json index 8c6fbce0..12f13fb3 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -34,7 +34,7 @@ } }, "author": "Shannon Hochkins ", - "license": "ISC", + "license": "SEE LICENSE IN LICENSE.md", "files": [ "dist", "README.md", @@ -54,9 +54,9 @@ "scripts": { "dev": "vite", "type-check": "tsc --noEmit", - "prebuild": "rm -rf ./dist && npm run lint && npm run prettier", + "prebuild": "rm -rf ./dist && npm run lint", "build": "NODE_ENV=production vite build", - "postbuild": "npm run type-check", + "postbuild": "npm run prettier", "watch:build": "NODE_ENV=production vite build --watch", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "prettier": "prettier \"src/**/*.{ts,tsx}\" --write && git status", diff --git a/packages/components/src/Cards/SidebarCard/index.tsx b/packages/components/src/Cards/SidebarCard/index.tsx index 3d4a48a1..66e6f5d2 100644 --- a/packages/components/src/Cards/SidebarCard/index.tsx +++ b/packages/components/src/Cards/SidebarCard/index.tsx @@ -255,6 +255,8 @@ export interface SidebarCardProps extends Extendable { menuItems?: MenuItem[]; /** the children to render in the sidebar */ children?: React.ReactNode; + /** a method to apply a sort function to the sidebar menu items before they render */ + sortSidebarMenuItems?: (a: MenuItem, b: MenuItem) => number; } function _SidebarCard({ weatherCardProps, @@ -270,6 +272,7 @@ function _SidebarCard({ includeTimeCard = true, className, cssStyles, + sortSidebarMenuItems, ...rest }: SidebarCardProps) { const [open, setOpen] = useState(startOpen); @@ -278,7 +281,7 @@ function _SidebarCard({ const hash = useStore((state) => state.hash); const devices = useBreakpoint(); const concatenatedMenuItems = useMemo(() => { - const mappedRoutes = routes.map((route) => ({ + const mappedRoutes = routes.map((route) => ({ ...route, title: route.name, onClick() { @@ -293,8 +296,12 @@ function _SidebarCard({ } }, })); - return autoIncludeRoutes ? [...menuItems, ...mappedRoutes] : menuItems; - }, [routes, autoIncludeRoutes, menuItems, hash]); + const items = autoIncludeRoutes ? [...menuItems, ...mappedRoutes] : menuItems; + if (typeof sortSidebarMenuItems === "function") { + items.sort(sortSidebarMenuItems); + } + return items; + }, [routes, sortSidebarMenuItems, autoIncludeRoutes, menuItems, hash]); return ( <> ) : null} -
+
{modes && !hideHvacModes && ( ", - "license": "ISC", + "license": "SEE LICENSE IN LICENSE.md", "files": [ "dist", "package.json", @@ -62,12 +62,13 @@ "scripts": { "dev": "vite", "type-check": "tsc --noEmit", - "prebuild": "rm -rf ./dist && npm run lint && npm run prettier", - "build": "npm run sync-local-types && npm run build:sync-script-cli && npm run build:sync-ha-types && npm run build:core && npm run type-check", + "prebuild": "rm -rf ./dist && npm run lint", + "postbuild": "npm run prettier", + "build": "npm run sync-local-types && npm run build:sync-script-cli && npm run build:sync-ha-types && npm run build:core", "build:core": "NODE_ENV=production vite build", "build:sync-script": "NODE_ENV=production vite --config ./scripts/sync-user-types/vite-node.config.ts build", "build:sync-script-cli": "tsup", - "build:sync-ha-types": "ts-node --esm ./scripts/sync-ha-types/index.ts", + "build:sync-ha-types": "npx tsx ./scripts/sync-ha-types/index.ts", "watch:build": "NODE_ENV=production vite build --watch", "watch:build:sync-script": "NODE_ENV=production vite --config ./scripts/sync-user-types/vite-node.config.ts build --watch", "dev:test:sync-script": "npm run build:sync-script && ts-node ./scripts/sync-user-types/test.ts", diff --git a/packages/core/scripts/sync-user-types/constants.ts b/packages/core/scripts/sync-user-types/constants.ts index ffaf9857..9ac2b4e4 100644 --- a/packages/core/scripts/sync-user-types/constants.ts +++ b/packages/core/scripts/sync-user-types/constants.ts @@ -8,4 +8,9 @@ export const REMAPPED_TYPES: Record = { rgbw_color: `[number, number, number, number]`, rgbww_color: `[number, number, number, number, number]`, group_members: `string[]`, + media_content_id: `string | number`, + kelvin: `number | object`, + white: 'boolean', + color_temp: `number | object`, + xy_color: `[number, number]`, }; diff --git a/packages/core/src/types/autogenerated-types-by-domain.ts b/packages/core/src/types/autogenerated-types-by-domain.ts index d990ae15..1f3f25fe 100644 --- a/packages/core/src/types/autogenerated-types-by-domain.ts +++ b/packages/core/src/types/autogenerated-types-by-domain.ts @@ -1,49 +1,22 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ // auto generated, do not manipulate, instead run the sync-ha-types script -import { - HassEntityBase, - HassEntityAttributeBase, -} from "home-assistant-js-websocket"; -export type HvacAction = - | "off" - | "preheating" - | "heating" - | "cooling" - | "drying" - | "idle" - | "fan"; +import { HassEntityBase, HassEntityAttributeBase } from "home-assistant-js-websocket"; +export type HvacAction = "off" | "preheating" | "heating" | "cooling" | "drying" | "idle" | "fan"; export type HvacMode = (typeof HVAC_MODES)[number]; -export const HVAC_MODES = [ - "auto", - "heat_cool", - "heat", - "cool", - "dry", - "fan_only", - "off", -] as const; +export const HVAC_MODES = ["auto", "heat_cool", "heat", "cool", "dry", "fan_only", "off"] as const; export type HumidifierAction = "off" | "idle" | "humidifying" | "drying"; export const MODES = ["single", "restart", "queued", "parallel"] as const; export type OperationMode = (typeof OPERATION_MODES)[number]; -export const OPERATION_MODES = [ - "electric", - "gas", - "heat_pump", - "eco", - "performance", - "high_demand", - "off", -] as const; +export const OPERATION_MODES = ["electric", "gas", "heat_pump", "eco", "performance", "high_demand", "off"] as const; export interface AlarmControlPanelEntity extends HassEntityBase { attributes: AlarmControlPanelEntityAttributes; } -export interface AlarmControlPanelEntityAttributes - extends HassEntityAttributeBase { +export interface AlarmControlPanelEntityAttributes extends HassEntityAttributeBase { code_format?: "text" | "number"; changed_by?: string | null; code_arm_required?: boolean; @@ -183,8 +156,7 @@ export const LIGHT_COLOR_MODES = { RGBWW: "rgbww", WHITE: "white", }; -export type LightColorMode = - (typeof LIGHT_COLOR_MODES)[keyof typeof LIGHT_COLOR_MODES]; +export type LightColorMode = (typeof LIGHT_COLOR_MODES)[keyof typeof LIGHT_COLOR_MODES]; export interface LightEntity extends HassEntityBase { attributes: LightEntityAttributes; } @@ -217,16 +189,7 @@ export interface LockEntityAttributes extends HassEntityAttributeBase { } export interface MediaPlayerEntity extends HassEntityBase { attributes: MediaPlayerEntityAttributes; - state: - | "playing" - | "paused" - | "idle" - | "off" - | "on" - | "unavailable" - | "unknown" - | "standby" - | "buffering"; + state: "playing" | "paused" | "idle" | "off" | "on" | "unavailable" | "unknown" | "standby" | "buffering"; } export interface MediaPlayerEntityAttributes extends HassEntityAttributeBase { @@ -319,6 +282,14 @@ export interface VacuumEntityAttributes extends HassEntityAttributeBase { fan_speed?: any; [key: string]: any; } +export interface ValveEntity extends HassEntityBase { + attributes: ValveEntityAttributes; +} + +export interface ValveEntityAttributes extends HassEntityAttributeBase { + current_position?: number; + position?: number; +} export type WaterHeaterEntity = HassEntityBase & { attributes: HassEntityAttributeBase & { target_temp_step?: number; diff --git a/packages/core/src/types/supported-services.ts b/packages/core/src/types/supported-services.ts index e54c46e2..1931313b 100644 --- a/packages/core/src/types/supported-services.ts +++ b/packages/core/src/types/supported-services.ts @@ -125,7 +125,7 @@ export interface DefaultServices { keep_days?: number; // Attempt to save disk space by rewriting the entire database file. repack?: boolean; - // Applys `entity_id` and `event_type` filters in addition to time-based purge. + // Apply `entity_id` and `event_type` filters in addition to time-based purge. apply_filter?: boolean; } >; @@ -262,6 +262,26 @@ export interface DefaultServices { // Disconnects the Home Assistant UI from the Home Assistant Cloud. You will no longer be able to access your Home Assistant instance from outside your local network. remoteDisconnect: ServiceFunction; }; + update: { + // Installs an update for this device or service. + install: ServiceFunction< + T, + { + // The version to install. If omitted, the latest version will be installed. @example 1.0.0 + version?: string; + // If supported by the integration, this creates a backup before starting the update . + backup?: boolean; + } + >; + // Marks currently available update as skipped. + skip: ServiceFunction; + // Removes the skipped version marker from an update. + clearSkipped: ServiceFunction; + }; + historyStats: { + // Reloads history stats sensors from the YAML-configuration. + reload: ServiceFunction; + }; tts: { // Say something using text-to-speech on a media player with google_translate. googleTranslateSay: ServiceFunction< @@ -314,26 +334,6 @@ export interface DefaultServices { } >; }; - update: { - // Installs an update for this device or service. - install: ServiceFunction< - T, - { - // The version to install. If omitted, the latest version will be installed. @example 1.0.0 - version?: string; - // If supported by the integration, this creates a backup before starting the update . - backup?: boolean; - } - >; - // Marks currently available update as skipped. - skip: ServiceFunction; - // Removes the skipped version marker from an update. - clearSkipped: ServiceFunction; - }; - historyStats: { - // Reloads history stats sensors from the YAML-configuration. - reload: ServiceFunction; - }; conversation: { // Launches a conversation from a transcribed text. process: ServiceFunction< @@ -358,12 +358,6 @@ export interface DefaultServices { } >; }; - restCommand: { - // - assistantRelay: ServiceFunction; - // - reload: ServiceFunction; - }; mediaPlayer: { // Turns on the power of the media player. turnOn: ServiceFunction; @@ -442,7 +436,7 @@ export interface DefaultServices { T, { // The ID of the content to play. Platform dependent. @example https://home-assistant.io/images/cast/splash.png - media_content_id: string; + media_content_id: string | number; // The type of the content to play. Such as image, music, tv show, video, episode, channel, or playlist. @example music media_content_type: string; // If the content should be played now or be added to the queue. @@ -474,6 +468,12 @@ export interface DefaultServices { // Reloads command line configuration from the YAML-configuration. reload: ServiceFunction; }; + restCommand: { + // + assistantRelay: ServiceFunction; + // Reloads RESTful commands from the YAML-configuration. + reload: ServiceFunction; + }; light: { // Turn on one or more lights and adjust properties of the light, even when they are turned on already. turnOn: ServiceFunction< @@ -640,11 +640,11 @@ export interface DefaultServices { // Color in hue/sat format. A list of two integers. Hue is 0-360 and Sat is 0-100. @example [300, 70] hs_color?: [number, number]; // Color in XY-format. A list of two decimal numbers between 0 and 1. @example [0.52, 0.43] - xy_color?: object; + xy_color?: [number, number]; // Color temperature in mireds. - color_temp?: object; + color_temp?: number | object; // Color temperature in Kelvin. - kelvin?: number; + kelvin?: number | object; // Number indicating brightness, where 0 turns the light off, 1 is the minimum brightness, and 255 is the maximum brightness. brightness?: number; // Number indicating the percentage of full brightness, where 0 turns the light off, 1 is the minimum brightness, and 100 is the maximum brightness. @@ -654,7 +654,7 @@ export interface DefaultServices { // Change brightness by a percentage. brightness_step_pct?: number; // Set the light to white mode. - white?: object; + white?: boolean; // Name of a light profile to use. @example relax profile?: string; // Tell light to flash, can be either value short or long. @@ -834,17 +834,17 @@ export interface DefaultServices { // Color in hue/sat format. A list of two integers. Hue is 0-360 and Sat is 0-100. @example [300, 70] hs_color?: [number, number]; // Color in XY-format. A list of two decimal numbers between 0 and 1. @example [0.52, 0.43] - xy_color?: object; + xy_color?: [number, number]; // Color temperature in mireds. - color_temp?: object; + color_temp?: number | object; // Color temperature in Kelvin. - kelvin?: number; + kelvin?: number | object; // Number indicating brightness, where 0 turns the light off, 1 is the minimum brightness, and 255 is the maximum brightness. brightness?: number; // Number indicating the percentage of full brightness, where 0 turns the light off, 1 is the minimum brightness, and 100 is the maximum brightness. brightness_pct?: number; // Set the light to white mode. - white?: object; + white?: boolean; // Name of a light profile to use. @example relax profile?: string; // Tell light to flash, can be either value short or long. @@ -936,9 +936,59 @@ export interface DefaultServices { // Toggles a cover tilt open/closed. toggleCoverTilt: ServiceFunction; }; - schedule: { - // Reloads schedules from the YAML-configuration. + zone: { + // Reloads zones from the YAML-configuration. + reload: ServiceFunction; + }; + inputNumber: { + // Reloads helpers from the YAML-configuration. + reload: ServiceFunction; + // Sets the value. + setValue: ServiceFunction< + T, + { + // The target value. + value: number; + } + >; + // Increments the value by 1 step. + increment: ServiceFunction; + // Decrements the current value by 1 step. + decrement: ServiceFunction; + }; + inputDatetime: { + // Reloads helpers from the YAML-configuration. reload: ServiceFunction; + // Sets the date and/or time. + setDatetime: ServiceFunction< + T, + { + // The target date. @example '2019-04-20' + date?: string; + // The target time. @example '05:04:20' + time?: object; + // The target date & time. @example '2019-04-20 05:04:20' + datetime?: string; + // The target date & time, expressed by a UNIX timestamp. + timestamp?: number; + } + >; + }; + counter: { + // Increments a counter. + increment: ServiceFunction; + // Decrements a counter. + decrement: ServiceFunction; + // Resets a counter. + reset: ServiceFunction; + // Sets the counter value. + setValue: ServiceFunction< + T, + { + // The new counter value the entity should be set to. + value: number; + } + >; }; inputSelect: { // Reloads helpers from the YAML-configuration. @@ -980,32 +1030,16 @@ export interface DefaultServices { } >; }; - inputNumber: { - // Reloads helpers from the YAML-configuration. - reload: ServiceFunction; - // Sets the value. - setValue: ServiceFunction< - T, - { - // The target value. - value: number; - } - >; - // Increments the value by 1 step. - increment: ServiceFunction; - // Decrements the current value by 1 step. - decrement: ServiceFunction; - }; - zone: { - // Reloads zones from the YAML-configuration. - reload: ServiceFunction; - }; inputButton: { // Reloads helpers from the YAML-configuration. reload: ServiceFunction; // Mimics the physical button press on the device. press: ServiceFunction; }; + schedule: { + // Reloads schedules from the YAML-configuration. + reload: ServiceFunction; + }; switch: { // Turns a switch off. turnOff: ServiceFunction; @@ -1014,41 +1048,15 @@ export interface DefaultServices { // Toggles a switch on/off. toggle: ServiceFunction; }; - counter: { - // Increments a counter. - increment: ServiceFunction; - // Decrements a counter. - decrement: ServiceFunction; - // Resets a counter. - reset: ServiceFunction; - // Sets the counter value. - setValue: ServiceFunction< - T, - { - // The new counter value the entity should be set to. - value: number; - } - >; - // - configure: ServiceFunction; - }; - inputDatetime: { + inputBoolean: { // Reloads helpers from the YAML-configuration. reload: ServiceFunction; - // Sets the date and/or time. - setDatetime: ServiceFunction< - T, - { - // The target date. @example '2019-04-20' - date?: string; - // The target time. @example '05:04:20' - time?: object; - // The target date & time. @example '2019-04-20 05:04:20' - datetime?: string; - // The target date & time, expressed by a UNIX timestamp. - timestamp?: number; - } - >; + // Turns on the helper. + turnOn: ServiceFunction; + // Turns off the helper. + turnOff: ServiceFunction; + // Toggles the helper on/off. + toggle: ServiceFunction; }; script: { // Reloads all the available scripts. @@ -1072,15 +1080,31 @@ export interface DefaultServices { } >; }; - inputBoolean: { - // Reloads helpers from the YAML-configuration. + timer: { + // Reloads timers from the YAML-configuration. reload: ServiceFunction; - // Turns on the helper. - turnOn: ServiceFunction; - // Turns off the helper. - turnOff: ServiceFunction; - // Toggles the helper on/off. - toggle: ServiceFunction; + // Starts a timer. + start: ServiceFunction< + T, + { + // Duration the timer requires to finish. [optional]. @example 00:01:00 or 60 + duration?: string; + } + >; + // Pauses a timer. + pause: ServiceFunction; + // Cancels a timer. + cancel: ServiceFunction; + // Finishes a timer. + finish: ServiceFunction; + // Changes a timer. + change: ServiceFunction< + T, + { + // Duration to add or subtract to the running timer. @example 00:01:00, 60 or -60 + duration: string; + } + >; }; scene: { // Reloads the scenes from the YAML-configuration. @@ -1107,6 +1131,8 @@ export interface DefaultServices { snapshot_entities?: string; } >; + // Deletes a dynamically created scene. + delete: ServiceFunction; // Activates a scene. turnOn: ServiceFunction< T, @@ -1116,85 +1142,81 @@ export interface DefaultServices { } >; }; - timer: { - // Reloads timers from the YAML-configuration. - reload: ServiceFunction; - // Starts a timer. - start: ServiceFunction< + camera: { + // Enables the motion detection. + enableMotionDetection: ServiceFunction; + // Disables the motion detection. + disableMotionDetection: ServiceFunction; + // Turns off the camera. + turnOff: ServiceFunction; + // Turns on the camera. + turnOn: ServiceFunction; + // Takes a snapshot from a camera. + snapshot: ServiceFunction< T, { - // Duration the timer requires to finish. [optional]. @example 00:01:00 or 60 - duration?: string; + // Template of a filename. Variable available is `entity_id`. @example /tmp/snapshot_{{ entity_id.name }}.jpg + filename: string; } >; - // Pauses a timer. - pause: ServiceFunction; - // Cancels a timer. - cancel: ServiceFunction; - // Finishes a timer. - finish: ServiceFunction; - // Changes a timer. - change: ServiceFunction< + // Plays the camera stream on a supported media player. + playStream: ServiceFunction< T, { - // Duration to add or subtract to the running timer. @example 00:01:00, 60 or -60 - duration: string; + // Media players to stream to. + media_player: string; + // Stream format supported by the media player. + format?: "hls"; } >; - }; - profiler: { - // Starts the Profiler. - start: ServiceFunction< + // Creates a recording of a live camera feed. + record: ServiceFunction< T, { - // The number of seconds to run the profiler. - seconds?: number; + // Template of a filename. Variable available is `entity_id`. Must be mp4. @example /tmp/snapshot_{{ entity_id.name }}.mp4 + filename: string; + // Planned duration of the recording. The actual duration may vary. + duration?: number; + // Planned lookback period to include in the recording (in addition to the duration). Only available if there is currently an active HLS stream. The actual length of the lookback period may vary. + lookback?: number; } >; - // Starts the Memory Profiler. - memory: ServiceFunction< + }; + siren: { + // Turns the siren on. + turnOn: ServiceFunction< T, { - // The number of seconds to run the memory profiler. - seconds?: number; - } - >; - // Starts logging growth of objects in memory. - startLogObjects: ServiceFunction< - T, - { - // The number of seconds between logging objects. - scan_interval?: number; + // The tone to emit. When `available_tones` property is a map, either the key or the value can be used. Must be supported by the integration. @example fire + tone?: string; + // The volume. 0 is inaudible, 1 is the maximum volume. Must be supported by the integration. @example 0.5 + volume_level?: number; + // Number of seconds the sound is played. Must be supported by the integration. @example 15 + duration?: string; } >; - // Stops logging growth of objects in memory. - stopLogObjects: ServiceFunction; - // Starts logging sources of new objects in memory. - startLogObjectSources: ServiceFunction< + // Turns the siren off. + turnOff: ServiceFunction; + // Toggles the siren on/off. + toggle: ServiceFunction; + }; + weather: { + // Get weather forecast. + getForecast: ServiceFunction< T, { - // The number of seconds between logging objects. - scan_interval?: number; - // The maximum number of objects to log. - max_objects?: number; + // Forecast type: daily, hourly or twice daily. + type: "daily" | "hourly" | "twice_daily"; } >; - // Stops logging sources of new objects in memory. - stopLogObjectSources: ServiceFunction; - // Dumps the repr of all matching objects to the log. - dumpLogObjects: ServiceFunction< + // Get weather forecasts. + getForecasts: ServiceFunction< T, { - // The type of objects to dump to the log. @example State - type: string; + // Forecast type: daily, hourly or twice daily. + type: "daily" | "hourly" | "twice_daily"; } >; - // Logs the stats of all lru caches. - lruStats: ServiceFunction; - // Logs the current frames for all threads. - logThreadFrames: ServiceFunction; - // Logs what is scheduled in the event loop. - logEventLoopScheduled: ServiceFunction; }; remote: { // Turns the device off. @@ -1256,91 +1278,23 @@ export interface DefaultServices { // Press the button entity. press: ServiceFunction; }; - weather: { - // Get weather forecast. - getForecast: ServiceFunction< - T, - { - // Forecast type: daily, hourly or twice daily. - type: "daily" | "hourly" | "twice_daily"; - } - >; - }; - calendar: { - // Adds a new calendar event. - createEvent: ServiceFunction< - T, - { - // Defines the short summary or subject for the event. @example Department Party - summary: string; - // A more complete description of the event than the one provided by the summary. @example Meeting to provide technical review for 'Phoenix' design. - description?: string; - // The date and time the event should start. @example 2022-03-22 20:00:00 - start_date_time?: object; - // The date and time the event should end. @example 2022-03-22 22:00:00 - end_date_time?: object; - // The date the all-day event should start. @example 2022-03-22 - start_date?: object; - // The date the all-day event should end (exclusive). @example 2022-03-23 - end_date?: object; - // Days or weeks that you want to create the event in. @example {'days': 2} or {'weeks': 2} - in?: object; - // The location of the event. @example Conference Room - F123, Bldg. 002 - location?: string; - } - >; - // Lists events on a calendar within a time range. - listEvents: ServiceFunction< - T, - { - // Returns active events after this time (exclusive). When not set, defaults to now. @example 2022-03-22 20:00:00 - start_date_time?: object; - // Returns active events before this time (exclusive). Cannot be used with 'duration'. @example 2022-03-22 22:00:00 - end_date_time?: object; - // Returns active events from start_date_time until the specified duration. - duration?: object; - } - >; - }; - camera: { - // Enables the motion detection. - enableMotionDetection: ServiceFunction; - // Disables the motion detection. - disableMotionDetection: ServiceFunction; - // Turns off the camera. - turnOff: ServiceFunction; - // Turns on the camera. - turnOn: ServiceFunction; - // Takes a snapshot from a camera. - snapshot: ServiceFunction< + valve: { + // Opens a valve. + openValve: ServiceFunction; + // Closes a valve. + closeValve: ServiceFunction; + // Moves a valve to a specific position. + setValvePosition: ServiceFunction< T, { - // Template of a filename. Variable available is `entity_id`. @example /tmp/snapshot_{{ entity_id.name }}.jpg - filename: string; - } - >; - // Plays the camera stream on a supported media player. - playStream: ServiceFunction< - T, - { - // Media players to stream to. - media_player: string; - // Stream format supported by the media player. - format?: "hls"; - } - >; - // Creates a recording of a live camera feed. - record: ServiceFunction< - T, - { - // Template of a filename. Variable available is `entity_id`. Must be mp4. @example /tmp/snapshot_{{ entity_id.name }}.mp4 - filename: string; - // Planned duration of the recording. The actual duration may vary. - duration?: number; - // Planned lookback period to include in the recording (in addition to the duration). Only available if there is currently an active HLS stream. The actual length of the lookback period may vary. - lookback?: number; + // Target position. + position: number; } >; + // Stops the valve movement. + stopValve: ServiceFunction; + // Toggles a valve open/closed. + toggle: ServiceFunction; }; climate: { // Turns climate device on. @@ -1352,14 +1306,7 @@ export interface DefaultServices { T, { // HVAC operation mode. - hvac_mode?: - | "off" - | "auto" - | "cool" - | "dry" - | "fan_only" - | "heat_cool" - | "heat"; + hvac_mode?: "off" | "auto" | "cool" | "dry" | "fan_only" | "heat_cool" | "heat"; } >; // Sets preset mode. @@ -1389,14 +1336,7 @@ export interface DefaultServices { // Low target temperature. target_temp_low?: number; // HVAC operation mode. - hvac_mode?: - | "off" - | "auto" - | "cool" - | "dry" - | "fan_only" - | "heat_cool" - | "heat"; + hvac_mode?: "off" | "auto" | "cool" | "dry" | "fan_only" | "heat_cool" | "heat"; } >; // Sets target humidity. @@ -1424,24 +1364,6 @@ export interface DefaultServices { } >; }; - mediaExtractor: { - // Downloads file from given URL. - playMedia: ServiceFunction< - T, - { - // The ID of the content to play. Platform dependent. @example https://soundcloud.com/bruttoband/brutto-11 - media_content_id: string; - // The type of the content to play. Must be one of MUSIC, TVSHOW, VIDEO, EPISODE, CHANNEL or PLAYLIST MUSIC. - media_content_type: - | "CHANNEL" - | "EPISODE" - | "PLAYLIST MUSIC" - | "MUSIC" - | "TVSHOW" - | "VIDEO"; - } - >; - }; automation: { // Triggers the actions of an automation. trigger: ServiceFunction< @@ -1466,6 +1388,60 @@ export interface DefaultServices { // Reloads the automation configuration. reload: ServiceFunction; }; + profiler: { + // Starts the Profiler. + start: ServiceFunction< + T, + { + // The number of seconds to run the profiler. + seconds?: number; + } + >; + // Starts the Memory Profiler. + memory: ServiceFunction< + T, + { + // The number of seconds to run the memory profiler. + seconds?: number; + } + >; + // Starts logging growth of objects in memory. + startLogObjects: ServiceFunction< + T, + { + // The number of seconds between logging objects. + scan_interval?: number; + } + >; + // Stops logging growth of objects in memory. + stopLogObjects: ServiceFunction; + // Starts logging sources of new objects in memory. + startLogObjectSources: ServiceFunction< + T, + { + // The number of seconds between logging objects. + scan_interval?: number; + // The maximum number of objects to log. + max_objects?: number; + } + >; + // Stops logging sources of new objects in memory. + stopLogObjectSources: ServiceFunction; + // Dumps the repr of all matching objects to the log. + dumpLogObjects: ServiceFunction< + T, + { + // The type of objects to dump to the log. @example State + type: string; + } + >; + // Logs the stats of all lru caches. + lruStats: ServiceFunction; + // Logs the current frames for all threads. + logThreadFrames: ServiceFunction; + // Logs what is scheduled in the event loop. + logEventLoopScheduled: ServiceFunction; + }; alarmControlPanel: { // Disarms the alarm. alarmDisarm: ServiceFunction< @@ -1546,60 +1522,6 @@ export interface DefaultServices { } >; }; - humidifier: { - // Turns the humidifier on. - turnOn: ServiceFunction; - // Turns the humidifier off. - turnOff: ServiceFunction; - // Toggles the humidifier on/off. - toggle: ServiceFunction; - // Sets the humidifier operation mode. - setMode: ServiceFunction< - T, - { - // Operation mode. For example, _normal_, _eco_, or _away_. For a list of possible values, refer to the integration documentation. @example away - mode: string; - } - >; - // Sets the target humidity. - setHumidity: ServiceFunction< - T, - { - // Target humidity. - humidity: number; - } - >; - }; - select: { - // Selects the first option. - selectFirst: ServiceFunction; - // Selects the last option. - selectLast: ServiceFunction; - // Selects the next option. - selectNext: ServiceFunction< - T, - { - // If the option should cycle from the last to the first. - cycle?: boolean; - } - >; - // Selects an option. - selectOption: ServiceFunction< - T, - { - // Option to be selected. @example 'Item A' - option: string; - } - >; - // Selects the previous option. - selectPrevious: ServiceFunction< - T, - { - // If the option should cycle from the first to the last. - cycle?: boolean; - } - >; - }; fan: { // Turns fan on. turnOn: ServiceFunction< @@ -1664,39 +1586,87 @@ export interface DefaultServices { } >; }; - number: { - // Sets the value of a number. + lawnMower: { + // Starts the mowing task. + startMowing: ServiceFunction; + // Pauses the mowing task. + pause: ServiceFunction; + // Stops the mowing task and returns to the dock. + dock: ServiceFunction; + }; + humidifier: { + // Turns the humidifier on. + turnOn: ServiceFunction; + // Turns the humidifier off. + turnOff: ServiceFunction; + // Toggles the humidifier on/off. + toggle: ServiceFunction; + // Sets the humidifier operation mode. + setMode: ServiceFunction< + T, + { + // Operation mode. For example, _normal_, _eco_, or _away_. For a list of possible values, refer to the integration documentation. @example away + mode: string; + } + >; + // Sets the target humidity. + setHumidity: ServiceFunction< + T, + { + // Target humidity. + humidity: number; + } + >; + }; + text: { + // Sets the value. setValue: ServiceFunction< T, { - // The target value to set. @example 42 - value?: string; + // Enter your text. @example Hello world! + value: string; } >; }; - lock: { - // Unlocks a lock. - unlock: ServiceFunction< + waterHeater: { + // Turns water heater on. + turnOn: ServiceFunction; + // Turns water heater off. + turnOff: ServiceFunction; + // Turns away mode on/off. + setAwayMode: ServiceFunction< T, { - // Code used to unlock the lock. @example 1234 - code?: string; + // New value of away mode. + away_mode: boolean; } >; - // Locks a lock. - lock: ServiceFunction< + // Sets the target temperature. + setTemperature: ServiceFunction< T, { - // Code used to lock the lock. @example 1234 - code?: string; + // New target temperature for the water heater. + temperature: number; + // New value of the operation mode. For a list of possible modes, refer to the integration documentation. @example eco + operation_mode?: string; } >; - // Opens a lock. - open: ServiceFunction< + // Sets the operation mode. + setOperationMode: ServiceFunction< T, { - // Code used to open the lock. @example 1234 - code?: string; + // New value of the operation mode. For a list of possible modes, refer to the integration documentation. @example eco + operation_mode: string; + } + >; + }; + number: { + // Sets the value of a number. + setValue: ServiceFunction< + T, + { + // The target value to set. @example 42 + value?: string; } >; }; @@ -1705,7 +1675,7 @@ export interface DefaultServices { turnOn: ServiceFunction; // Stops the current cleaning task and returns to its dock. turnOff: ServiceFunction; - // + // Toggles the vacuum cleaner on/off. toggle: ServiceFunction; // Starts, pauses, or resumes the cleaning task. startPause: ServiceFunction; @@ -1740,77 +1710,121 @@ export interface DefaultServices { } >; }; - waterHeater: { - // Turns water heater on. - turnOn: ServiceFunction; - // Turns water heater off. - turnOff: ServiceFunction; - // Turns away mode on/off. - setAwayMode: ServiceFunction< + select: { + // Selects the first option. + selectFirst: ServiceFunction; + // Selects the last option. + selectLast: ServiceFunction; + // Selects the next option. + selectNext: ServiceFunction< T, { - // New value of away mode. - away_mode: boolean; + // If the option should cycle from the last to the first. + cycle?: boolean; } >; - // Sets the target temperature. - setTemperature: ServiceFunction< + // Selects an option. + selectOption: ServiceFunction< T, { - // New target temperature for the water heater. - temperature: number; - // New value of the operation mode. For a list of possible modes, refer to the integration documentation. @example eco - operation_mode?: string; + // Option to be selected. @example 'Item A' + option: string; } >; - // Sets the operation mode. - setOperationMode: ServiceFunction< + // Selects the previous option. + selectPrevious: ServiceFunction< T, { - // New value of the operation mode. For a list of possible modes, refer to the integration documentation. @example eco - operation_mode: string; + // If the option should cycle from the first to the last. + cycle?: boolean; } >; }; - text: { - // Sets the value. - setValue: ServiceFunction< + lock: { + // Unlocks a lock. + unlock: ServiceFunction< T, { - // Enter your text. @example Hello world! - value: string; + // Code used to unlock the lock. @example 1234 + code?: string; + } + >; + // Locks a lock. + lock: ServiceFunction< + T, + { + // Code used to lock the lock. @example 1234 + code?: string; + } + >; + // Opens a lock. + open: ServiceFunction< + T, + { + // Code used to open the lock. @example 1234 + code?: string; } >; }; - lawnMower: { - // Starts the mowing task. - startMowing: ServiceFunction; - // Pauses the mowing task. - pause: ServiceFunction; - // Stops the mowing task and returns to the dock. - dock: ServiceFunction; - }; - siren: { - // Turns the siren on. - turnOn: ServiceFunction< + mediaExtractor: { + // Downloads file from given URL. + playMedia: ServiceFunction< T, { - // The tone to emit. When `available_tones` property is a map, either the key or the value can be used. Must be supported by the integration. @example fire - tone?: string; - // The volume. 0 is inaudible, 1 is the maximum volume. Must be supported by the integration. @example 0.5 - volume_level?: number; - // Number of seconds the sound is played. Must be supported by the integration. @example 15 - duration?: string; + // The ID of the content to play. Platform dependent. @example https://soundcloud.com/bruttoband/brutto-11 + media_content_id: string | number; + // The type of the content to play. Must be one of MUSIC, TVSHOW, VIDEO, EPISODE, CHANNEL or PLAYLIST MUSIC. + media_content_type: "CHANNEL" | "EPISODE" | "PLAYLIST MUSIC" | "MUSIC" | "TVSHOW" | "VIDEO"; } >; - // Turns the siren off. - turnOff: ServiceFunction; - // Toggles the siren on/off. - toggle: ServiceFunction; }; - template: { - // Reloads template entities from the YAML-configuration. - reload: ServiceFunction; + calendar: { + // Adds a new calendar event. + createEvent: ServiceFunction< + T, + { + // Defines the short summary or subject for the event. @example Department Party + summary: string; + // A more complete description of the event than the one provided by the summary. @example Meeting to provide technical review for 'Phoenix' design. + description?: string; + // The date and time the event should start. @example 2022-03-22 20:00:00 + start_date_time?: object; + // The date and time the event should end. @example 2022-03-22 22:00:00 + end_date_time?: object; + // The date the all-day event should start. @example 2022-03-22 + start_date?: object; + // The date the all-day event should end (exclusive). @example 2022-03-23 + end_date?: object; + // Days or weeks that you want to create the event in. @example {'days': 2} or {'weeks': 2} + in?: object; + // The location of the event. @example Conference Room - F123, Bldg. 002 + location?: string; + } + >; + // Lists events on a calendar within a time range. + listEvents: ServiceFunction< + T, + { + // Returns active events after this time (exclusive). When not set, defaults to now. @example 2022-03-22 20:00:00 + start_date_time?: object; + // Returns active events before this time (exclusive). Cannot be used with 'duration'. @example 2022-03-22 22:00:00 + end_date_time?: object; + // Returns active events from start_date_time until the specified duration. + duration?: object; + } + >; + // Get events on a calendar within a time range. + getEvents: ServiceFunction< + T, + { + // Returns active events after this time (exclusive). When not set, defaults to now. @example 2022-03-22 20:00:00 + start_date_time?: object; + // Returns active events before this time (exclusive). Cannot be used with 'duration'. @example 2022-03-22 22:00:00 + end_date_time?: object; + // Returns active events from start_date_time until the specified duration. + duration?: object; + } + >; }; notify: { // Sends a notification that is visible in the **Notifications** panel. @@ -1868,6 +1882,10 @@ export interface DefaultServices { } >; }; + template: { + // Reloads template entities from the YAML-configuration. + reload: ServiceFunction; + }; google: { // Adds a new calendar event. addEvent: ServiceFunction< @@ -1914,6 +1932,16 @@ export interface DefaultServices { } >; }; + reolink: { + // Move the camera with a specific speed. + ptzMove: ServiceFunction< + T, + { + // PTZ move speed. + speed: number; + } + >; + }; mass: { // Perform a global search on the Music Assistant library and all providers. search: ServiceFunction< From f37700f94046d25a9cbad1030f8029588bbce78c Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 29 Jan 2024 15:31:58 +1100 Subject: [PATCH 2/2] adding changelog --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b16bbcb..fb3b7821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ + +# 3.1.2 +## @hakit/components +- Licence.md file updated +- ClimateCard - small changes to classes +- SidebarCard - sortSidebarMenuItems - now accepts a function to sort the menu items before they render +- Automatic typed introduced ValveEntity + +## @hakit/core +- updating base ha types +- some properties of auto generated types are now strictly typed and will no longer generate from the schema which has these properties defined as the incorrect type (xy_color, media_content_id, white, kelvin, color_temp) - there will most likely be more of these corrections in the future + # 3.1.1 ## @hakit/components - NEW - ClimateCard - completely rebuilt to match home assistant controls, as the original climate control was far too primitive, it supports everything the current climate card supports in home assistant. (Goodbye react-thermostat, sorry old shannon but it's just not good enough)