From fd586256401ca9bc777c23995f9e6720787848db Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Sun, 19 Jan 2025 13:44:53 +0000 Subject: [PATCH 1/3] Info only menu item --- config.schema.json | 28 ++++++++++++++++++++++++---- source/HomeAssistantView.mc | 3 ++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/config.schema.json b/config.schema.json index d536b94..92dbf8f 100644 --- a/config.schema.json +++ b/config.schema.json @@ -70,7 +70,7 @@ "const": "template", "deprecated": true, "title": "Schema change:", - "description": "Use 'tap' instead." + "description": "Use 'info' or 'tap' instead." } }, "required": ["name", "content", "type"], @@ -93,7 +93,7 @@ "const": "template", "deprecated": true, "title": "Schema change:", - "description": "Use 'tap' instead." + "description": "Use 'info' or 'tap' instead." }, "tap_action": { "$ref": "#/$defs/tap_action" @@ -104,6 +104,23 @@ } ] }, + "info": { + "type": "object", + "properties": { + "name": { + "$ref": "#/$defs/name" + }, + "content": { + "$ref": "#/$defs/content" + }, + "type": { + "$ref": "#/$defs/type", + "const": "info" + } + }, + "required": ["name", "content", "type"], + "additionalProperties": false + }, "tap": { "type": "object", "properties": { @@ -169,7 +186,7 @@ }, "type": { "title": "Menu item type", - "description": "One of 'tap', 'toggle' or 'group'." + "description": "One of 'info', 'tap', 'toggle' or 'group'." }, "items": { "type": "array", @@ -185,6 +202,9 @@ { "$ref": "#/$defs/tap" }, + { + "$ref": "#/$defs/info" + }, { "$ref": "#/$defs/group" } @@ -192,7 +212,7 @@ } }, "name": { - "title": "Your familiar name", + "title": "Your familiar name to display in the menu item", "type": "string" }, "entity": { diff --git a/source/HomeAssistantView.mc b/source/HomeAssistantView.mc index 9d94e9f..5bd7877 100644 --- a/source/HomeAssistantView.mc +++ b/source/HomeAssistantView.mc @@ -64,7 +64,8 @@ class HomeAssistantView extends WatchUi.Menu2 { if (type != null && name != null) { if (type.equals("toggle") && entity != null) { addItem(HomeAssistantMenuItemFactory.create().toggle(name, entity, content, confirm, pin)); - } else if ((type.equals("tap") && service != null) || (type.equals("template") && content != null)) { + } else if ((type.equals("tap") && service != null) || (type.equals("info") && content != null) || (type.equals("template") && content != null)) { + // NB. "template" is deprecated in the schema and remains only for backward compatibility. All menu items can now use templates, so the replacement is "info". addItem(HomeAssistantMenuItemFactory.create().tap(name, entity, content, service, confirm, pin, data)); } else if (type.equals("group")) { addItem(HomeAssistantMenuItemFactory.create().group(items[i], content)); From ed4646511fe58a242ced9381329b84a08d51502c Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Sun, 19 Jan 2025 18:47:38 +0000 Subject: [PATCH 2/3] Added 5 new Instinct devices Small (imperfect) fix for 2 colour device icons. --- compile_sim.cmd | 14 ++++++++------ manifest.xml | 5 +++++ monkey.jungle | 22 ++++++++++++++++------ resources-icons-18-w/drawables.xml | 23 +++++++++++++++++++++++ resources-icons-18-w/error.svg | 1 + resources-icons-18-w/group_type.svg | 7 +++++++ resources-icons-18-w/info_type.svg | 1 + resources-icons-18-w/tap_type.svg | 1 + resources-icons-21-w/drawables.xml | 23 +++++++++++++++++++++++ resources-icons-21-w/error.svg | 1 + resources-icons-21-w/group_type.svg | 7 +++++++ resources-icons-21-w/info_type.svg | 1 + resources-icons-21-w/tap_type.svg | 1 + resources-icons-34/drawables.xml | 23 +++++++++++++++++++++++ resources-icons-34/error.svg | 1 + resources-icons-34/group_type.svg | 7 +++++++ resources-icons-34/info_type.svg | 1 + resources-icons-34/tap_type.svg | 1 + resources-icons-48/group_type.svg | 1 - resources-launcher-52-52/drawables.xml | 17 +++++++++++++++++ resources-launcher-52-52/launcher.svg | 4 ++++ 21 files changed, 149 insertions(+), 13 deletions(-) create mode 100644 resources-icons-18-w/drawables.xml create mode 100644 resources-icons-18-w/error.svg create mode 100644 resources-icons-18-w/group_type.svg create mode 100644 resources-icons-18-w/info_type.svg create mode 100644 resources-icons-18-w/tap_type.svg create mode 100644 resources-icons-21-w/drawables.xml create mode 100644 resources-icons-21-w/error.svg create mode 100644 resources-icons-21-w/group_type.svg create mode 100644 resources-icons-21-w/info_type.svg create mode 100644 resources-icons-21-w/tap_type.svg create mode 100644 resources-icons-34/drawables.xml create mode 100644 resources-icons-34/error.svg create mode 100644 resources-icons-34/group_type.svg create mode 100644 resources-icons-34/info_type.svg create mode 100644 resources-icons-34/tap_type.svg create mode 100644 resources-launcher-52-52/drawables.xml create mode 100644 resources-launcher-52-52/launcher.svg diff --git a/compile_sim.cmd b/compile_sim.cmd index 1005efb..bf3e89c 100644 --- a/compile_sim.cmd +++ b/compile_sim.cmd @@ -26,7 +26,7 @@ rem SDK_PATH should work for all users set /p SDK_PATH=<"%USERPROFILE%\AppData\Roaming\Garmin\ConnectIQ\current-sdk.cfg" set SDK_PATH=%SDK_PATH:~0,-1%\bin rem Assume we can create and use this directory -set DEST=export +set DEST=bin rem Device for simulation set DEVICE=venu2 @@ -72,17 +72,19 @@ rem -x,--excludes Add annotations to the exclude list (deprecated) rem -y,--private-key Private key to sign builds with rem -z,--rez Resource files (deprecated) +title Compiling for %DEVICE% + rem Batch file's directory where the source code is set SRC=%~dp0 rem drop last character '\' set SRC=%SRC:~0,-1% -if not exist %DEST% ( - md %DEST% +if exist %DEST% ( + rmdir /s /q %DEST% ) - -if exist %SRC%\export\HomeAssistant*.iq ( - del /f /q %SRC%\export\HomeAssistant*.iq +rem The above may not successfully delete the directory if there are locked files +if not exist %DEST% ( + mkdir %DEST% ) echo. diff --git a/manifest.xml b/manifest.xml index 14d1424..6974d01 100644 --- a/manifest.xml +++ b/manifest.xml @@ -117,7 +117,12 @@ + + + + + diff --git a/monkey.jungle b/monkey.jungle index f432ed6..8add2a2 100644 --- a/monkey.jungle +++ b/monkey.jungle @@ -31,8 +31,8 @@ project.manifest = manifest.xml # # The icons need to scale as a ratio of screen size 48:416 pixels # -# Icon 55 53 48 46 42 37 32 30 28 26 24 21 18 -# Screen 480 454 416 390 360 320 280 260 240 218 208 176 156 +# Icon 55 53 48 46 42 37 32 30 28 26 24 21 19 18 +# Screen 480 454 416 390 360 320 280 260 240 218 208 176 166 156 # Screen Size 390x390 launcher icon size 70x70 approachs7042mm.resourcePath = $(approachs7042mm.resourcePath);resources-launcher-70-70;resources-icons-46 @@ -166,13 +166,23 @@ fr965.resourcePath = $(fr965.resourcePath);resources-launcher-65-65;resources-ic # Screen Size 240x400 launcher icon size 38x33 gpsmap67.resourcePath = $(gpsmap67.resourcePath);resources-launcher-33-33;resources-icons-28 # Screen Size 176x176 launcher icon size 62x62 -instinct2.resourcePath = $(instinct2.resourcePath);resources-launcher-62-62;resources-icons-21 +instinct2.resourcePath = $(instinct2.resourcePath);resources-launcher-62-62;resources-icons-21-w # Screen Size 163x156 launcher icon size 54x54 -instinct2s.resourcePath = $(instinct2s.resourcePath);resources-launcher-54-54;resources-icons-18 +instinct2s.resourcePath = $(instinct2s.resourcePath);resources-launcher-54-54;resources-icons-18-w # Screen Size 176x176 launcher icon size 62x62 -instinct2x.resourcePath = $(instinct2x.resourcePath);resources-launcher-62-62;resources-icons-21 +instinct2x.resourcePath = $(instinct2x.resourcePath);resources-launcher-62-62;resources-icons-21-w +# Screen Size 390x390 launcher icon size 60x60, but the icon size used here is reduced as the menu items were clipped. +instinct3amoled45mm.resourcePath = $(instinct3amoled45mm.resourcePath);resources-launcher-60-60;resources-icons-32 +# Screen Size 416x416 launcher icon size 60x60, but the icon size used here is reduced as the menu items were clipped. +instinct3amoled50mm.resourcePath = $(instinct3amoled50mm.resourcePath);resources-launcher-60-60;resources-icons-34 +# Screen Size 176x176 launcher icon size 62x62 +instinct3solar45mm.resourcePath = $(instinct3solar45mm.resourcePath);resources-launcher-62-62;resources-icons-18-w # Screen Size 176x176 launcher icon size 26x26 -instinctcrossover.resourcePath = $(instinctcrossover.resourcePath);resources-launcher-26-26;resources-icons-21 +instinctcrossover.resourcePath = $(instinctcrossover.resourcePath);resources-launcher-26-26;resources-icons-21-w +# Screen Size 166x166 launcher icon size 52x52, but the icon size used here is reduced as the menu items were clipped. +instincte40mm.resourcePath = $(instincte40mm.resourcePath);resources-launcher-52-52;resources-icons-18-w +# Screen Size 176x176 launcher icon size 62x62, but the icon size used here is reduced as the menu items were clipped. +instincte45mm.resourcePath = $(instincte45mm.resourcePath);resources-launcher-62-62;resources-icons-18-w # Screen Size 218x218 launcher icon size 30x30 legacyherocaptainmarvel.resourcePath = $(legacyherocaptainmarvel.resourcePath);resources-launcher-30-30;resources-icons-26 # Screen Size 260x260 launcher icon size 35x35 diff --git a/resources-icons-18-w/drawables.xml b/resources-icons-18-w/drawables.xml new file mode 100644 index 0000000..33c0707 --- /dev/null +++ b/resources-icons-18-w/drawables.xml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/resources-icons-18-w/error.svg b/resources-icons-18-w/error.svg new file mode 100644 index 0000000..a457398 --- /dev/null +++ b/resources-icons-18-w/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources-icons-18-w/group_type.svg b/resources-icons-18-w/group_type.svg new file mode 100644 index 0000000..8a67a91 --- /dev/null +++ b/resources-icons-18-w/group_type.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/resources-icons-18-w/info_type.svg b/resources-icons-18-w/info_type.svg new file mode 100644 index 0000000..65a4cc6 --- /dev/null +++ b/resources-icons-18-w/info_type.svg @@ -0,0 +1 @@ + diff --git a/resources-icons-18-w/tap_type.svg b/resources-icons-18-w/tap_type.svg new file mode 100644 index 0000000..6d52a9a --- /dev/null +++ b/resources-icons-18-w/tap_type.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources-icons-21-w/drawables.xml b/resources-icons-21-w/drawables.xml new file mode 100644 index 0000000..33c0707 --- /dev/null +++ b/resources-icons-21-w/drawables.xml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/resources-icons-21-w/error.svg b/resources-icons-21-w/error.svg new file mode 100644 index 0000000..2b21d69 --- /dev/null +++ b/resources-icons-21-w/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources-icons-21-w/group_type.svg b/resources-icons-21-w/group_type.svg new file mode 100644 index 0000000..9996c00 --- /dev/null +++ b/resources-icons-21-w/group_type.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/resources-icons-21-w/info_type.svg b/resources-icons-21-w/info_type.svg new file mode 100644 index 0000000..4dcfba5 --- /dev/null +++ b/resources-icons-21-w/info_type.svg @@ -0,0 +1 @@ + diff --git a/resources-icons-21-w/tap_type.svg b/resources-icons-21-w/tap_type.svg new file mode 100644 index 0000000..2fcd199 --- /dev/null +++ b/resources-icons-21-w/tap_type.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources-icons-34/drawables.xml b/resources-icons-34/drawables.xml new file mode 100644 index 0000000..33c0707 --- /dev/null +++ b/resources-icons-34/drawables.xml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/resources-icons-34/error.svg b/resources-icons-34/error.svg new file mode 100644 index 0000000..f015c3f --- /dev/null +++ b/resources-icons-34/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources-icons-34/group_type.svg b/resources-icons-34/group_type.svg new file mode 100644 index 0000000..9b20a55 --- /dev/null +++ b/resources-icons-34/group_type.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/resources-icons-34/info_type.svg b/resources-icons-34/info_type.svg new file mode 100644 index 0000000..aa79943 --- /dev/null +++ b/resources-icons-34/info_type.svg @@ -0,0 +1 @@ + diff --git a/resources-icons-34/tap_type.svg b/resources-icons-34/tap_type.svg new file mode 100644 index 0000000..cf998ef --- /dev/null +++ b/resources-icons-34/tap_type.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources-icons-48/group_type.svg b/resources-icons-48/group_type.svg index 6ab40e7..322ef7d 100644 --- a/resources-icons-48/group_type.svg +++ b/resources-icons-48/group_type.svg @@ -1,4 +1,3 @@ - diff --git a/resources-launcher-52-52/drawables.xml b/resources-launcher-52-52/drawables.xml new file mode 100644 index 0000000..44c0b71 --- /dev/null +++ b/resources-launcher-52-52/drawables.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/resources-launcher-52-52/launcher.svg b/resources-launcher-52-52/launcher.svg new file mode 100644 index 0000000..85d3316 --- /dev/null +++ b/resources-launcher-52-52/launcher.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From b82e63d1913658b330852e778a69f5d912986944 Mon Sep 17 00:00:00 2001 From: Philip Abbey Date: Sun, 19 Jan 2025 19:47:42 +0000 Subject: [PATCH 3/3] Documentation update --- HISTORY.md | 1 + README.md | 53 ++++++++++++++++++++++--------------------- examples/Templates.md | 30 ++++++++++++------------ 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index eb7019f..7446b14 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -35,3 +35,4 @@ | 2.20 | Simplified the code base now that templates have been requested in all menu items. This means the `template` menu item became a superset of `tap`. Therefore the `tap` code has been has been upgraded to include `template` and the latter deprecated. JSON menu definitions continue to support `template` items by instantiating a `tap` menu item, but the schema marks them as deprecated and users should migrate their menu definitions now. Use the [web editor](https://house-of-abbey.github.io/GarminHomeAssistant/web/) for assistance with changes. | | 2.21 | Added 7 new devices (`edge1050`, `enduro3`, `fenix843mm`, `fenix847mm`, `fenix8solar47mm`, `fenix8solar51mm`, `fenixe`) and upgraded the SDK to 7.3.0. Fix for a bug on Edge devices introduced by v2.16 activity reporting improvements. | | 2.22 | Major feature release adding an optional PIN to menu items. This significant new feature has been provided by [moesterheld](https://github.com/moesterheld). Please do not rely on this application for security. Use at your own risk! | +| 2.23 | Added "info" menu item for displaying information via a template without a tap or toggle. Essentially like the old 'template' type that was deprecated when all items were amended to display evaluated templates. That action removed the display only items too hastily. Added 5 new devices in the model range Instinct 3 and Instinct E. | diff --git a/README.md b/README.md index 2d89f6d..fd4b76d 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Home | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Temp A Garmin application to provide a "dashboard" to control your devices via [Home Assistant](https://www.home-assistant.io/). The application will never be as fully fledged as a Home Assistant dashboard, so it is designed to be good enough for the simple and essential things. Those things that can be activated via an on/off toggle or a tap. That should cover lights, switches, and anything requiring a single press such as an automation. For anything more complicated, e.g. thermostat, it would always be quicker and simpler to reach for your phone or tablet... or the device's own remote control! -The application is designed around a simple scrollable menu where menu items have been extended to interface with the [Home Assistant API](https://developers.home-assistant.io/docs/api/rest/), e.g. to get the status of switches or lights for display on the toggle menu item, or a text status for an entity (template item). It is possible to nest menus, so there is a menu item to open a sub-menu. This can be arbitrarily deep and nested in the format of a tree of items, although you need to consider if reaching for your phone becomes quicker to select the device what you want to control. +The application is designed around a simple scrollable menu where menu items have been extended to interface with the [Home Assistant API](https://developers.home-assistant.io/docs/api/rest/), e.g. to get the status of switches or lights for display on the `toggle` menu item, or a text status for an entity (`info` item). It is possible to nest menus, so there is a menu item to open a sub-menu. This can be arbitrarily deep and nested in the format of a tree of items, although you need to consider if reaching for your phone becomes quicker to select the device what you want to control. -**The intended audience for this application are those comfortable with configuring a Home Assistant** (e.g. editing the YAML configuration files) and debugging why URLs don't work. It does not require programming skills, but the menu is configured via JSON which feels like "coding". If you are not comfortable with this relatively low level of configuration, you may like to try other Garmin applications instead. +**The intended audience for this application are those comfortable with configuring a Home Assistant** (e.g. editing the YAML configuration files) and debugging why URLs don't work. It does not require programming skills, but the menu is configured via JSON which feels like "coding" (more like "describing"). If you are not comfortable with this relatively low level of configuration, you may like to try other Garmin applications instead. > [!IMPORTANT] > The Garmin SDK allows HTTP requests only to a limited number of domains specified in their app. Therefore, for your Garmin to communicate with your Home Assistant instance, your Home Assistant instance must be accessible via HTTPS (with a public certificate!) or through a local DNS server that overrides one of the whitelisted domains to communicate using HTTP. @@ -145,32 +145,33 @@ NB. Entity names are not real in case anyone's a hacker ;-). The example above illustrates how to configure: -* Lights or switches (toggle), -* Enables for automations (toggle), -* Script invocation (tap) -* Service invocation, e.g. Scene setting, (tap) -* A sub-menu to open (group) -* You can also display the status of devices (template) and add an optional 'tap' action. However that's a bit more involved and has its own [examples page](examples/Templates.md). Add those later! +* Lights or switches (`toggle`), +* Enables for automations (`toggle`), +* Script invocation (`tap`) +* Service invocation, e.g. Scene setting, (`tap`) +* A sub-menu to open (`group`) +* You can also display the status of devices (`info`) which is essentially a `tap` with no action +* All menu items can display the results of evaluating [templates](examples/Templates.md). -The following table indicates how Home Assistant entity types can map to the Garmin applications menu types. Presently, an automation is the only one that can be either a 'tap' or a 'toggle'. +The following table indicates how Home Assistant entity types can map to the Garmin applications menu types. Presently, an automation is the only one that can be either a `tap` or a `toggle`. -| HA Entity Type | Tap | Toggle | Template (custom status text with optional tap action) | -|------------------|:---:|:------:|:------------------------------------------------------:| -| Switch | ❌ | ✅ | ✅
Separate on and off, or anything in between | -| Light | ❌ | ✅ | ✅
Separate on and off, or anything in between | -| Automation | ✅ | ✅ | ✅ | -| Script | ✅ | ❌ | ✅ | -| Scene | ✅ | ❌ | ✅ | -| Sensor | ❌ | ❌ | ✅ | -| Binary Sensor | ❌ | ❌ | ✅ | -| Any other entity | ❌ | ❌ | ✅ | -| Any service | ✅ | ❌ | ✅ | +| HA Entity Type | Tap | Toggle | Info (status)| +|------------------|:---:|:------:|:------------:| +| Switch | ❌ | ✅ | ✅ | +| Light | ❌ | ✅ | ✅ | +| Automation | ✅ | ✅ | ❌ | +| Script | ✅ | ❌ | ❌ | +| Scene | ✅ | ❌ | ❌ | +| Sensor | ❌ | ❌ | ✅ | +| Binary Sensor | ❌ | ❌ | ✅ | +| Any other entity | ❌ | ❌ | ✅ | +| Any service | ✅ | ❌ | ❌ | -Templates need separate HTTP requests to update their status and send an action. Only the toggle items have the on/off icon. A Tap does not require a status update and hence does not require the associated HTTP GET request. NB. All 'tap' items must specify a 'service' tag. +Multiple templates are evaluated in a single HTTP request to update their status. Only the toggle items have the on/off icon. NB. All `tap` items must specify a `service` tag in the `tap_action` object (see example below). You can now specify alternative texts to use instead of "On" and "Off", e.g. "Locked" and "Unlocked" or "Open" and "Closed" through the use of a [template menu item](examples/Templates.md). But wouldn't having locks operated from your watch be a security concern ;-) ? -The [schema](https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json) is checked by using a URL directly back to this GitHub source repository, so you do not need to install that file. You can just copy & paste your entity names from the YAML configuration files used to configure Home Assistant. With a submenu, there's a difference between "title" and "name". The "name" goes on the menu item, and the "title" at the head of the submenu. If your dashboard definition fails to meet the schema, the application will simply drop items with the wrong field names without warning to protect itself. +The [schema](https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json) is checked by using a URL directly back to this GitHub source repository, so you do not need to install that file. You can just copy & paste your entity names from the YAML configuration files used to configure Home Assistant. With a submenu, there's a difference between `title` and `name`. The `name` goes on the menu item, and the `title` at the head of the submenu. If your dashboard definition fails to meet the schema, the application will simply drop items with the wrong field names without warning to protect itself. ### Old deprecated format @@ -198,13 +199,13 @@ The above should be replaced by the following: } ``` -This allows the `confirm` field to be accommodated in the `tap_action` along side the `service` tag, and follows the Home Assistant YAML format more closely. +This allows the `confirm` and `pin` fields to be accommodated in the `tap_action` along side the `service` tag, and follows the Home Assistant YAML format more closely. ### More Examples -- [Switches](examples/Switches.md) -- [Actions](examples/Actions.md) -- [Templates](examples/Templates.md) +* [Switches](examples/Switches.md) +* [Actions](examples/Actions.md) +* [Templates](examples/Templates.md) ## Editing the JSON file diff --git a/examples/Templates.md b/examples/Templates.md index ec27d82..743c267 100644 --- a/examples/Templates.md +++ b/examples/Templates.md @@ -20,7 +20,7 @@ In this example we get the battery level of the device and add the percent sign. ```json { "name": "Phone", - "type": "template", + "type": "info", "content": "{{ states('sensor._battery_level') }}%" } ``` @@ -32,17 +32,17 @@ The first two keep to the simple proposal above. The last combines them into a s ```json { "name": "Hall Temp", - "type": "template", + "type": "info", "content": "{{ states('sensor.hallway_temperature') }}°C" }, { "name": "Hall Humidity", - "type": "template", + "type": "info", "content": "{{ states('sensor.hallway_humidity') }}%" }, { "name": "Hallway", - "type": "template", + "type": "info", "content": "{{ states('sensor.hallway_temperature') }}°C {{ states('sensor.hallway_humidity') }}%" } ``` @@ -52,7 +52,7 @@ In order to keep the formatting of floating point numbers under control, you mig ```json { "name": "Hallway", - "type": "template", + "type": "info", "content": "T:{{ '%.1f' | format(states('sensor.hallway_temperature') | float) }}°C, H:{{ '%.1f' | format(states('sensor.hallway_humidity') | float) }}%" }, ``` @@ -62,12 +62,12 @@ Where your device supports unicode characters these example may work. ```json { "name": "Charge", - "type": "template", + "type": "info", "content": "☎ {{ states('sensor.my_phone_battery_level') }}%{% if is_state('binary_sensor.my_phone_is_charging', 'on') %}⚡{% endif %}, ⏳ {{ '%.0f'|format(states('sensor.my_watch_battery_level') | float) }}%{% if is_state('binary_binary_sensor.my_watch_battery_is_charging', 'on') %}⚡{% endif %}" }, { "name": "Hallway", - "type": "template", + "type": "info", "content": "🌡{% if is_state('sensor.hallway_temperature', 'unavailable') %}-{% else %}{{ '%.1f'|format(states('sensor.hallway_temperature')|float) }}°C{% if is_state_attr('climate.hallway', 'hvac_action', 'heating') or is_state_attr('climate.hallway', 'hvac_action', 'preheating') -%}🔥{%- endif %}{% endif %}, 💧{% if is_state('sensor.hallway_humidity', 'unavailable') %}-{% else %}{{ '%.1f'|format(states('sensor.hallway_humidity')|float) }}%{% endif %}" } ``` @@ -83,7 +83,7 @@ In this example we get the battery level of the device and add the percent sign. ```json { "name": "Phone", - "type": "template", + "type": "info", "content": "{{ states('sensor._battery_level') }}%{% if is_state('binary_sensor._is_charging', 'on') %}+{% endif %}" } ``` @@ -93,7 +93,7 @@ Here we also use the else clause as well to give proper text instead of just `on ```json { "name": "Garage Doors", - "type": "template", + "type": "info", "content": "{% if is_state('binary_sensor.', 'on') %}Open{% else %}Closed{% endif %} {% if is_state('binary_sensor.', 'on') %}Open{% else %}Closed{% endif %}" } ``` @@ -113,7 +113,7 @@ Note: Only when you use the `tap_action` field do you also need to include the ` { "entity": "cover.garage_door", "name": "Garage Door", - "type": "template", + "type": "tap", "content": "{% if is_state('binary_sensor.garage_connected', 'on') %}{{state_translated('cover.garage_door')}} - {{state_attr('cover.garage_door', 'current_position')}}%{%else%}Unconnected{% endif %}", "tap_action": { "service": "cover.toggle", @@ -150,7 +150,7 @@ Here we generate a bar graph of the battery level. We use the following steps to ```json { "name": "Phone", - "type": "template", + "type": "info", "content": "{{ states('sensor._battery_level') }}%{% if is_state('binary_sensor._is_charging', 'on') %}+{% endif %} {{ '#' * (((states('sensor._battery_level') | int) / 100 * ) | int) }}{{ '_' * ( - (((states('sensor._battery_level') | int) / 100 * ) | int)) }}" } ``` @@ -164,13 +164,13 @@ An example of a dimmer light with 4 brightness settings 0..3. Here our light wor "items": [ { "name": "LEDs", - "type": "template", + "type": "info", "content": "{% if not (is_state('light.green_house', 'off') or is_state('light.green_house', 'unavailable')) %}{{ (((state_attr('light.green_house', 'brightness') | float) / 255 * 100) | round(0)) | int }}%{% else %}Off{% endif %}" }, { "entity": "light.green_house", "name": "LEDs 0", - "type": "template", + "type": "tap", "content": "{% if not (is_state('light.green_house', 'off') or is_state('light.green_house', 'unavailable')) %}{{ (((state_attr('light.green_house', 'brightness') | float) / 255 * 100) | round(0)) | int }}%{% else %}Off{% endif %}", "tap_action": { "service": "light.turn_on", @@ -193,7 +193,7 @@ An example of a dimmer light with 4 brightness settings 0..3. Here our light wor { "entity": "light.green_house", "name": "LEDs 2", - "type": "template", + "type": "tap", "content": "{% if not (is_state('light.green_house', 'off') or is_state('light.green_house', 'unavailable')) %}{{ (((state_attr('light.green_house', 'brightness') | float) / 255 * 100) | round(0)) | int }}%{% else %}Off{% endif %}", "tap_action": { "service": "light.turn_on", @@ -205,7 +205,7 @@ An example of a dimmer light with 4 brightness settings 0..3. Here our light wor { "entity": "light.green_house", "name": "LEDs 3", - "type": "template", + "type": "tap", "content": "{% if not (is_state('light.green_house', 'off') or is_state('light.green_house', 'unavailable')) %}{{ (((state_attr('light.green_house', 'brightness') | float) / 255 * 100) | round(0))| int }}%{% else %}Off{% endif %}", "tap_action": { "service": "light.turn_on",