Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jamieyates79/fd49d23c1dac1add951ec8ba5f0ff8ae to your computer and use it in GitHub Desktop.
Save jamieyates79/fd49d23c1dac1add951ec8ba5f0ff8ae to your computer and use it in GitHub Desktop.
/**
* Sony X8309C
*
* Copyright 2016 Jamie Yates
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
* RAW IRCC codes from:
* http://www.openremote.org/display/forums/Sony+TV+HTTP+control
* Test CURL (not tested)
* curl -v -XPOST http://192.168.1.182/sony/IRCC -d '{"method":"getMethodTypes","params":[""],"id":7,"version":"1.0"}'
*/
metadata {
definition (name: "Sony X8309C", namespace: "jamieyates79", author: "Jamie Yates") {
capability "Switch"
}
simulator {
status "on": "on/off: 1"
status "off": "on/off: 0"
}
tiles {
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
state "on", label: 'AM ON', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
}
main "switch"
details "switch"
}
}
// parse events into attributes
def parse(String description) {
log.debug "Parsing '${description}'"
// TODO: handle 'volume' attribute
// TODO: handle 'channel' attribute
// TODO: handle 'power' attribute
// TODO: handle 'picture' attribute
// TODO: handle 'sound' attribute
// TODO: handle 'movieMode' attribute
}
// handle commands
//so this sends the correct SOAP code to the TV. The code below is a Wake On Lan code.
//https://community.smartthings.com/t/sony-bravia-tv-integration-discussion/29976/17
def on() {
log.debug "Executing 'on'"
def rawcmd = "AAAAAQAAAAEAAAAuAw==" //Wake On LAN
def ip = "192.168.1.182" //TV's IP
def port = "5353" //TV's Port
setDeviceNetworkId(ip,port)
log.debug( "Device IP:Port = ${ip}:${port}" )
def sonycmd = new physicalgraph.device.HubSoapAction(
path: '/sony/IRCC',
urn: "urn:schemas-sony-com:service:IRCC:1",
action: "X_SendIRCC",
body: ["IRCCCode":rawcmd],
headers: [Host:"${ip}:${port}", 'X-Auth-PSK':"1111"] //pre shared key (make sure TV is set up for Pre-shared Key!
)
sendHubCommand(sonycmd)
log.debug( "hubAction = ${sonycmd}" )
}
def off() {
log.debug "Executing 'off'"
def rawcmd = "AAAAAQAAAAEAAAAvAw==" //Wake On LAN
def ip = "192.168.1.182" //TV's IP
def port = "5353" //TV's Port
setDeviceNetworkId(ip,port)
log.debug( "Device IP:Port = ${ip}:${port}" )
def sonycmd = new physicalgraph.device.HubSoapAction(
path: '/sony/IRCC',
urn: "urn:schemas-sony-com:service:IRCC:1",
action: "X_SendIRCC",
body: ["IRCCCode":rawcmd],
headers: [Host:"${ip}:${port}", 'X-Auth-PSK':"1111"] //pre shared key (make sure TV is set up for Pre-shared Key!
)
sendHubCommand(sonycmd)
log.debug( "hubAction = ${sonycmd}" )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment