Timed Stop - Sleep

“Does the timer reset to off once it fire” -> Sure. This is how every sleep timer I’ve every seen functions.

1 Like

My guess that the way to implement this may be to have an option for a timer that can be set in a drop down for sleep in (65,95,125,185)* mins or in settings as a “default”. Once the timer fires, a popup “are you still there” like the one that some other apps/dvrs have comes up. If no response; then exit app. Once App is exited, the ATV sleep should be able to kick in and sleep (turning off the TV as well)

  • 5 mins above the common show lengths.
2 Likes

Why would the show lengths matter if the person is sleeping? The times should be set based on how long it takes people to fall asleep.

Love this app! Working wonderfully!

But, the lack of a Sleep feature was a bit disappointing. Our bedroom TV turns off at 1AM, but ATV4 continues to stream all night (and day if we are not diligent to turn off in the morning).

Found this tiny little guy, Broadlink RM Mini 3 for $19.99 @ Amazon.

https://www.amazon.com/BroadLink-Control-Universal-Remote-RMMINI3-EN/dp/B01FK2SDOC

It works!!! I set it up to do one thing (there is so much more, I'll probably play with it and Alexa support later). I set it to issue the 'MENU' command at 1AM. ATV4 exits the stream, screen saver turns on after 15mins, after 30 mins ATV4 goes to sleep and TV turns off with it due to HDMI control!! Shouldn't have to pay $19.99 to do this, but this thing is pretty cool, and it now ensures my TV is off, along with freeing up a tuner. You can program RM Mini 3 to issue the command daily, specific days, or for one time use.

2 Likes

This is a known issue in tvOS where we can’t detect when the tv turns off

I used a similar workaround to solve the lack of Sleep support in Channels, but without the need for an extra device. This python library allows you to send the “menu” or “top_menu” commands to your Apple TV: https://github.com/postlund/pyatv

Depending on your situation you can set up how/when it runs. I’ve got mine set up with HomeKit so there’s a fake switch in my Home app that when toggled will set up a timer to send the menu command after 30 minutes. If you always need it at 1AM, should be easier to set up.

1 Like

Would you mind sharing some additional detail on how you set this up?

Sure, I've got homebridge set up on my Mac with a plugin installed called cmdSwitch2 (links below). The config for cmdSwitch is set up so that when the switch in HomeKit is toggled on, it runs a command that waits 30 minutes and then runs the atvremote command that sends the top_menu button.

This allows you to ask Siri to turn on the Bedroom Sleep Timer and in 30 minutes, the Channels app should exit allowing the Apple TV's screen saver to kick in and turn off the TV after 15mins.

  • Make sure your Apple TV is set up with an assigned IP address through your router so the command won't need to change.
  • Use atvremote scan to find the correct login_id value to put in the config.

https://github.com/nfarina/homebridge
https://github.com/luisiam/homebridge-cmdswitch2
https://github.com/postlund/pyatv

~/.homebridge/config.json

{
  "bridge": {
    "name": "Homebridge",
    "username": "CC:22:3D:E3:CE:30",
    "port": 51826,
    "pin": "031-45-154"
  },
  "accessories": [
  ],
  "platforms": [
    { 
      "platform": "cmdSwitch2", 
      "name": "cmdSwitch2", 
      "switches": [
        { 
          "name": "Bedroom Sleep Timer",
          "on_cmd": "sleep 1800;atvremote --address 10.0.1.11 --login_id 00000000-0000-0000-0000-000000000000 top_menu", 
          "manufacturer": "Apple", 
          "model": "Apple TV 4" 
        }
      ] 
    }
  ]
}

Thank you. I have homebridge setup for some other automation. Missed this. Will give it a try.

Here’s another command you can use to control Channels tvOS directly:

curl -XPOST http://appletv.local:57000/api/stop

2 Likes

Interesting. What other API commands are there? Are they documented anywhere?

They are undocumented, private and subject to change at any time. :slight_smile:

I suspected as much. :grinning:

Except for STOP which was made public and documented here? :grimacing:

Where did we land on this? Is this feature still be considered? Possibly on the product roadmap? If not, did anyone come up with a work around that is more elegant than the home bridge solution? Nothing against the work around, just checking. Wife loves falling asleep with the TV and therefore we can’t get rid of the TV remote. If we had sleep, only Apple TV remotes all around. Thanks

This is on the roadmap, but no ETA at this time.

Is the roadmap published somewhere?

Nope sorry.

1 Like

Thanks for the reply. Glad to know this is still being thought of.

1 Like

I tried this command with ip address and hostname.local and I get an error:

curl -XPOST http://192.168.7.36:57000/api/stop
“curl: (7) Failed to connect to 192.168.7.29 port 57000: Connection refused”

Do I need to authenticate first? I am on the machine where the DVR software is running.