From 226945cae031007a86865dbbe22a42e951999f03 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Mon, 9 Dec 2024 12:34:19 -0700 Subject: [PATCH] fix: Fix Home Assistant event entities for openHAB (#25140) --- lib/extension/homeassistant.ts | 2 +- test/extensions/homeassistant.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/extension/homeassistant.ts b/lib/extension/homeassistant.ts index c399c6b516..531af427c1 100644 --- a/lib/extension/homeassistant.ts +++ b/lib/extension/homeassistant.ts @@ -2102,7 +2102,7 @@ export default class HomeAssistant extends Extension { ` {% set ns.r = ns.r|rejectattr(0, 'eq', key)|list + [(key, value)] %}\n` + ` {% endfor %}\n` + `{% endfor %}\n` + - `{% if ns.r|selectattr(0, 'eq', 'actionPrefix')|first is defined %}\n` + + `{% if (ns.r|selectattr(0, 'eq', 'actionPrefix')|first) is defined %}\n` + ` {% set ns.r = ns.r|rejectattr(0, 'eq', 'action')|list + [('action', ns.r|selectattr(0, 'eq', 'actionPrefix')|map(attribute=1)|first + ns.r|selectattr(0, 'eq', 'action')|map(attribute=1)|first)] %}\n` + `{% endif %}\n` + `{% set ns.r = ns.r + [('event_type', ns.r|selectattr(0, 'eq', 'action')|map(attribute=1)|first)] %}\n` + diff --git a/test/extensions/homeassistant.test.ts b/test/extensions/homeassistant.test.ts index 816a1fd338..3fe4bdf388 100644 --- a/test/extensions/homeassistant.test.ts +++ b/test/extensions/homeassistant.test.ts @@ -410,7 +410,7 @@ describe('Extension: HomeAssistant', () => { unique_id: '0x0017880104e45520_action_zigbee2mqtt', // Needs to be updated whenever one of the ACTION_*_PATTERN constants changes. value_template: - "{% set patterns = [\n{\"pattern\": '^(?P