This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

apple tv standby
#1
Is there a way to standby an Apple tv from a LM script?
Reply
#2
There are some solutions in Python and NodeJS but that's not something that can be run on LM as is.
Reply
#3
Home Assistant support Apple TV standby, so i used that product also.

So make a script in Home Assistant and run that script with the LM

Code:
https = require('ssl.https')
json = require('json')
ltn12 = require('ltn12')
token = "xxxxxxxxxxxxxx" --generate long use token in HA (10 years lifetime)

function runScript(iDevice, iScript, iScriptId)
  data = json.encode({
    query = '{"entity_id": "'..iScriptId..'"}'
  })

  tbl = {}
  res, code = https.request({
    url = 'http://'..iDevice..'/api/services/script/'..iScript,
    method = 'POST',
    headers = {
      ['authorization'] = 'Bearer ' .. token,
      ['content-type']  = 'application/json',
      ['content-length'] = #data,
    },
    source = ltn12.source.string(data),
    sink = ltn12.sink.table(tbl),
  })

  --[[
  if res and code == 200 then
    resp = table.concat(tbl)
    resp = json.pdecode(resp)

    log(resp)
  else
    log(res, code)
  end
  --]]
end

-- standby apple tv woonkamer (ip, scriptname, scriptid)
--runScript("192.168.X.XX:8123", "AppleTVWoonkamer_Standby", "script.appletvwoonkamer_standby")
Reply


Forum Jump: