diff --git a/package.json b/package.json index c7b05c06df..f6c7c0fcb7 100644 --- a/package.json +++ b/package.json @@ -107,7 +107,7 @@ "fuse.js": "^6.0.0", "google-timezones-json": "^1.0.2", "hls.js": "^1.0.7", - "home-assistant-js-websocket": "^5.10.0", + "home-assistant-js-websocket": "^5.11.0", "idb-keyval": "^5.0.5", "intl-messageformat": "^9.6.16", "js-yaml": "^4.1.0", diff --git a/src/components/currency-datalist.ts b/src/components/currency-datalist.ts new file mode 100644 index 0000000000..7133aa560b --- /dev/null +++ b/src/components/currency-datalist.ts @@ -0,0 +1,168 @@ +export const createCurrencyListEl = () => { + const list = document.createElement("datalist"); + list.id = "currencies"; + for (const currency of [ + "AED", + "AFN", + "ALL", + "AMD", + "ANG", + "AOA", + "ARS", + "AUD", + "AWG", + "AZN", + "BAM", + "BBD", + "BDT", + "BGN", + "BHD", + "BIF", + "BMD", + "BND", + "BOB", + "BRL", + "BSD", + "BTN", + "BWP", + "BYR", + "BZD", + "CAD", + "CDF", + "CHF", + "CLP", + "CNY", + "COP", + "CRC", + "CUP", + "CVE", + "CZK", + "DJF", + "DKK", + "DOP", + "DZD", + "EGP", + "ERN", + "ETB", + "EUR", + "FJD", + "FKP", + "GBP", + "GEL", + "GHS", + "GIP", + "GMD", + "GNF", + "GTQ", + "GYD", + "HKD", + "HNL", + "HRK", + "HTG", + "HUF", + "IDR", + "ILS", + "INR", + "IQD", + "IRR", + "ISK", + "JMD", + "JOD", + "JPY", + "KES", + "KGS", + "KHR", + "KMF", + "KPW", + "KRW", + "KWD", + "KYD", + "KZT", + "LAK", + "LBP", + "LKR", + "LRD", + "LSL", + "LTL", + "LYD", + "MAD", + "MDL", + "MGA", + "MKD", + "MMK", + "MNT", + "MOP", + "MRO", + "MUR", + "MVR", + "MWK", + "MXN", + "MYR", + "MZN", + "NAD", + "NGN", + "NIO", + "NOK", + "NPR", + "NZD", + "OMR", + "PAB", + "PEN", + "PGK", + "PHP", + "PKR", + "PLN", + "PYG", + "QAR", + "RON", + "RSD", + "RUB", + "RWF", + "SAR", + "SBD", + "SCR", + "SDG", + "SEK", + "SGD", + "SHP", + "SLL", + "SOS", + "SRD", + "SSP", + "STD", + "SYP", + "SZL", + "THB", + "TJS", + "TMT", + "TND", + "TOP", + "TRY", + "TTD", + "TWD", + "TZS", + "UAH", + "UGX", + "USD", + "UYU", + "UZS", + "VEF", + "VND", + "VUV", + "WST", + "XAF", + "XCD", + "XOF", + "XPF", + "YER", + "ZAR", + "ZMK", + "ZWL", + ]) { + const option = document.createElement("option"); + option.value = currency; + option.innerHTML = currency; + list.appendChild(option); + } + return list; +}; diff --git a/src/data/core.ts b/src/data/core.ts index 667a90cd61..32006fbb7e 100644 --- a/src/data/core.ts +++ b/src/data/core.ts @@ -10,6 +10,7 @@ export interface ConfigUpdateValues { time_zone: string; external_url?: string | null; internal_url?: string | null; + currency?: string | null; } export interface CheckConfigResult { diff --git a/src/data/currency.ts b/src/data/currency.ts new file mode 100644 index 0000000000..d8ddf7933e --- /dev/null +++ b/src/data/currency.ts @@ -0,0 +1,8 @@ +export const SYMBOL_TO_ISO = { + $: "USD", + "€": "EUR", + "¥": "JPY", + "£": "GBP", + "₽": "RUB", + "₹": "INR", +}; diff --git a/src/fake_data/demo_config.ts b/src/fake_data/demo_config.ts index 68a99ee8e2..91052868ea 100644 --- a/src/fake_data/demo_config.ts +++ b/src/fake_data/demo_config.ts @@ -22,4 +22,5 @@ export const demoConfig: HassConfig = { state: STATE_RUNNING, internal_url: "http://homeassistant.local:8123", external_url: null, + currency: "USD", }; diff --git a/src/panels/config/core/ha-config-core-form.ts b/src/panels/config/core/ha-config-core-form.ts index 2d26def4ce..980f1cd5f9 100644 --- a/src/panels/config/core/ha-config-core-form.ts +++ b/src/panels/config/core/ha-config-core-form.ts @@ -7,11 +7,13 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; import { UNIT_C } from "../../../common/const"; +import { createCurrencyListEl } from "../../../components/currency-datalist"; import "../../../components/ha-card"; import "../../../components/map/ha-locations-editor"; import type { MarkerLocation } from "../../../components/map/ha-locations-editor"; import { createTimezoneListEl } from "../../../components/timezone-datalist"; import { ConfigUpdateValues, saveCoreConfig } from "../../../data/core"; +import { SYMBOL_TO_ISO } from "../../../data/currency"; import type { PolymerChangedEvent } from "../../../polymer-types"; import type { HomeAssistant } from "../../../types"; @@ -23,6 +25,8 @@ class ConfigCoreForm extends LitElement { @state() private _location?: [number, number]; + @state() private _currency?: string; + @state() private _elevation?: string; @state() private _unitSystem?: ConfigUpdateValues["unit_system"]; @@ -143,6 +147,33 @@ class ConfigCoreForm extends LitElement { +