Disable devices card?

i have recently made an automation to notify al the alexas around the house if there is motion at the front door but i am wondering if its possible to make a card so if need be i can unselect specific devices from being notified? i am very new to coding so i have no idea how to do it if its possible

maybe something like a device button selection card so all devices that are selected will be notified?

this is my current code

You can use the already existing do-not-disturb buttons in combination with type: announce:


service: notify.alexa_media
data:
  message: your message
  data:
    type: announce
  target: media_player.a, media_player.b, media_player.c

By using announce your Echos will only speak the message if the do-not-disturb button is set to off.

1 Like

would enabling that do not disturb affect anything else with the alexa devices though? also i do prefer tts as it doesn’t include the dong sounds at the beginning of the messages

As far as I could experience: no. But if you don’t like the announce dong, one approach would be to create input booleans corresponding to the object_id of your Alexa mediaplayers:

input_boolean.bri

input_boolean.living_room

…

and so on. After that, replace your automation action with:


  - service: notify.alexa_media
    data:
      message: blabla
      target: |
        {% set players =
          [
          'input_boolean.bri',
          'input_boolean.living_room',
          ]
          |select('is_state', 'on')
          |list |replace('input_boolean', 'media_player') %}
        {{ players if players != '[]' else 'media_player.your_fallback_alexa_mediaplayer' }}



The code above checks if any of your corresponding input bools are turned on. If so, the domain gets replaced with media_player to get the list of target players. The if-statement ensures that a notification is always played if you forget to activate the UI buttons.

1 Like

thanks a lot i gave this a shot straight up copy and pasting as i am quite clueless on how to code haha but i have gotten an error back in return any help?

Forgot to delete brackets, I’ve updated the code.

1 Like

still not quite?


n

Where are you trying to use the code?

1 Like

oh as an automation as thats all I’ve delt with so far really i assume its not that :stuck_out_tongue:

In your last post the code begins at line 1 of the editor, this cannot be right. Compare with your original automation code. May code example goes in the action part.

1 Like

thanks a lot im stupid i got this down now except no messages are being sent to the alexa devices? when run manually through the script nothing happens?

 alias: New Automation motion dec 2
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.front_door_camera_person
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition: []
action:
  - service: notify.alexa_media
    data:
      message: blabla
      target: >
        {% set players =
          [
          'input_boolean.bri',
          'input_boolean.craig_s_echo_show',
          ]
          |select('is_state', 'on')
          |list |replace('input_boolean', 'media_player') %}
        {{ players if players != '[]' else
        'media_player.your_fallback_alexa_mediaplayer' }}
mode: single

also from the looks of it whenever you talk to alexa it automatically disables do not disturb?

The automation works flawless here. Are the booleans activated?
Go to your automation, hit the 3 vertical dots top right, choose „traces“ and look into traces steps one by one. What is it telling?

1 Like

im not too sure what to look for in traces but did find this if its of any help?


stil nothing happening im unsure why exactly

I assume, no input boolean was activated because according to the trace protocol the target mediaplayer is the example fallback one. No offense but you really should take a look into the code and not only copy and paste. It’s on you to define an existing fallback mediaplayer.

1 Like

no yea i totally get it now thats on me for overlooking it hahah unfortunately trying to run it is only running the fallback player so i think i might have to give up on it considering I’m not great at this stuff and have no knowledge on getting it to work thanks so much for the help though

What you can do is to copy the code snippet into Developer Tools → Template and tell me the result.

Another thought: Is this the Alexa Mediaplayer Custom Component you are using or the Alexa integration via Home Assistant cloud?

1 Like


this is what i have gotten from the template and i am doing this through the alexa media player component, like i said the ffallback media plays fine but any boolian target doesnt play

The input booleans are all on?

1 Like

i think so? i am unsure how to check

??

Your initial question was

So what have youndone with the input booleans you’ve created? Have you added them to your frontend view?

1 Like