It discovers by ethernet, and when I had a v1 hub I had to use my public IP. On v2 it is the local 192.168…
Hope it works out, and do let me know any feedback, I didn’t write the handler, but did amend so any improvements can be looked at
metadata {
definition (name: "Dynalite Dimmer PS1", namespace: "smartthings", author: "Derek Wright") {
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 + "&f=" + settings.DynetFade
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 + "&f=" + settings.DynetFade
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 + "&f=" + settings.DynetFade
def hubAction = new physicalgraph.device.HubAction(
method: "GET",
path: path,
headers: [HOST:ipaddress],
)
}
def refresh() {
}