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

Fix errors when connection is closed #445

Merged
merged 3 commits into from
May 3, 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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# first stage, can't use alpine for building armv7
FROM node:21 AS builder
FROM node:22 AS builder
WORKDIR /app

# copy all files
Expand All @@ -11,7 +11,7 @@ RUN npm install --verbose && \
npm prune --omit=dev

# second stage
FROM node:21-alpine
FROM node:22-alpine
WORKDIR /app

# copy files to /app
Expand Down
2 changes: 2 additions & 0 deletions scripts/translations/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def process_dir(_dir, _output, _keys):
f"{COMPONENTS}/camera/translations/",
[
("camera", ["title"]),
("recording", ["entity_component", "_", "state", "recording"]),
("streaming", ["entity_component", "_", "state", "streaming"]),
],
),
( # UPDATE
Expand Down
8 changes: 8 additions & 0 deletions src/lib/Modal/getRandomEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function random(list: HassEntity[] | any[]) {
* number | %
*/
export function getPercentageEntity(states: HassEntities) {
if (states === undefined) return;
const filtered = Object.values(states).filter(
(entity) =>
entity.attributes &&
Expand All @@ -30,6 +31,7 @@ export function getPercentageEntity(states: HassEntities) {
* binary_sensor | sensor | state.length > 5 | !unavailable | !unknown
*/
export function getSensorEntity(states: HassEntities) {
if (states === undefined) return;
const sensors = Object.values(states).filter(
(entity) =>
entity.entity_id.startsWith('binary_sensor.') || entity.entity_id.startsWith('sensor.')
Expand All @@ -53,6 +55,7 @@ export function getSensorEntity(states: HassEntities) {
* Get random timer entity
*/
export function getTimerEntity(states: HassEntities) {
if (states === undefined) return;
const timers = Object.values(states).filter((e) => e.entity_id.startsWith('timer.'));
return timers.length ? random(timers).entity_id : undefined;
}
Expand All @@ -61,6 +64,7 @@ export function getTimerEntity(states: HassEntities) {
* Get random history entity
*/
export function getHistoryEntity(states: HassEntities) {
if (states === undefined) return;
const list = Object.values(states).filter(
(entity) => entity.state === 'on' || entity.state === 'off'
);
Expand All @@ -71,6 +75,7 @@ export function getHistoryEntity(states: HassEntities) {
* Get random weather entity
*/
export function getWeatherEntity(states: HassEntities) {
if (states === undefined) return;
const list = Object.values(states).filter((e) => e.entity_id.startsWith('weather.'));
return list.length ? random(list).entity_id : undefined;
}
Expand All @@ -79,6 +84,7 @@ export function getWeatherEntity(states: HassEntities) {
* Get random weather entity with forecast attribute
*/
export function getWeatherForecastEntity(states: HassEntities) {
if (states === undefined) return;
const list = Object.values(states).filter(
(entity) =>
entity.entity_id.startsWith('weather.') &&
Expand All @@ -97,6 +103,7 @@ export function getGraphEntity(
connection: any,
callback: (id: string | undefined) => void
) {
if (states === undefined) return;
connection.subscribe(async (conn: Connection) => {
if (!conn) {
callback(undefined);
Expand Down Expand Up @@ -137,6 +144,7 @@ export function getGraphEntity(
* Get random camera entity
*/
export function getCameraEntity(states: HassEntities) {
if (states === undefined) return;
const filtered = Object.values(states).filter((entity) => entity.entity_id.startsWith('camera.'));
const entity = random(filtered);
if (entity) return entity.entity_id;
Expand Down
6 changes: 4 additions & 2 deletions static/translations/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@
"fan_speed_low": "\u041d\u0438\u0441\u043a\u0430",
"fan_speed_medium": "\u0421\u0440\u0435\u0434\u043d\u0430",
"finish": "\u0444\u0438\u043d\u0430\u043b",
"forecast_daily": "\u0414\u043d\u0435\u0432\u043d\u0430",
"forecast_daily": "\u041f\u043e \u0434\u043d\u0438",
"forecast_hourly": "\u041f\u043e \u0447\u0430\u0441\u043e\u0432\u0435",
"forecast_twice_daily": "\u0414\u0432\u0430 \u043f\u044a\u0442\u0438 \u043d\u0430 \u0434\u0435\u043d",
"forecast_type": "\u0418\u0437\u0431\u0435\u0440\u0435\u0442\u0435 \u0442\u0438\u043f \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430",
"forecast_type": "\u0418\u0437\u0431\u0435\u0440\u0435\u0442\u0435 \u0442\u0438\u043f\u0430 \u043d\u0430 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430\u0442\u0430",
"forward": "\u041d\u0430\u043f\u0440\u0435\u0434",
"graph": "\u0413\u0440\u0430\u0444\u0438\u043a\u0430",
"group": "\u0413\u0440\u0443\u043f\u0430",
Expand Down Expand Up @@ -196,6 +196,7 @@
"precision": "\u041f\u0440\u0435\u0446\u0438\u0437\u043d\u043e\u0441\u0442 \u043d\u0430 \u0434\u0438\u0441\u043f\u043b\u0435\u044f",
"preview": "\u041f\u0440\u0435\u0433\u043b\u0435\u0434",
"raw": "\u0422\u0435\u043a\u0441\u0442\u043e\u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043d\u0430 Lovelace",
"recording": "\u0417\u0430\u043f\u0438\u0441\u0432\u0430\u043d\u0435",
"remove": "\u041f\u0440\u0435\u043c\u0430\u0445\u0432\u0430\u043d\u0435",
"return_home": "\u0412\u0440\u044a\u0449\u0430\u043d\u0435 \u0432\u043a\u044a\u0449\u0438",
"save": "\u0417\u0430\u043f\u0430\u0437\u0432\u0430\u043d\u0435",
Expand Down Expand Up @@ -230,6 +231,7 @@
"stop": "\u0421\u0442\u043e\u043f",
"stop_cover": "\u0421\u043f\u0438\u0440\u0430\u043d\u0435 \u043d\u0430 \u043f\u043e\u043a\u0440\u0438\u0432\u0430\u043b\u043e",
"stop_valve": "\u0421\u043f\u0438\u0440\u0430\u043d\u0435 \u043d\u0430 \u0432\u0435\u043d\u0442\u0438\u043b",
"streaming": "\u041f\u043e\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0430\u0432\u0430\u043d\u0435",
"successfully_saved": "\u0423\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u043f\u0430\u0437\u0435\u043d\u043e",
"suggestion": "\u0421\u044a\u0437\u0434\u0430\u0434\u043e\u0445\u043c\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430 \u0432\u0430\u0441",
"summary": "\u041e\u0431\u043e\u0431\u0449\u0435\u043d\u043e",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"preview": "Vista pr\u00e8via",
"quiet": "Suau",
"raw": "Editor de codi",
"recording": "Enregistrant",
"remove": "Elimina",
"reset": "Reinicialitzar",
"return_home": "Torna a casa",
Expand Down Expand Up @@ -263,6 +264,7 @@
"stop_cover": "Atura la coberta",
"stop_valve": "Atura v\u00e0lvula",
"stopped": "Aturada",
"streaming": "Transmetent v\u00eddeo",
"successfully_saved": "S'ha desat correctament",
"suggestion": "T'hem creat un suggeriment",
"summary": "Resum",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"preview": "N\u00e1hled",
"quiet": "Tich\u00fd",
"raw": "Editor k\u00f3du nastaven\u00ed",
"recording": "Nahr\u00e1v\u00e1",
"remove": "Odebrat",
"reset": "Resetovat",
"return_home": "N\u00e1vrat dom\u016f",
Expand Down Expand Up @@ -263,6 +264,7 @@
"stop_cover": "Zastavit",
"stop_valve": "Zastavit ventil",
"stopped": "Zastavena",
"streaming": "Streamuje",
"successfully_saved": "\u00dasp\u011b\u0161n\u011b ulo\u017eeno",
"suggestion": "Vytvo\u0159ili jsme pro v\u00e1s n\u00e1vrh",
"summary": "Souhrn",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
"preview": "Forh\u00e5ndsvisning",
"quiet": "Stille",
"raw": "Tekstbaseret redigering",
"recording": "Optager",
"remove": "Fjern",
"return_home": "Retur til ladestation",
"returning": "Vender tilbage til dock",
Expand Down Expand Up @@ -257,6 +258,7 @@
"stop_cover": "Stop gardin/port",
"stop_valve": "Stop ventil",
"stopped": "Stoppet",
"streaming": "Streamer",
"successfully_saved": "Gemt",
"suggestion": "Vi har lavet et forslag til dig",
"summary": "Resum\u00e9",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"preview": "Vorschau",
"quiet": "Ruhig",
"raw": "Raw-Konfigurationseditor",
"recording": "Aufnahme",
"remove": "Entfernen",
"reset": "Zur\u00fccksetzen",
"return_home": "Zur Basis zur\u00fcckkehren",
Expand Down Expand Up @@ -263,6 +264,7 @@
"stop_cover": "Abdeckung stoppen",
"stop_valve": "Ventil stoppen",
"stopped": "Angehalten",
"streaming": "\u00dcbertr\u00e4gt",
"successfully_saved": "Erfolgreich gespeichert",
"suggestion": "Wir haben einen Vorschlag f\u00fcr dich erstellt",
"summary": "Titel",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
"preview": "\u03a0\u03c1\u03bf\u03b5\u03c0\u03b9\u03c3\u03ba\u03cc\u03c0\u03b7\u03c3\u03b7",
"quiet": "\u0389\u03c3\u03c5\u03c7\u03bf",
"raw": "\u03a0\u03c1\u03cc\u03b3\u03c1\u03b1\u03bc\u03bc\u03b1 \u03b5\u03c0\u03b5\u03be\u03b5\u03c1\u03b3\u03b1\u03c3\u03af\u03b1\u03c2 \u03b4\u03b9\u03b1\u03bc\u03cc\u03c1\u03c6\u03c9\u03c3\u03b7\u03c2 raw",
"recording": "\u039a\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae",
"remove": "\u0391\u03c6\u03b1\u03af\u03c1\u03b5\u03c3\u03b7",
"return_home": "\u0395\u03c0\u03b9\u03c3\u03c4\u03c1\u03bf\u03c6\u03ae \u03c3\u03c4\u03b7 \u03b2\u03ac\u03c3\u03b7",
"returning": "\u0395\u03c0\u03b9\u03c3\u03c4\u03c1\u03bf\u03c6\u03ae \u03c3\u03c4\u03b7 \u03b2\u03ac\u03c3\u03b7",
Expand Down Expand Up @@ -253,6 +254,7 @@
"stop_cover": "\u03a3\u03c4\u03b1\u03bc\u03ac\u03c4\u03b7\u03bc\u03b1 \u03c1\u03bf\u03bb\u03bf\u03cd",
"stop_valve": "Stop valve",
"stopped": "\u03a3\u03c4\u03b1\u03bc\u03ac\u03c4\u03b7\u03c3\u03b5",
"streaming": "\u039c\u03b5\u03c4\u03ac\u03b4\u03bf\u03c3\u03b7",
"successfully_saved": "\u0391\u03c0\u03bf\u03b8\u03b7\u03ba\u03b5\u03cd\u03c4\u03b7\u03ba\u03b5 \u03bc\u03b5 \u03b5\u03c0\u03b9\u03c4\u03c5\u03c7\u03af\u03b1",
"suggestion": "\u0394\u03b7\u03bc\u03b9\u03bf\u03c5\u03c1\u03b3\u03ae\u03c3\u03b1\u03bc\u03b5 \u03bc\u03b9\u03b1 \u03c0\u03c1\u03cc\u03c4\u03b1\u03c3\u03b7 \u03b3\u03b9\u03b1 \u03b5\u03c3\u03ac\u03c2",
"summary": "\u03a3\u03cd\u03bd\u03bf\u03c8\u03b7",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
"preview": "Preview",
"quiet": "Quiet",
"raw": "Raw configuration editor",
"recording": "Recording",
"remove": "Remove",
"reset": "Reset",
"return_home": "Return home",
Expand Down Expand Up @@ -261,6 +262,7 @@
"stop_cover": "Stop cover",
"stop_valve": "Stop valve",
"stopped": "Stopped",
"streaming": "Streaming",
"successfully_saved": "Successfully saved",
"suggestion": "We created a suggestion for you",
"summary": "Summary",
Expand Down
4 changes: 3 additions & 1 deletion static/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"fan_modes": "Modos de ventilador",
"fan_only": "Solo ventilador",
"fan_oscillate": "Oscilar",
"fan_preset_mode": "Modo preestablecido",
"fan_preset_mode": "Modo predefinido",
"fan_reverse": "Inverso",
"fan_speed": "Velocidad del ventilador",
"fan_speed_high": "Alta",
Expand Down Expand Up @@ -225,6 +225,7 @@
"preview": "Vista previa",
"quiet": "Tranquilo",
"raw": "Editor de configuraci\u00f3n en bruto",
"recording": "Grabando",
"remove": "Eliminar",
"reset": "Restablecer",
"return_home": "Volver a la base",
Expand Down Expand Up @@ -263,6 +264,7 @@
"stop_cover": "Detener la persiana",
"stop_valve": "Detener v\u00e1lvula",
"stopped": "Detenido",
"streaming": "Transmitiendo",
"successfully_saved": "Guardado correctamente",
"suggestion": "Hemos creado una sugerencia para ti",
"summary": "Resumen",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"preview": "Eelvaade",
"quiet": "Vaikne",
"raw": "Konfiguratsiooni muutmine YAMLis",
"recording": "Salvestab",
"remove": "Eemalda",
"reset": "L\u00e4htesta",
"return_home": "Tagasi dokki",
Expand Down Expand Up @@ -263,6 +264,7 @@
"stop_cover": "Peata avakate",
"stop_valve": "Peata ventiili t\u00f6\u00f6",
"stopped": "Peatatud",
"streaming": "Voogedastab",
"successfully_saved": "Edukalt salvestatud",
"suggestion": "L\u00f5ime sulle ettepaneku",
"summary": "Kokkuv\u00f5te",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"preview": "Esikatselu",
"quiet": "Hiljainen",
"raw": "Raaka konfigurointieditori",
"recording": "Tallentaa",
"remove": "Poista",
"reset": "Nollaa",
"return_home": "Palaa kotiin",
Expand Down Expand Up @@ -263,6 +264,7 @@
"stop_cover": "Pys\u00e4yt\u00e4 suojus",
"stop_valve": "Pys\u00e4yt\u00e4 venttiili",
"stopped": "Pys\u00e4ytetty",
"streaming": "Toistaa",
"successfully_saved": "Tallennus onnistui",
"suggestion": "Loimme ehdotuksen sinulle",
"summary": "Yhteenveto",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
"preview": "Aper\u00e7u",
"quiet": "Calme",
"raw": "\u00c9diteur de configuration",
"recording": "Enregistrement",
"remove": "Supprimer",
"reset": "R\u00e9initialiser",
"return_home": "Retourner \u00e0 la base",
Expand Down Expand Up @@ -262,6 +263,7 @@
"stop_cover": "Arr\u00eater le volet",
"stop_valve": "Arr\u00eater la vanne",
"stopped": "Arr\u00eat\u00e9",
"streaming": "Diffusion en cours",
"successfully_saved": "Enregistr\u00e9 avec succ\u00e8s",
"suggestion": "Nous avons cr\u00e9\u00e9 une suggestion pour vous",
"summary": "R\u00e9sum\u00e9",
Expand Down
4 changes: 2 additions & 2 deletions static/translations/fy.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"addons": "Add-ons",
"after": "Nei",
"alarm_modes_armed_away": "\u00d4fw\u00eazich",
"alarm_modes_armed_custom_bypass": "Custom",
"alarm_modes_armed_custom_bypass": "Oanpast",
"alarm_modes_armed_home": "Th\u00fas",
"alarm_modes_armed_night": "Nacht",
"alarm_modes_armed_vacation": "Fak\u00e2nsje",
Expand Down Expand Up @@ -166,7 +166,7 @@
"show": "Toan",
"show_in_sidebar": "Toan yn sydbalke",
"show_more_info": "Lit mear ynformaasje sjen",
"show_password": "Show password",
"show_password": "Lit wachtwurd sjen",
"sidebar": "Sysbalke",
"size": "Grutte",
"start": "Start",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
"preview": "\u05ea\u05e6\u05d5\u05d2\u05d4 \u05de\u05e7\u05d3\u05d9\u05de\u05d4",
"quiet": "\u05e9\u05e7\u05d8",
"raw": "\u05e2\u05d5\u05e8\u05da \u05ea\u05e6\u05d5\u05e8\u05d4 \u05d2\u05d5\u05dc\u05de\u05d9\u05ea",
"recording": "\u05de\u05e7\u05dc\u05d9\u05d8",
"remove": "\u05d4\u05e1\u05e8\u05d4",
"reset": "\u05d0\u05d9\u05e4\u05d5\u05e1",
"return_home": "\u05d7\u05d5\u05d6\u05e8 \u05d4\u05d1\u05d9\u05ea\u05d4",
Expand Down Expand Up @@ -259,6 +260,7 @@
"stop_cover": "\u05e2\u05e6\u05d9\u05e8\u05ea \u05d5\u05d9\u05dc\u05d5\u05df",
"stop_valve": "\u05e2\u05e6\u05d9\u05e8\u05ea \u05e9\u05e1\u05ea\u05d5\u05dd",
"stopped": "\u05e2\u05e6\u05e8",
"streaming": "\u05de\u05d6\u05e8\u05d9\u05dd",
"successfully_saved": "\u05e0\u05e9\u05de\u05e8 \u05d1\u05d4\u05e6\u05dc\u05d7\u05d4",
"suggestion": "\u05d9\u05e6\u05e8\u05e0\u05d5 \u05d4\u05e6\u05e2\u05d4 \u05e2\u05d1\u05d5\u05e8\u05da",
"summary": "\u05ea\u05e7\u05e6\u05d9\u05e8",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"preview": "El\u0151n\u00e9zet",
"quiet": "Halk",
"raw": "YAML konfigur\u00e1ci\u00f3 szerkeszt\u0151",
"recording": "Felv\u00e9tel",
"remove": "Elt\u00e1vol\u00edt\u00e1s",
"reset": "Null\u00e1z\u00e1s",
"return_home": "Hazat\u00e9r\u00e9s",
Expand Down Expand Up @@ -263,6 +264,7 @@
"stop_cover": "Le\u00e1ll\u00edt\u00e1s",
"stop_valve": "Szelep meg\u00e1ll\u00edt\u00e1sa",
"stopped": "Meg\u00e1ll\u00edtva",
"streaming": "Streamel\u00e9s",
"successfully_saved": "Sikeresen elmentve",
"suggestion": "Javasolt k\u00e1rtya",
"summary": "\u00d6sszegz\u00e9s",
Expand Down
2 changes: 2 additions & 0 deletions static/translations/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"preview": "Pratinjau",
"quiet": "Hening",
"raw": "Editor konfigurasi mentah",
"recording": "Merekam",
"remove": "Hapus",
"reset": "Setel Ulang",
"return_home": "Kembali ke dok",
Expand Down Expand Up @@ -263,6 +264,7 @@
"stop_cover": "Hentikan penutup",
"stop_valve": "Hentikan katup",
"stopped": "Terhenti",
"streaming": "Streaming",
"successfully_saved": "Berhasil disimpan",
"suggestion": "Kami membuat saran untuk Anda",
"summary": "Ringkasan",
Expand Down
Loading