ha: log trigger errors and default after error

pull/3375/head
Rob Pilling 2024-04-21 19:29:27 +01:00
parent 3c2e6725fa
commit e2a62eabca
1 changed files with 5 additions and 3 deletions

View File

@ -33,15 +33,17 @@ function _getIcon(trigger){
} }
exports.getTriggers = function(){ exports.getTriggers = function(){
var triggers = [ var triggers;
{display: "Empty", trigger: "NOP", icon: "ha"},
];
try{ try{
triggers = require("Storage").read("ha.trigger.json"); triggers = require("Storage").read("ha.trigger.json");
triggers = JSON.parse(triggers); triggers = JSON.parse(triggers);
} catch(e) { } catch(e) {
// In case there are no user triggers yet, we show the default... // In case there are no user triggers yet, we show the default...
console.log("ha: error loading triggers:", e);
triggers = [
{display: "Empty", trigger: "NOP", icon: "ha"},
];
} }
// We lazy load all icons, otherwise, we have to keep // We lazy load all icons, otherwise, we have to keep