Im attempting to bumble together a device type for a 2015 Sony Tv
Ive used some of the posts on here to get together a working script very messy and just basic buttons for control
so far i can put the tv into standbye and turn it on again, select inputs and send some remote commands, I can also poll the tv for status, “active” “standby”
the problem with the TV is after 20 mins or so of being in standby the tv goes to sleep, and it no longer responds to any command over the network (at least on wifi). If i poll it i dont get any response and i can’t bring it out of standby. I can however send a smart things WOL packet which wakes it up and turns the tv on again. this brings it out of standby so no use for polling as the Tv would turn on every 5 mins
i need to figure out a way of coding, it to say if you get no response from polling the TV set the TV as off, and when the ST on off switch is pressed send the wake on lan packet instead of the wake from standbye command (annoyingly although the WOL packet turns the tv on (the screen comes on), it doesnt bring it out of standby(screen stays off if in standby already) or i could just use that every time)
additional to this, this is the response to one of the polls of the TV
‘[index:17, mac:ACD1B83DDA7B, ip:C0A8000C, port:0050, requestId:bd6a4d7f-8886-4896-99db-ab970f0715ba, headers:[content-length:40, http/1.1 200 ok:null, connection:keep-alive, content-type:application/json, date:Tue, 22 Nov 2016 10:20:08 GMT], body:{“id”:2,“result”:[{“status”:“standby”}]}, header:HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 40
Connection: keep-alive
Date: Tue, 22 Nov 2016 10:20:08 GMT, status:200, data:[id:2, result:[[status:standby]]], json:[id:2, result:[[status:standby]]]]’
id like to parse this message for the Mac address, that way should someone want to use it for their TV they wont have to find it out, it will self populate
currently i parse it for status (standby like this)
def poll() {
log.debug "Executing ‘poll’"
def json = "{“id”:2,“method”:“getPowerStatus”,“version”:“1.0”,“params”:[]}"
def result = sendJsonRpcCommand(json)
}
def parse(description) {
def msg = parseLanMessage(description)
if (msg.json?.id == 2) {
def status = (msg.json.result[0]?.status == “active”) ? “on” : "off"
sendEvent(name: “switch”, value: status)
log.debug “TV is ‘${status}’”
}
}
any help would be great. thanks