Compare commits

..

1 Commits

Author SHA1 Message Date
Rafael Pinto
fed4500f28 MSA-1465: Dual Relay Module RSM2 2016-09-05 22:55:34 -05:00
2 changed files with 135 additions and 183 deletions

View File

@@ -1,183 +0,0 @@
metadata {
definition (name: "Rooflight Controller", namespace: "CR76", author: "Cameron.Reid@Glazingvision.co.uk") {
capability "Refresh"
capability "Polling"
capability "Switch"
capability "Switch level"
attribute "Rooflight", "string"
attribute "Weather", "string"
attribute "Thermostat", "string"
command "Stop"
fingerprint profileId: "0104", inClusters: "0000,0006,0008"
}
// simulator metadata
simulator {
}
// UI tile definitions
tiles {
multiAttributeTile(name:"sliderTile", type: "generic", width:6, height:4) {
tileAttribute("device.Rooflight", key: "PRIMARY_CONTROL") {
attributeState "Open", label:'Open', action: "Switch.off", backgroundColor:"#79b821", nextState:"Closing"
attributeState "Closed", label:'Closed', action: "Switch.on", backgroundColor:"#ffffff", nextState:"Opening"
attributeState "Opening", label:'Opening', backgroundColor:"#79b821"
attributeState "Closing", label:'Closing', backgroundColor:"#ffffff"
}
tileAttribute ("device.Rooflight", key: "SECONDARY_CONTROL") {
attributeState "Open", label: 'Push to close.', nextState:"Closing"
attributeState "Closed", label: 'Push to open.', nextState:"Opening"
attributeState "Opening", label: 'Skylight opening.'
attributeState "Closing", label: 'Skylight closing.'
}
}
standardTile("Close", "device.Rooflight", inactiveLabel: false, decoration: "flat", width:2, height:2 ) {
state "default", label: 'Close', action:"Switch.off", icon:"st.thermostat.thermostat-left"
}
standardTile("Stop", "device.level", inactiveLabel: false, decoration: "flat", width:2, height:2 ) {
state "default", action:"Stop", icon:"st.sonos.stop-btn"
}
standardTile("Open", "device.Rooflight", inactiveLabel: false, decoration: "flat", width:2, height:2 ) {
state "default", label: 'open', action:"Switch.on", icon:"st.thermostat.thermostat-right"
}
standardTile("Rain", "device.Weather", width: 2, height: 2) {
state "No", backgroundColor: "#ffffff"
state "Dry", label: 'Dry', icon:"st.Weather.weather14", backgroundColor: "#ffffff"
state "Raining", label: 'Raining', icon:"st.Weather.weather10", backgroundColor: "#153591"
}
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width:2, height:2 ) {
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
}
main ("sliderTile")
details (["sliderTile","Close","Stop","Open","Rain","refresh"])
}
}
// Parse incoming device messages to generate events
def parse(String description) {
log.debug "Parse description $description"
def name = null
def value = null
if (description?.startsWith("catchall: 0104 0006 38")) {
log.debug "On/Off command received from EP 38 open / close command"
if (description?.endsWith("01 01 0000001000")) {
name = "Rooflight"
value = "Closed"
}
else if (description?.endsWith("01 01 0000001001")) {
name = "Rooflight"
value = "Open"
}
else if (description?.endsWith("01 01 0000001003")) {
name = "Rooflight"
value = "Opening"
}
else if (description?.endsWith("01 01 0000001004")) {
name = "Rooflight"
value = "Closing"
}
}
if (description?.startsWith("catchall: 0104 0006 39")) {
log.debug "On/Off command received from EP 39 is rain sensor connected"
if (description?.endsWith("01 01 0000001000")) {
name = "Weather"
value = "No"
state.tile = 1
}
else if (description?.endsWith("01 01 0000001001")) {
name = "Weather"
value = "Dry"
state.tile = 0
log.debug "${state.tile}"
}
}
if (description?.startsWith("catchall: 0104 0006 40")) {
log.debug "On/Off command received from EP 40 Thermostat"
if (description?.endsWith("01 01 0000001000")){
name = "Switch"
value = "on"
}
else if (description?.endsWith("01 01 0000001001")) {
name = "Switch"
value = "off"
}
}
if (description?.startsWith("catchall: 0104 0006 41")) {
log.debug "On/Off command received from EP 41 rain sensor"
if (description?.endsWith("01 01 0000001000")) {
name = "Weather"
value = "Dry"
}
else if (description?.endsWith("01 01 0000001001")) {
name = "Weather"
value = "Raining"
}
}
if(description?.startsWith('read attr -')) {
def descMap = parseDescriptionAsMap(description) //Get level value.
value = zigbee.convertHexToInt(descMap.value)
log.debug " level = $value"
name = "level"
}
def result = createEvent(name: name, value: value)
log.debug "Parse returned ${result?.descriptionText}"
return result
}
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() {
log.debug "Rooflight Opening"
def cmd = []
cmd <<"st cmd 0x${device.deviceNetworkId} 0x38 0x0006 0x1 {}"
cmd << "delay 250"
cmd << zigbee.command(0x0008, 0x04, "64")
}
def off() {
log.debug "Rooflight Closing"
def cmd = []
cmd << "st cmd 0x${device.deviceNetworkId} 0x38 0x0006 0x0 {}"
cmd << "delay 250"
cmd << zigbee.command(0x0008, 0x04, "00")
}
def Stop() { //Send stop command in the level control cluster.
log.debug "send stop"
"st cmd 0x${device.deviceNetworkId} 0x38 0x0008 0x07 {}"
}
def poll() {
log.debug "Poll is calling refresh"
refresh()
}
def refresh() {
log.debug "sending refresh command"
log.debug "Tile State: ${state.tile}"
def cmd = []
if("${state.tile}" == "0") { //If rain sensor is connected refresh rain sensor and rooflight position.
cmd << "st rattr 0x${device.deviceNetworkId} 0x38 0x0006 0x0000" // Read on / off attribute at End point 0x38 Rooflight open / closed.
cmd << "delay 250"
cmd << "st rattr 0x${device.deviceNetworkId} 0x38 0x0008 0x0000" // Read Level position at End point 0x38 Rooflight Position.
cmd << "delay 250"
cmd << "st rattr 0x${device.deviceNetworkId} 0x41 0x0006 0x0000" // Read on / off attribute at End point 0x41 Rain sensor.
}
else {
cmd << "st rattr 0x${device.deviceNetworkId} 0x38 0x0006 0x0000" // Read on / off attribute at End point 0x38 Rooflight open / closed.
cmd << "delay 250"
cmd << "st rattr 0x${device.deviceNetworkId} 0x38 0x0008 0x0000" // Read on / off attribute at End point 0x88 Rain sensor.
}
}

View File

@@ -0,0 +1,135 @@
metadata {
// Automatically generated. Make future change here.
definition (name: "ZWN-RSM2 Dual Relay Module", namespace: "Enerwave Home Automation", author: "Enerwave Home Automation") {
capability "Switch"
capability "Refresh"
capability "Configuration"
capability "Actuator"
command "reset"
(1..2).each { n ->
attribute "switch$n", "enum", ["on", "off"]
command "on$n"
command "off$n"
}
fingerprint deviceId: "0x1001", inClusters:
"0x25,0x27,0x70,0x72,0x86,0x60"
}
// simulator metadata
simulator {
status "on": "command: 2003, payload: FF"
status "off": "command: 2003, payload: 00"
status "switch1 on": "command: 600D, payload: 01 00 25 03 FF"
status "switch1 off": "command: 600D, payload: 01 00 25 03 00"
status "switch2 on": "command: 600D, payload: 02 00 25 03 FF"
status "switch2 off": "command: 600D, payload: 02 00 25 03 00"
// reply messages
reply "2001FF,delay 100,2502": "command: 2503, payload: FF"
reply "200100,delay 100,2502": "command: 2503, payload: 00"
}
// tile definitions
tiles {
(1..2).each { n ->
standardTile("switch$n", "switch$n", canChangeIcon: true) {
state "on", label: '${name}', action: "off$n", icon:
"st.switches.switch.on", backgroundColor: "#79b821"
state "off", label: '${name}', action: "on$n", icon:
"st.switches.switch.off", backgroundColor: "#ffffff"
}
}
standardTile("refresh", "device.switch", inactiveLabel: false,
decoration: "flat") {
state "default", label:"", action:"refresh.refresh",
icon:"st.secondary.refresh"
}
main(["switch1", "switch2"])
details(["switch1",
"switch2","refresh"])
}
}
def parse(String description) {
def result = null
if (description.startsWith("Err")) {
result = createEvent(descriptionText:description, isStateChange:true)
} else if (description != "updated") {
def cmd = zwave.parse(description, [0x60: 3, 0x25: 1, 0x20: 1])
if (cmd) {
result = zwaveEvent(cmd, null)
}
}
log.debug "parsed '${description}' to ${result.inspect()}"
result
}
def endpointEvent(endpoint, map) {
if (endpoint) {
map.name = map.name + endpoint.toString()
}
createEvent(map)
}
def
zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiChannelCmdEncap
cmd, ep) {
def encapsulatedCommand = cmd.encapsulatedCommand([0x32: 3, 0x25: 1,
0x20: 1])
if (encapsulatedCommand) {
zwaveEvent(encapsulatedCommand, cmd.sourceEndPoint as Integer)
}
}
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd, endpoint) {
def map = [name: "switch", type: "physical", value: (cmd.value ? "on" : "off")]
def events = [endpointEvent(endpoint, map)]
events
}
def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd, endpoint) {
def map = [name: "switch", value: (cmd.value ? "on" : "off")]
def events = [endpointEvent(endpoint, map)]
events
}
def zwaveEvent(physicalgraph.zwave.Command cmd, ep) {
log.debug "${device.displayName}: Unhandled ${cmd}" + (ep ? " from endpoint $ep" : "")
}
def onOffCmd(value, endpoint = null) {
[
encap(zwave.basicV1.basicSet(value: value), endpoint),
"delay 500",
encap(zwave.switchBinaryV1.switchBinaryGet(), endpoint),
]
}
def on() { onOffCmd(0xFF) }
def off() { onOffCmd(0x0) }
def on1() { onOffCmd(0xFF, 1) }
def on2() { onOffCmd(0xFF, 2) }
//def on3() { onOffCmd(0xFF, 3) }
//def on4() { onOffCmd(0xFF, 4) }
def off1() { onOffCmd(0, 1) }
def off2() { onOffCmd(0, 2) }
//def off3() { onOffCmd(0, 3) }
//def off4() { onOffCmd(0, 4) }
def refresh() {
delayBetween([
encap(zwave.basicV1.basicGet(), 1), // further gets are sent from the basic report handler
encap(zwave.basicV1.basicGet(), 2) // further gets are sent from the basic report handler
],200)
}
def resetCmd(endpoint = null) {
delayBetween([
encap(zwave.meterV2.meterReset(), endpoint),
encap(zwave.meterV2.meterGet(scale: 0), endpoint)
])
}
def reset() {
delayBetween([resetCmd(null), reset1(), reset2()])
}
def reset1() { resetCmd(1) }
def reset2() { resetCmd(2) }
//def reset3() { resetCmd(3) }
//def reset4() { resetCmd(4) }
def configure() {
}
private encap(cmd, endpoint) {
if (endpoint) {
zwave.multiChannelV3.multiChannelCmdEncap(destinationEndPoint:endpoint).
encapsulate(cmd).format()
} else {
cmd.format()
}
}