Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitflow-feature-stash: small-updates #115

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
9 changes: 1 addition & 8 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
# 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

* EntitiesCard - updates to allow simple controls like toggling a light/switch, or opening a cover
* 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.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 16 additions & 2 deletions packages/components/LICENCE.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
},
"author": "Shannon Hochkins <mail@shannonhochkins.com>",
"license": "ISC",
"license": "SEE LICENSE IN LICENSE.md",
"files": [
"dist",
"README.md",
Expand All @@ -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",
Expand Down
13 changes: 10 additions & 3 deletions packages/components/src/Cards/SidebarCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -270,6 +272,7 @@ function _SidebarCard({
includeTimeCard = true,
className,
cssStyles,
sortSidebarMenuItems,
...rest
}: SidebarCardProps) {
const [open, setOpen] = useState(startOpen);
Expand All @@ -278,7 +281,7 @@ function _SidebarCard({
const hash = useStore((state) => state.hash);
const devices = useBreakpoint();
const concatenatedMenuItems = useMemo<MenuItem[]>(() => {
const mappedRoutes = routes.map((route) => ({
const mappedRoutes = routes.map<MenuItem>((route) => ({
...route,
title: route.name,
onClick() {
Expand All @@ -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 (
<>
<Global
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HvacMode, HvacAction } from "@hakit/core";

export const HVAC_MODES = ["auto", "heat_cool", "heat", "cool", "dry", "fan_only", "off"] as const;
const HVAC_MODES = ["auto", "heat_cool", "heat", "cool", "dry", "fan_only", "off"] as const;

/** Temperature units. */
export const UNIT_C = "°C";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function _ClimateControls({
return (
<Wrapper
{...rest}
className={`climate-card-controls ${className}`}
css={css`
${cssStyles ?? ""}
`}
Expand Down Expand Up @@ -174,7 +175,7 @@ function _ClimateControls({
/>
</ButtonBar>
) : null}
<div className={`controls-scroll ${className}`}>
<div className={`controls-scroll`}>
{modes && !hideHvacModes && (
<Menu
placement="top"
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export { SidebarCard, type SidebarCardProps } from "./Cards/SidebarCard";
export { ClimateControls, type ClimateControlsProps } from "./Shared/Entity/Climate/ClimateControls";
export { ClimateControlSlider, type ClimateControlSliderProps } from "./Shared/Entity/Climate/ClimateControls/ClimateControlSlider";
export { ClimateHumiditySlider, type ClimateHumiditySliderProps } from "./Shared/Entity/Climate/ClimateControls/ClimateHumiditySlider";
export * from "./Shared/Entity/Climate/ClimateControls/data";
// LightControls
export { LightControls, type LightControlsProps } from "./Shared/Entity/Light/LightControls";
// CoverControls
Expand Down
18 changes: 16 additions & 2 deletions packages/core/LICENCE.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 5 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
}
},
"author": "Shannon Hochkins <mail@shannonhochkins.com>",
"license": "ISC",
"license": "SEE LICENSE IN LICENSE.md",
"files": [
"dist",
"package.json",
Expand All @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions packages/core/scripts/sync-user-types/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ export const REMAPPED_TYPES: Record<string, string> = {
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]`,
};
59 changes: 15 additions & 44 deletions packages/core/src/types/autogenerated-types-by-domain.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
Loading