Guys I got basic on/off working with Tim’s help.
Now I have had someone help do a fuller solution in the device type with dimming control, which works on his v2 (uk) hub, works on my uk v2 hub, but not on my v1 (us) hub regardless of public or private IP address and port being used, can anyone see as to why it could be? Are these differences in how to write a device type dependant on which hub type there is?
metadata {
definition (name: “Dynalite Dimmer PS1”, namespace: “smartthings”, author: “PS”) {
capability "Switch Level"
capability "Actuator"
capability "Switch"
capability "Refresh"
capability “Sensor”
}
preferences {
section("IP Address Settings") {
input "IPAddress", "string", title:"IP Address", description: "IP Address of gateway", required: true
input "IPPort", "string", title:"Port", description: "Port", required: true
}
section("Dynet Settings") {
input "DynetArea", "number", title:"Area", description: "Area of channel", required: true
input "DynetChannel", "number", title:"Channel", description: "Channel Number", required: true
input "DynetFade", "number", title:"Fade Time", description: "Fade time ms", required: true
}
}
simulator {
// status messages
}
tiles(scale: 2) {
multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
attributeState "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821"
attributeState "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff"
}
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
attributeState "level", action:"switch level.setLevel"
}
}
standardTile("refresh", "device.power", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
}
main "switch"
details(["switch","refresh"])
}
}
// Parse incoming device messages to generate events
def parse(String description) {
log.debug “Parse description $description”
}
def parseDescriptionAsMap(description) {
(description - “read attr - “).split(”,”).inject([:]) { map, param ->
def nameAndValue = param.split(":")
map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
}
}
// Commands to device
def on() {
sendEvent(name: “switch”, value: “on”)
sendpreset(3,1);
}
def off() {
sendEvent(name: “switch”, value: “off”)
sendpreset(3,4);
}
private getIPAddress() {
settings.IPAddress
}
def setLevel(value) {
log.trace “setLevel($value)”
//this updates the level of the icon
sendEvent(name: "level", value: value)
if(value > 0){
sendEvent(name: "switch", value: "on")
}else{
sendEvent(name: "switch", value: "off")
}
sendchannellevel(3, 1, value);
}
def sendpreset(area, preset){
def ipaddress = settings.IPAddress + ":" + settings.IPPort;
def path = "/SetDyNet.cgi?a=" + settings.DynetArea + "&c=255&p=" + preset
def hubAction = new physicalgraph.device.HubAction(
method: "GET",
path: path,
headers: [HOST:ipaddress],
)
}
def sendchannellevel(area, channel, level){
def ipaddress = settings.IPAddress + ":" + settings.IPPort;
def path = "/SetDyNet.cgi?a=" + settings.DynetArea + "&c=" + settings.DynetChannel + "&l=" + level
def hubAction = new physicalgraph.device.HubAction(
method: "GET",
path: path,
headers: [HOST:ipaddress],
)
}
def getchannellevel(area, channel, level){
def ipaddress = settings.IPAddress + ":" + settings.IPPort;
def path = "/GetDyNet.cgi?a=" + settings.DynetArea + "&c=" + settings.DynetChannel
def hubAction = new physicalgraph.device.HubAction(
method: "GET",
path: path,
headers: [HOST:ipaddress],
)
}
def refresh() {
}