Skip to content

Commit

Permalink
Major renovation
Browse files Browse the repository at this point in the history
  • Loading branch information
rgc99 committed Jun 23, 2024
1 parent 9d81002 commit 2b54d35
Show file tree
Hide file tree
Showing 16 changed files with 3,450 additions and 538 deletions.
60 changes: 36 additions & 24 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"name": "Irrigation Unlimited Card Development",
"image": "ghcr.io/ludeeus/devcontainer/generic:latest",
"context": "..",
"appPort": ["5000:5000", "9123:8123"],
"postCreateCommand": "npm install",
"image": "mcr.microsoft.com/devcontainers/python:3.12-bookworm",
// "context": "..",
"appPort": [
"5000:5000",
"9123:8123"
],
"postCreateCommand": "scripts/setup",
"runArgs": [
"-v",
"${env:HOME}${env:USERPROFILE}/.ssh:/tmp/.ssh" // This is added so you can push from inside the container
],
"extensions": [
"github.vscode-pull-request-github",
"eamodio.gitlens",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"bierner.lit-html",
"runem.lit-plugin",
"auchenberg.vscode-browser-preview",
"davidanson.vscode-markdownlint",
"redhat.vscode-yaml"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
"customizations": {
"vscode": {
"extensions": [
"github.vscode-pull-request-github",
"eamodio.gitlens",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"bierner.lit-html",
"runem.lit-plugin",
"auchenberg.vscode-browser-preview",
"davidanson.vscode-markdownlint",
"redhat.vscode-yaml"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
},
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "latest"
}
}
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/node_modules/
/.rpt2_cache/
package-lock.json
/dist
.DS_Store
**config
7 changes: 0 additions & 7 deletions .prettierrc.js

This file was deleted.

1,691 changes: 1,691 additions & 0 deletions dist/irrigation-unlimited-card.js

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
"custom-cards",
"irrigation"
],
"type": "module",
"module": "irrigation-unlimited-card.js",
"repository": "https://github.com/rgc99/irrigation-unlimited-card",
"author": "rgc99",
"license": "MIT",
"dependencies": {
"@lit-labs/scoped-registry-mixin": "^1.0.0",
"custom-card-helpers": "^1.7.2",
"home-assistant-js-websocket": "^5.11.1",
"lit": "^2.0.0"
"global": "^4.4.0",
"home-assistant-js-websocket": "^9.3.0",
"lit": "^2.7.4"
},
"devDependencies": {
"@babel/core": "^7.15.0",
Expand All @@ -28,13 +29,14 @@
"@rollup/plugin-json": "^4.1.0",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.32.0",
"eslint": "^8.52.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.4.1",
"rollup": "^2.58.0",
"prettier": "^3.1.0",
"prettier-eslint": "^16.1.2",
"rollup": "^2.79.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
Expand All @@ -56,4 +58,4 @@
"lint": "eslint src/*.ts",
"rollup": "rollup -c"
}
}
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
homeassistant==2024.5.0
20 changes: 20 additions & 0 deletions scripts/develop
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

# Create config dir if not present
if [[ ! -d "${PWD}/config" ]]; then
mkdir -p "${PWD}/config"
hass --config "${PWD}/config" --script ensure_config
fi

# Set the path to custom_components
## This let's us have the structure we want <root>/custom_components/irrigation_unlimited
## while at the same time have Home Assistant configuration inside <root>/config
## without resulting to symlinks.
export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components"

# Start Home Assistant
hass --config "${PWD}/config" --debug
9 changes: 9 additions & 0 deletions scripts/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

npm install
npm install --global rollup

# HA runtime environment
set -e
cd "$(dirname "$0")/.."
python3 -m pip install --requirement requirements.txt
88 changes: 64 additions & 24 deletions src/editor.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { LitElement, html, TemplateResult, css, CSSResultGroup, nothing } from 'lit';
import { HomeAssistant, fireEvent } from 'custom-card-helpers';
import {
LitElement,
html,
TemplateResult,
css,
CSSResultGroup,
nothing,
} from "lit";
import { customElement, property, state } from "lit/decorators";
import { HomeAssistant } from "./ha-types";
import { fireEvent } from "./fire_event";

import { IrrigationUnlimitedCardConfig } from './types';
import { customElement, property, state } from 'lit/decorators';
import { IrrigationUnlimitedCardConfig } from "./types";

@customElement('irrigation-unlimited-card-editor')
@customElement("irrigation-unlimited-card-editor")
export class IrrigationUnlimitedCardEditor extends LitElement {

@property({ attribute: false }) public hass?: HomeAssistant;
@state() private _config?: IrrigationUnlimitedCardConfig;

Expand All @@ -16,11 +22,11 @@ export class IrrigationUnlimitedCardEditor extends LitElement {
}

get _name(): string {
return this._config?.name || '';
return this._config?.name || "";
}

get _show_controllers(): string {
return this._config?.show_controllers || '';
return this._config?.show_controllers || "";
}

get _always_show_zones(): boolean {
Expand All @@ -31,46 +37,74 @@ export class IrrigationUnlimitedCardEditor extends LitElement {
return this._config?.always_show_sequences || false;
}

get _show_timeline_scheduled(): boolean {
return this._config?.show_timeline_scheduled || false;
}

get _show_timeline_history(): boolean {
return this._config?.show_timeline_history || true;
}

protected render(): TemplateResult | typeof nothing {
if (!this.hass) {
return nothing;
}

return html`
<div class="iu-editor-row">
<div class="iu-editor-row">
<ha-textfield
label="Title (optional)"
.value=${this._name}
.configValue=${'name'}
.configValue=${"name"}
@input="${this._valueChanged}"
></ha-textfield>
</div>
<div class="iu-editor-row">
</div>
<div class="iu-editor-row">
<ha-textfield
label="Show controllers (CSV list)"
.value=${this._show_controllers}
.configValue=${'show_controllers'}
.configValue=${"show_controllers"}
@input="${this._valueChanged}"
></ha-textfield>
</div>
<div class="iu-editor-row">
</div>
<div class="iu-editor-row">
<ha-switch
id=${this._always_show_zones}
.checked=${this._always_show_zones}
.configValue=${'always_show_zones'}
.configValue=${"always_show_zones"}
@change=${this._valueChanged}
></ha-switch>
<label for=${this._always_show_zones}>Always show zones</label>
</div>
<div class="iu-editor-row">
</div>
<div class="iu-editor-row">
<ha-switch
id=${this._always_show_sequences}
.checked=${this._always_show_sequences}
.configValue=${'always_show_sequences'}
.configValue=${"always_show_sequences"}
@change=${this._valueChanged}
></ha-switch>
<label for=${this._always_show_sequences}>Always show sequences</label>
</div>
</div>
<div class="iu-editor-row">
<ha-switch
id=${this._show_timeline_scheduled}
.checked=${this._show_timeline_scheduled}
.configValue=${"show_timeline_scheduled"}
@change=${this._valueChanged}
></ha-switch>
<label for=${this._show_timeline_scheduled}
>Show timeline scheduled</label
>
</div>
<div class="iu-editor-row">
<ha-switch
id=${this._show_timeline_history}
.checked=${this._show_timeline_history}
.configValue=${"show_timeline_history"}
@change=${this._valueChanged}
></ha-switch>
<label for=${this._show_timeline_history}>Show timeline history</label>
</div>
`;
}

Expand All @@ -80,18 +114,24 @@ export class IrrigationUnlimitedCardEditor extends LitElement {
}
const target = ev.target;
if (target.configValue) {
if (target.value === '') {
if (target.value === "") {
const tmpConfig = { ...this._config };
delete tmpConfig[target.configValue];
this._config = tmpConfig;
} else {
this._config = {
...this._config,
[target.configValue]: target.checked !== undefined ? target.checked : target.value,
[target.configValue]:
target.checked !== undefined ? target.checked : target.value,
};
}
}
fireEvent(this, 'config-changed', { config: this._config }, { bubbles: true, composed: true });
fireEvent(
this,
"config-changed",
{ config: this._config },
{ bubbles: true, composed: true }
);
}

static styles: CSSResultGroup = css`
Expand Down
Loading

0 comments on commit 2b54d35

Please sign in to comment.