Compare commits

..
6 Commits
Author SHA1 Message Date
ari b342088b96 fixed up tsc error 2022-05-16 19:37:32 -04:00
ari c0c0d3181c v0.1.5 2022-05-16 19:27:03 -04:00
ari cf013cc342 fixed up styles 2022-05-16 19:27:03 -04:00
Ari Sosnovsky 23b869d43e Update README.md 2022-05-16 19:07:14 -04:00
Ari Sosnovsky e333e80ea3 Update README.md 2022-05-16 16:03:45 -04:00
Ari Sosnovsky 996e23038f Update README.md 2022-05-16 16:01:46 -04:00
10 changed files with 75 additions and 33 deletions

No files matched your search

+3 -2
View File
@@ -1,3 +1,4 @@
# Changelog -- [![GitHub version](https://badge.fury.io/gh/asosnovsky%2FShortumation.svg)](https://badge.fury.io/gh/asosnovsky%2FShortumation) # Changelog -- v0.1.5
- Updated Api Routing - Fixed up arrow styles due to typos
- Added selection color
+20 -2
View File
@@ -1,6 +1,11 @@
# Shortumation [![GitHub version](https://badge.fury.io/gh/asosnovsky%2FShortumation.svg)](https://badge.fury.io/gh/asosnovsky%2FShortumation) # Shortumation
A better way to write automations in home-assistant without having to install and run a seperate automation engine!
![image](https://user-images.githubusercontent.com/7451445/168672575-fb19997d-fe9b-4192-96b0-733b62519797.png)
![image](https://user-images.githubusercontent.com/7451445/168672840-71ceaa8a-2bee-443e-9150-5b0f03b05d08.png)
![image](https://user-images.githubusercontent.com/7451445/167028000-41528244-47be-408e-8f47-55187c0e5dcd.png)
A [home-assistent addon](https://www.home-assistant.io/addons/) for a better UI for managing your automations & scripts. We provide a way to visualize and develop your automation using a visual-programming language that draws inspirations from [Node-Red](https://nodered.org/). A [home-assistent addon](https://www.home-assistant.io/addons/) for a better UI for managing your automations & scripts. We provide a way to visualize and develop your automation using a visual-programming language that draws inspirations from [Node-Red](https://nodered.org/).
@@ -19,3 +24,16 @@ A [home-assistent addon](https://www.home-assistant.io/addons/) for a better UI
See roadmap in [Version 1 Github Project](https://github.com/asosnovsky/Shortumation/projects/1). See roadmap in [Version 1 Github Project](https://github.com/asosnovsky/Shortumation/projects/1).
## FAQ
**How is this different from Node-Red?**
> Node-Red is both an execution engine and an automation editor, which means that in order for you automations to run you have to have an additional component running and executing the automations. Shortumations simply provides a different editor and manager for writing Homeassistant automations, while relying on Homeassistant to execute the automations (this uses the `automations.yaml` file as the backend database)
**Which HA Installation does this support?**
> Currently this is only tested on HA OS. However, you should be able to get it working supervised installations as well (as they support addons). If you want to make it work for Container or Core, you will need to do some additional leg-work and I welcome a PR to get this working (it should be just a matter of mounting the `/config` path to the container running the images in this repo).
**Which version of HA does this require?**
> Since I am working on this project on my own, I can only test it against my own HA installations at home, and I tend to keep things as up to date as possible. The lowest version of HA this was tested on is `core-2022.5.4`
+1 -1
View File
@@ -1,5 +1,5 @@
name: Shortumation name: Shortumation
version: 0.1.4 version: 0.1.5
slug: shortumation slug: shortumation
image: asosnovsky/shortumation-{arch} image: asosnovsky/shortumation-{arch}
url: "https://github.com/asosnovsky/Shortumation" url: "https://github.com/asosnovsky/Shortumation"
@@ -15,7 +15,7 @@
} }
.automation-editor--info-box.show { .automation-editor--info-box.show {
min-width: 25em; min-width: 20em;
} }
.automation-editor--info-box.hide { .automation-editor--info-box.hide {
@@ -10,10 +10,12 @@
flex: 1; flex: 1;
user-select: none; user-select: none;
} }
.automation-list-box--body > * {
.automation-list-box--body>* {
padding-top: 0.5em; padding-top: 0.5em;
padding-bottom: 0.5em; padding-bottom: 0.5em;
} }
.automation-list-box--body--group { .automation-list-box--body--group {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -21,33 +23,37 @@
border-radius: 10px; border-radius: 10px;
padding-bottom: 0.5em; padding-bottom: 0.5em;
border-width: 1px; border-width: 1px;
border-bottom-style: solid ; border-bottom-style: solid;
border-color: white; border-color: white;
} }
.automation-list-box--body--group > .automation-list-box--body--group {
border-left-style: solid ; .automation-list-box--body--group>.automation-list-box--body--group {
border-left-style: solid;
border-top-left-radius: 0; border-top-left-radius: 0;
margin-left: 0.75em; margin-left: 0.75em;
padding-left: 0.5em; padding-left: 0.5em;
} }
.automation-list-box--body--group > b { .automation-list-box--body--group>b {
width: 100%; width: 100%;
cursor: pointer; cursor: pointer;
padding: 0.1em; padding: 0.1em;
} }
.automation-list-box--body--group > b:hover {
.automation-list-box--body--group>b:hover {
background-color: var(--secondary-accent); background-color: var(--secondary-accent);
color: var(--secondary); color: var(--secondary);
} }
.automation-list-box--body--item:hover { .automation-list-box--body--item:hover, .automation-list-box--body--item.selected {
background-color: var(--primary-accent); background-color: var(--primary-accent);
color: var(--primary); color: var(--primary);
} }
.automation-list-box--body--item:hover > .automation-list-box--body--item--tags > span {
.automation-list-box--body--item:hover>.automation-list-box--body--item--tags>span {
border-color: var(--primary); border-color: var(--primary);
} }
.automation-list-box--body--item { .automation-list-box--body--item {
padding-left: 1em; padding-left: 1em;
cursor: pointer; cursor: pointer;
@@ -57,25 +63,31 @@
gap: 1em; gap: 1em;
flex-wrap: wrap; flex-wrap: wrap;
} }
.automation-list-box--body--item::before { .automation-list-box--body--item::before {
content: "⊚ "; content: "⊚ ";
} }
.automation-list-box--body--item--title { .automation-list-box--body--item--title {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-left: 0.25em; padding-left: 0.25em;
flex: 1; flex: 1;
} }
.automation-list-box--body--item--title > b {
.automation-list-box--body--item--title>b {
font-size: 1em; font-size: 1em;
} }
.automation-list-box--body--item--title > span, .automation-list-box--body--item--title > b > span {
.automation-list-box--body--item--title>span, .automation-list-box--body--item--title>b>span {
font-size: 0.75em; font-size: 0.75em;
} }
.automation-list-box--body--item > button {
.automation-list-box--body--item>button {
padding: 0.25em !important; padding: 0.25em !important;
margin: 0.5em !important; margin: 0.5em !important;
} }
.automation-list-box--body--item--tags { .automation-list-box--body--item--tags {
flex: 1; flex: 1;
display: flex; display: flex;
@@ -87,13 +99,15 @@
max-height: 100%; max-height: 100%;
gap: 0.25em; gap: 0.25em;
} }
.automation-list-box--body--item--tags > span {
.automation-list-box--body--item--tags>span {
border-color: var(--primary-accent); border-color: var(--primary-accent);
border-style: solid; border-style: solid;
border-width: 1px; border-width: 1px;
border-radius: 0.5em; border-radius: 0.5em;
padding: 0.1em 0.5em; padding: 0.1em 0.5em;
} }
.automation-list-box--bottom { .automation-list-box--bottom {
margin-top: 0.5em; margin-top: 0.5em;
margin-bottom: 0.5em; margin-bottom: 0.5em;
@@ -102,7 +116,8 @@
justify-content: space-around; justify-content: space-around;
align-items: center; align-items: center;
} }
.automation-list-box--bottom > button {
.automation-list-box--bottom>button {
background-color: #070; background-color: #070;
color: var(--primary-accent); color: var(--primary-accent);
padding: 0.5em 2em; padding: 0.5em 2em;
@@ -13,10 +13,12 @@ export default {
const Template: ComponentStory<typeof AutomationListBox> = args => { const Template: ComponentStory<typeof AutomationListBox> = args => {
const [autos, setAutos] = useState(args.automations) const [selected, setSelected] = useState(args.selected)
console.log({ args })
return <div className="page"> return <div className="page">
<AutomationListBox {...args} automations={autos} /> <AutomationListBox {...args} automations={args.automations} selected={selected} onSelectAutomation={(i) => {
setSelected(i)
args.onSelectAutomation(i)
}} />
</div> </div>
} }
@@ -9,6 +9,7 @@ import { TrashIcon } from "components/Icons";
export type Props = { export type Props = {
automations: AutomationData[]; automations: AutomationData[];
selected: number;
onSelectAutomation: (i: number) => void; onSelectAutomation: (i: number) => void;
onRemove: (i: number) => void; onRemove: (i: number) => void;
onAdd: () => void; onAdd: () => void;
@@ -16,6 +17,7 @@ export type Props = {
export const AutomationListBox: FC<Props> = ({ export const AutomationListBox: FC<Props> = ({
automations, automations,
selected,
onSelectAutomation, onSelectAutomation,
onAdd, onAdd,
onRemove, onRemove,
@@ -23,9 +25,9 @@ export const AutomationListBox: FC<Props> = ({
const tags = getTagList(automations); const tags = getTagList(automations);
const [searchText, setSearchText] = useState(''); const [searchText, setSearchText] = useState('');
const [selected, setSelected] = useState<number[]>([]); const [selectedTagIdx, setSelectedTagIdx] = useState<number[]>([]);
const filteredAutomations = filterAutomations(automations, searchText, selected, tags); const filteredAutomations = filterAutomations(automations, searchText, selectedTagIdx, tags);
const groups = groupAutomations(filteredAutomations.map(([a, _]) => a), selected, tags); const groups = groupAutomations(filteredAutomations.map(([a, _]) => a), selectedTagIdx, tags);
return <div className="automation-list-box"> return <div className="automation-list-box">
<div className="automation-list-box--nav"> <div className="automation-list-box--nav">
@@ -36,14 +38,14 @@ export const AutomationListBox: FC<Props> = ({
/> />
<InputMultiSelect <InputMultiSelect
label="Tags" label="Tags"
selected={selected} selected={selectedTagIdx}
onChange={setSelected} onChange={setSelectedTagIdx}
options={tags} options={tags}
max={3} max={3}
/> />
</div> </div>
<div className="automation-list-box--body"> <div className="automation-list-box--body">
{convertGroupsToItems(groups, filteredAutomations, onSelectAutomation, onRemove)} {convertGroupsToItems(groups, filteredAutomations, onSelectAutomation, onRemove, selected)}
</div> </div>
<div className="automation-list-box--bottom"> <div className="automation-list-box--bottom">
<Button onClick={onAdd}>Add</Button> <Button onClick={onAdd}>Add</Button>
@@ -123,13 +125,14 @@ const convertGroupsToItems = (
autos: Array<[AutomationData, number]>, autos: Array<[AutomationData, number]>,
onSelectAutomation: (i: number) => void, onSelectAutomation: (i: number) => void,
onRemove: (i: number) => void, onRemove: (i: number) => void,
selected: number,
) => { ) => {
if (Array.isArray(groups)) { if (Array.isArray(groups)) {
return groups.map(i => { return groups.map(i => {
const [auto, autoIndex] = autos[i]; const [auto, autoIndex] = autos[i];
return <div return <div
key={i} key={i}
className="automation-list-box--body--item" className={["automation-list-box--body--item", selected === autoIndex ? 'selected' : ''].join(' ')}
title={`Name = ${auto.metadata.alias}\nID = ${auto.metadata.id}\nDescription = ${auto.metadata.description}`} title={`Name = ${auto.metadata.alias}\nID = ${auto.metadata.id}\nDescription = ${auto.metadata.description}`}
onClick={() => onSelectAutomation(autoIndex)} onClick={() => onSelectAutomation(autoIndex)}
> >
@@ -158,6 +161,7 @@ const convertGroupsToItems = (
autos={autos} autos={autos}
onSelectAutomation={onSelectAutomation} onSelectAutomation={onSelectAutomation}
onRemove={onRemove} onRemove={onRemove}
selected={selected}
/> />
}) })
} }
@@ -170,16 +174,18 @@ const AutomationListBoxGroup: FC<{
autos: Array<[AutomationData, number]>, autos: Array<[AutomationData, number]>,
onSelectAutomation: (i: number) => void, onSelectAutomation: (i: number) => void,
onRemove: (i: number) => void; onRemove: (i: number) => void;
selected: number,
}> = ({ }> = ({
groupName, groupName,
groups, groups,
autos, autos,
onSelectAutomation, onSelectAutomation,
onRemove, onRemove,
selected,
}) => { }) => {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
return <div className="automation-list-box--body--group"> return <div className="automation-list-box--body--group">
<b onClick={() => setOpen(!open)}>{groupName} {!open ? "⊕" : "⊖"}</b> <b onClick={() => setOpen(!open)}>{groupName} {!open ? "⊕" : "⊖"}</b>
{open && convertGroupsToItems(groups, autos, onSelectAutomation, onRemove)} {open && convertGroupsToItems(groups, autos, onSelectAutomation, onRemove, selected)}
</div> </div>
} }
@@ -9,7 +9,6 @@
.automation-list--list { .automation-list--list {
flex: 1; flex: 1;
min-width: 400px;
max-width: 400px; max-width: 400px;
position: relative; position: relative;
} }
@@ -42,6 +42,7 @@ export const AutomationList: FC<AutomationListParams> = ({
setCurrent(automations.length) setCurrent(automations.length)
}} }}
onSelectAutomation={setCurrent} onSelectAutomation={setCurrent}
selected={current}
onRemove={onRemove} onRemove={onRemove}
/> />
<ButtonIcon <ButtonIcon
+2 -2
View File
@@ -16,8 +16,8 @@ export const {
primaryLightOpaque: 'var(--primary-light-opaque)', primaryLightOpaque: 'var(--primary-light-opaque)',
secondary: 'var(--secondary)', secondary: 'var(--secondary)',
secondaryOpaque: 'var(--secondary-opaque)', secondaryOpaque: 'var(--secondary-opaque)',
primaryAccent: 'var(--primary-acccent)', primaryAccent: 'var(--primary-accent)',
primaryAccentLight: 'var(--primary-acccent-light)', primaryAccentLight: 'var(--primary-accent-light)',
secondaryAccent: 'var(--secondary-accent)', secondaryAccent: 'var(--secondary-accent)',
condition: { condition: {
primaryColor: 'var(--condition-primary)', primaryColor: 'var(--condition-primary)',