Howto turn on/off a switch from markdown card content?


Is there a way to add a link/icon in the markdown card content that user can click to turn on/off a switch/light? I have a markdown card listing all switches/lights have been turned on for 2 hours. I would like to turn off them individually right in the content of the card. Thanks!

No. The Markdown card is output only.
Why are you using markdown rather than a “normal” entity(-ies) card?

The Markdown card is a curious choice for your intended application. Perhaps what will serve you better is to use the Auto-Entities Card (a custom Lovelace card). It can display a filtered list of entities.

There’s an example in its documentation for displaying only the lights that are on. The example uses a Glance Card (but you are free to use another type of card) to display the lights that are on. Tapping the Glance Card toggles the light’s state (i.e. it will turn off the light).

type: custom:auto-entities
show_empty: false
  type: glance
  title: Lights on
    - domain: light
      state: "on" # Remember that "on" and "off" are magic in yaml, and must always be quoted
          action: toggle

Thank you. Even though there could be a way that creating an ‘http in’ node in Node red to handle an ‘http get’ to turn off a switch (or do whatever), then put that link into markdown card. It’s way easier for this needs to use Auto-Entitites Card.

1 Like