Disable Alexa when kid is in time out - Alexa media player

I’m trying to create an automation that will essentially disable my 6 year old son’s Alexa when he is in time out (which happens too often!). I’m really just throwing every setting at it that I can think of. But just wondering if anyone has any suggestions to improve it. It works, but sometimes he can still get it to talk to him.

I have an input_boolean to turn the automation on/off. And then it will re-trigger itself if he tries to turn the volume back up. Any thoughts or suggestions would be greatly appreciated!

- id: alexa_off
  alias: Alexa Off
  initial_state: true
  trigger:
    - platform: state
      entity_id: input_boolean.kid_alexa
      to: 'off'
    - platform: state
      entity_id: media_player.kid_echo_dot
  condition:
    condition: or
    conditions:
      - condition: state
        entity_id: input_boolean.kid_alexa
        state: 'off'
      - condition: and
        conditions:
          - condition: state
            entity_id: input_boolean.kid_alexa
            state: 'off'
          - condition: template
            value_template: '{{ trigger.to_state.attributes.volume_level | float > 0 }}'   # Volume has been raised above 0

  action:
    - service: media_player.volume_set
      entity_id: media_player.kid_echo_dot
      data:
        volume_level: 0
    
    - delay: '00:00:01'

    - service: media_player.volume_mute
      entity_id: media_player.kid_echo_dot
      data:
        is_volume_muted: true

    - delay: '00:00:01'

    - service: media_player.turn_off
      entity_id: media_player.kid_echo_dot

    - delay: '00:00:01'

    - service: switch.turn_on
      entity_id: switch.kid_echo_dot_do_not_disturb_switch

I probably would have went with the same things you have in your automation… next step would be a switched plug and you can kill power to it altogether… as long as it’s somewhat hidden so he can’t just power it back on

Thanks for the feedback, @Bartem! My first idea was to use a smart plug. That would be way easier. But he’s smart enough to just move the Echo to a different outlet.

Oh well that stinks, plugs were off-limits for mine at that age they wouldn’t dare try to plug anything in without help… show him a couple videos or pretend you are getting zapped one time when plugging something in… that may keep him away :slight_smile:

1 Like

Ya know you could make an automation to tell you when he uses it, with the last alexa used sensor and as part of your other automation toggle an input_boolean so it only notifies you if he tries to use it when it is “off”

Ooooooh, that sounds like a good idea. I didn’t realize there was a last used sensor. I’ll check that out!

Oh, you’re saying to CREATE a sensor? I checked and didn’t see anything like that already existing.

Yes, sorry I’ve had it for awhile so just kind thought it was automatic by now… there are instructions here: https://github.com/custom-components/alexa_media_player/wiki#creating-sensorlast-alexa

So, that looks like it is creating a sensor that tells you which Alexa device was last called. It is a step in the right direction, but I don’t think it tells me exactly what I need to know. I am more interested in triggering each time his particular Alexa is called.

I found there is an attribute called last_called_timestamp that changes every time you call Alexa. I think this is what I am looking for. I’m just not sure how to incorporate it into an automation. I would need to know that the value changed or incremented. Thoughts?

So you create the last alexa sensor as mentioned in the link, then make an automation that watches for a state change of media_player.your_kids_echo in the sensor.last_alexa… but also have a condition that watches an input_Boolean which you make that gets toggled when you want to “disable” the alexa so you only get the notification if he is not supposed to be using it

You can try removing the internet access on the device either via the router if supported or this one:

Haven’t tried it since I moved to Hassio.

If I understand that sensor correctly, it gives you the last Alexa device that was used. So wouldn’t this be an issue:
Boolean turns on
He calls Alexa
State changes, so automation fires
He calls Alexa again
State is still the same Alexa, so trigger does not fire

That’s why I was thinking the last_called_timestamp attribute might work better for this scenario. I just need to figure out how to recognize when it changes.

May I suggest this instead?
https://www.amazon.com/-/de/dp/B005GG0MXI

Best option if your router supports it is to block the device.
If your router doesn’t, then you can block with pihole

1 Like

Can you build an automation to make them listen? :slight_smile:

1 Like

I haven’t tested it yet because my son is asleep now. But I THINK this might do the trick. The idea being that if the Last Called Timestamp has incremented, then he has just activated Alexa.

      - condition: and
        conditions:
          - condition: state
            entity_id: input_boolean.kid_alexa
            state: 'off'
          - condition: template
            value_template: '{{ trigger.to_state.attributes.last_called_timestamp | float > trigger.from_state.attributes.last_called_timestamp | float }}'   # Alexa has been triggered

Lol, 6yo comfy plugging stuff in/out… reminds me of being the tender age of 8, dropping pennies on top of partially pulled out plugs so I could see the arc flash and show off melted pennies to friends.

Wait till they’re school age… if there is still ‘distance learning’, you’ll find the ‘tech methods’ of parenting of limited use. With all the tls secured meetings etc… there’s no real way to ‘keep the tech on task’ without literally looking over their shoulder.

1 Like

I’ve got it working now. Here is the finished product, if anyone is interested. I’m sure there is still a better way to accomplish this, so I am still open to suggestions if someone has better ideas!

Input Boolean:

input_boolean:
  kids_alexa:
    name: "Kid's Alexa"

Script:

kids_alexa_off:
  sequence:
    - service: media_player.volume_set
      entity_id: media_player.kids_echo_dot
      data:
        volume_level: 0
    - delay: '00:00:01'
    - service: media_player.volume_mute
      entity_id: media_player.kids_echo_dot
      data:
        is_volume_muted: true
    - delay: '00:00:01'
    - service: media_player.turn_off
      entity_id: media_player.kids_echo_dot
    - delay: '00:00:01'
    - service: switch.turn_on
      entity_id: switch.kids_echo_dot_do_not_disturb_switch

Automations:

# Disable Kid's Alexa
- id: kids_alexa_off
  alias: Kid's Alexa Off
  initial_state: true
  trigger:
    - platform: state
      entity_id: input_boolean.kids_alexa
      to: 'off'
  action:
    - service: script.kids_alexa_off


# Re-Disable Kid's Alexa if it is used while turned off
- id: kids_alexa_off_reset
  alias: Kid's Alexa Off - Reset
  initial_state: true
  trigger:
    - platform: state
      entity_id: media_player.kids_echo_dot
  condition:
    condition: or
    conditions:
      - condition: and
        conditions:
          - condition: state
            entity_id: input_boolean.kids_alexa
            state: 'off'
          - condition: template
            value_template: '{{ trigger.to_state.attributes.volume_level | float > 0 }}'   # Volume has been raised above 0
      - condition: and
        conditions:
          - condition: state
            entity_id: input_boolean.kids_alexa
            state: 'off'
          - condition: template
            value_template: '{{ trigger.to_state.attributes.last_called_timestamp | float > trigger.from_state.attributes.last_called_timestamp | float }}'   # Alexa has been triggered
  action:
    - service: script.kids_alexa_off
    

# Re-Enable Kids Alexa
- id: kids_alexa_on
  alias: Kid's Alexa On
  initial_state: true
  trigger:
    - platform: state
      entity_id: input_boolean.kids_alexa
      to: 'on'
  action:
    - service: media_player.volume_set
      entity_id: media_player.kids_echo_dot
      data:
        volume_level: 0.4
    - delay: '00:00:01'
    - service: switch.turn_off
      entity_id: switch.kids_echo_dot_do_not_disturb_switch
1 Like