Files
GarminHomeAssistant/examples/Switches.md
2025-07-09 21:51:18 +01:00

2.9 KiB

Home | Switches | Actions | Templates | Glance | Background Service | Trouble Shooting | Version History

Switches

This is the simplest form:

 {
   "entity": "light.bedside_light_switch",
   "name": "Bedroom Light",
   "type": "toggle"
 },

And with an optional confirmation:

 {
   "entity": "light.exterior",
   "name": "Exterior Lights",
   "type": "toggle",
   "tap_action": {
     "confirm": true
   }
 }

or an optional PIN confirmation:

 {
   "entity": "light.exterior",
   "name": "Exterior Lights",
   "type": "toggle",
   "tap_action": {
     "pin": true
   }
 }

To support a non-standard light, switch, or automation as a toggle menu item you may like to define a custom switch. In order to facilitate custom switches at this time, you must create a template switch in HomeAssistant.

switch:
  - platform: template
    switches:
      <switch-name>:
        friendly_name: <name>
        value_template: <value>
        turn_on:
          service: <service>
          data:
            entity_id: <entity>
            <attribute>: <value>
        turn_off:
          service: <service>
          data:
            entity_id: <entity>
            <attribute>: <value>

Then you can use the following in your config:

{
  "entity": "switch.<switch-name>",
  "name": "<name>",
  "type": "toggle"
}

And you can optionally include a template to reflect some status. See Templates for details on hwo to use this JSON field.

{
  "entity": "switch.<switch-name>",
  "name": "<name>",
  "type": "toggle",
  "content": "..."
}

Example - Covers

switch:
  - platform: template
    switches:
      cover:
        friendly_name: Cover
        value_template: "{{ is_state('cover.cover', 'open') }}"
        turn_on:
          service: cover.open_cover
          data:
            entity_id: cover.cover
        turn_off:
          service: cover.close_cover
          data:
            entity_id: cover.cover

Then you can use the following in your config:

{
  "entity": "switch.cover",
  "name": "Cover",
  "type": "toggle"
}

Exit On Toggle

You can choose individual items that will quit after they have completed their action.

{
  "entity": "light.hall_light",
  "name": "Hall Light & Quit",
  "type": "toggle",
  "exit": true
}

Disable Menu Item

If you would like to temporarily disable an item in your menu, e.g. for seasonal reasons like not needing to turn on Christmas tree lights outside the festive season, then rather than swapping menu definition files or deleting a section of the menu you can mark the item as 'disabled'. This field applies to all menu items.

{
  "entity": "light.chrissmas_tree",
  "name": "Christmas Lights",
  "type": "toggle",
  "enabled": false
}