From 256254e15e1bcd642054b90d25463707688ff52c Mon Sep 17 00:00:00 2001 From: Bernhard Date: Tue, 7 Jun 2022 13:59:08 +0200 Subject: Add home assistant recipe (#47) --- recipes/home-assistant/icon.svg | 25 +++++++++++++++++++++++++ recipes/home-assistant/index.js | 1 + recipes/home-assistant/package.json | 10 ++++++++++ recipes/home-assistant/webview.js | 12 ++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 recipes/home-assistant/icon.svg create mode 100644 recipes/home-assistant/index.js create mode 100644 recipes/home-assistant/package.json create mode 100644 recipes/home-assistant/webview.js (limited to 'recipes') diff --git a/recipes/home-assistant/icon.svg b/recipes/home-assistant/icon.svg new file mode 100644 index 0000000..9912764 --- /dev/null +++ b/recipes/home-assistant/icon.svg @@ -0,0 +1,25 @@ + + + + logo + Created with Sketch. + + + + + + + \ No newline at end of file diff --git a/recipes/home-assistant/index.js b/recipes/home-assistant/index.js new file mode 100644 index 0000000..dd41f72 --- /dev/null +++ b/recipes/home-assistant/index.js @@ -0,0 +1 @@ +module.exports = Ferdium => Ferdium; diff --git a/recipes/home-assistant/package.json b/recipes/home-assistant/package.json new file mode 100644 index 0000000..60e06e0 --- /dev/null +++ b/recipes/home-assistant/package.json @@ -0,0 +1,10 @@ +{ + "id": "home-assistant", + "name": "Home Assistant", + "version": "1.0.0", + "license": "MIT", + "config": { + "hasCustomUrl": true, + "hasNotificationSound": true + } +} diff --git a/recipes/home-assistant/webview.js b/recipes/home-assistant/webview.js new file mode 100644 index 0000000..a449cc4 --- /dev/null +++ b/recipes/home-assistant/webview.js @@ -0,0 +1,12 @@ +module.exports = Ferdium => { + const getMessages = () => { + const badges = document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("ha-sidebar").shadowRoot.querySelectorAll(".notification-badge"); + if (badges.length > 0) { + var count = Ferdium.safeParseInt(badges[0].textContent.replace(/[^\p{N}]/gu, '')); + Ferdium.setBadge(count) + } else { + Ferdium.setBadge(0) + } + }; + Ferdium.loop(getMessages); +}; -- cgit v1.2.3-70-g09d2