Skip to content

Commit

Permalink
1.8.5
Browse files Browse the repository at this point in the history
Fixed error on device init after changing device entities.
  • Loading branch information
RonnyWinkler committed Dec 23, 2024
1 parent e5333ea commit 55ca76f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .homeychangelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,10 @@
"1.8.4": {
"en": "Fix for reading initial energy settings for new devices.",
"de": "Korrektur beim Lesen der Energie-Einstellungen für neue Geräte."
},
"1.8.5": {
"en": "Fixed error on device init after changing device entities.",
"de": "Fehler beim Initialisieren eines Gerätes nach einer Entitaten-Aktualisierung korrigiert."
}

}
2 changes: 1 addition & 1 deletion .homeycompose/app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "io.home-assistant.community",
"version": "1.8.3",
"version": "1.8.5",
"compatibility": ">=12.2.0",
"sdk": 3,
"brandColor": "#0DA6EA",
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_comment": "This file is generated. Please edit .homeycompose/app.json instead.",
"id": "io.home-assistant.community",
"version": "1.8.3",
"version": "1.8.5",
"compatibility": ">=12.2.0",
"sdk": 3,
"brandColor": "#0DA6EA",
Expand Down
28 changes: 25 additions & 3 deletions drivers/basedevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const CAPABILITIES_SET_DEBOUNCE = 100;

// Device init timeout (sec). Reads entity data with a delay to get ready on app start
const DEVICE_INIT_TIMEOUT = 4;
const DEVICE_ONSETTINGS_TIMEOUT = 2;
const DEVICE_MAX_DEVICE_ENTITIES = 20;

const defaultValueConverter = {
Expand Down Expand Up @@ -46,14 +47,26 @@ class BaseDevice extends Homey.Device {

// // update settings from device attributes
try{
this.setSettings({class: this.getClass()});
try{
await this.setSettings({class: this.getClass()});
}
catch(error){
// catch error for setSettings() while onSettings() is still pending
this.log("basedevice.onInit(): Error setting device class: "+error.message);
}
let energy = this.getEnergy() || {};
let settings = {};
settings["set_energy_cumulative"] = energy["cumulative"] != undefined ? energy["cumulative"] : false;
settings["set_energy_home_battery"] = energy["homeBattery"] != undefined ? energy["homeBattery"] : false;
settings["set_energy_cumulative_imported_capability"] = energy["cumulativeImportedCapability"] != undefined ? energy["cumulativeImportedCapability"] : "";
settings["set_energy_cumulative_exported_capability"] = energy["cumulativeExportedCapability"] != undefined ? energy["cumulativeExportedCapability"] : "";
await this.setSettings(settings);
try{
await this.setSettings(settings);
}
catch(error){
// catch error for setSettings() while onSettings() is still pending
this.log("basedevice.onInit(): Error setting device class: "+error.message);
}
}
catch(error){
this.error("Error updating device enrergy settings: "+error.message);
Expand Down Expand Up @@ -430,7 +443,16 @@ class BaseDevice extends Homey.Device {
}
}

await this.onInit();
this.homey.setTimeout( async () =>
{
try{
await this.onInit();
}
catch(error){
this.log("baseDevice.addDeviceEntities() onInit() error: "+error.message);
}
},
DEVICE_ONSETTINGS_TIMEOUT * 1000 );
}

async removeDeviceEntities(type=null){
Expand Down
2 changes: 1 addition & 1 deletion locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"converter_code_03": "(value) => {\nreturn new Date(value).toLocaleString(\n 'de-DE',\n {\n hour12s: false,\n hour: '2-digit',\n minute: '2-digit',\n day: '2-digit',\n month: '2-digit',\n year: 'numeric'\n });\n}",
"converter_text_04": "Temperatur-Konvertierung °F=>°C",
"converter_code_04": "(value) => { return (parseFloat(value) - 32) * 5/9; }",
"converter_text_05": "Extrahiere Wert aus Test: 'In 3 minutes' => 3",
"converter_text_05": "Extrahiere Wert aus Text: 'In 3 minutes' => 3",
"converter_code_05": "(value) => { return value.split(' ')[1]; }",
"add_as_main_capability": "Als Haupt-Capability hinzufügen",
"result_count_01": "Zeige",
Expand Down

0 comments on commit 55ca76f

Please sign in to comment.