From 32072f37d66c45dbd8e749cb842b3a2464663c3e Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sun, 21 Apr 2024 19:30:29 +0100 Subject: [PATCH] ha: getIcon() uses `this` --- apps/ha/ha.lib.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/ha/ha.lib.js b/apps/ha/ha.lib.js index 5a87387b1..0e15f9db9 100644 --- a/apps/ha/ha.lib.js +++ b/apps/ha/ha.lib.js @@ -2,8 +2,8 @@ * This library can be used to read all triggers that a user * configured and send a trigger to homeassistant. */ -function _getIcon(trigger){ - const icon = trigger.icon; +function _getIcon(){ + const icon = this.icon; if(icon == "light"){ return { width : 48, height : 48, bpp : 1, @@ -51,9 +51,7 @@ exports.getTriggers = function(){ // we lazy load icons only if needed using the getIcon // method of each trigger... triggers.forEach(trigger => { - trigger.getIcon = function(){ - return _getIcon(trigger); - } + trigger.getIcon = _getIcon.bind(trigger); }) return triggers;