erocm123

Inovelli Bulb Multi-Color LZW42 Color Assume

Jun 11th, 2020
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.32 KB | None | 0 0
  1. /**
  2. * Inovelli Bulb Multi-Color LZW42 Color Assume
  3. * v2.2 - 2020-05-11
  4. */
  5.  
  6. import groovy.transform.Field
  7.  
  8. metadata {
  9. definition (name: "Inovelli Bulb Multi-Color LZW42", namespace: "djdizzyd", author: "Bryan Copeland", importUrl: "https://raw.githubusercontent.com/djdizzyd/hubitat/master/Drivers/inovelli/inovelli-bulb-multi-color-lzw42.groovy") {
  10. capability "SwitchLevel"
  11. capability "ColorTemperature"
  12. capability "ColorControl"
  13. capability "Switch"
  14. capability "Refresh"
  15. capability "Actuator"
  16. capability "Sensor"
  17. capability "Configuration"
  18. capability "ChangeLevel"
  19. capability "ColorMode"
  20.  
  21. attribute "colorName", "string"
  22.  
  23. fingerprint mfr:"031E", prod:"0005", deviceId:"0001", inClusters:"0x5E,0x85,0x59,0x86,0x72,0x5A,0x33,0x26,0x70,0x27,0x98,0x73,0x7A", deviceJoinName: "Inovelli Bulb Multi-Color"
  24.  
  25. }
  26. preferences {
  27. configParams.each { input it.value.input }
  28. input name: "lowBandwidth", type: "bool", description: "Enable if seeing slow response", title: "Low Bandwidth", defaultValue: false
  29. input name: "assumeColor", type: "bool", description: "Assume a the color change occurs when a color change is requested in low bandwidth mode (so the hub records the proper color state)", title: "Assume Color", defaultValue: false
  30. input name: "colorStaging", type: "bool", description: "", title: "Enable color pre-staging", defaultValue: false
  31. input name: "colorTransition", type: "number", description: "", title: "Color fade time:", defaultValue: 0
  32. input name: "dimmingSpeed", type: "number", description: "", title: "Dimming speed:", defaultValue: 1
  33. input name: "eventFilter", type: "bool", title: "Filter out duplicate events", defaultValue: false
  34. input name: "enableGammaCorrect", type: "bool", description: "May cause a slight difference in reported color", title: "Enable gamma correction on setColor", defaultValue: false
  35. input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
  36. input name: "txtEnable", type: "bool", title: "Enable descriptive logging", defaultValue: false
  37. }
  38. }
  39. @Field static Map configParams = [
  40. 2: [input: [name: "configParam2", type: "enum", title: "Power fail load state restore", description: "", defaultValue: 0, options: [0:"Bulb turns ON",1:"Bulb remembers last state"]], parameterSize: 1]
  41. ]
  42. @Field static Map CMD_CLASS_VERS=[0x33:2,0x26:2,0x86:2,0x70:1]
  43. @Field static int COLOR_TEMP_MIN=2700
  44. @Field static int COLOR_TEMP_MAX=6500
  45. @Field static int WARM_WHITE_CONFIG=0x51
  46. @Field static int COLD_WHITE_CONFIG=0x52
  47. @Field static String RED="red"
  48. @Field static String GREEN="green"
  49. @Field static String BLUE="blue"
  50. @Field static String WARM_WHITE="warmWhite"
  51. @Field static String COLD_WHITE="coldWhite"
  52. @Field static Map ZWAVE_COLOR_COMPONENT_ID=[warmWhite: 0, coldWhite: 1, red: 2, green: 3, blue: 4]
  53. @Field static List<String> RGB_NAMES=["red", "green", "blue"]
  54. @Field static List<String> WHITE_NAMES=["warmWhite", "coldWhite"]
  55. private getCOLOR_TEMP_DIFF() { COLOR_TEMP_MAX - COLOR_TEMP_MIN }
  56.  
  57. void logsOff(){
  58. log.warn "debug logging disabled..."
  59. device.updateSetting("logEnable",[value:"false",type:"bool"])
  60. }
  61.  
  62. void configure() {
  63. if (!state.initialized) initializeVars()
  64. runIn(5,pollDeviceData)
  65. }
  66.  
  67. void initializeVars() {
  68. // first run only
  69. state.colorReceived=[red: null, green: null, blue: null, warmWhite: null, coldWhite: null]
  70. state.initialized=true
  71. runIn(5, refresh)
  72. }
  73.  
  74. void updated() {
  75. log.info "updated..."
  76. log.warn "debug logging is: ${logEnable == true}"
  77. unschedule()
  78. if (logEnable) runIn(1800,logsOff)
  79. runConfigs()
  80. }
  81.  
  82. void runConfigs() {
  83. List<hubitat.zwave.Command> cmds=[]
  84. configParams.each { param, data ->
  85. if (settings[data.input.name]) {
  86. cmds.addAll(configCmd(param, data.parameterSize, settings[data.input.name]))
  87. }
  88. }
  89. cmds += setDefaultAssociation()
  90. sendToDevice(cmds)
  91. }
  92.  
  93. List<hubitat.zwave.Command> configCmd(parameterNumber, size, scaledConfigurationValue) {
  94. List<hubitat.zwave.Command> cmds = []
  95. cmds.add(zwave.configurationV1.configurationSet(parameterNumber: parameterNumber.toInteger(), size: size.toInteger(), scaledConfigurationValue: scaledConfigurationValue.toInteger()))
  96. cmds.add(zwave.configurationV1.configurationGet(parameterNumber: parameterNumber.toInteger()))
  97. return cmds
  98. }
  99.  
  100. void zwaveEvent(hubitat.zwave.commands.configurationv1.ConfigurationReport cmd) {
  101. if(configParams[cmd.parameterNumber.toInteger()]) {
  102. Map configParam=configParams[cmd.parameterNumber.toInteger()]
  103. int scaledValue
  104. cmd.configurationValue.reverse().eachWithIndex { v, index -> scaledValue=scaledValue | v << (8*index) }
  105. device.updateSetting(configParam.input.name, [value: "${scaledValue}", type: configParam.input.type])
  106. }
  107. }
  108.  
  109. void pollDeviceData() {
  110. List<hubitat.zwave.Command> cmds = []
  111. cmds.add(zwave.versionV2.versionGet())
  112. cmds.add(zwave.manufacturerSpecificV2.deviceSpecificGet(deviceIdType: 1))
  113. cmds.add(zwave.configurationV1.configurationGet(parameterNumber: 2))
  114. cmds.addAll(configCmd(51,2,1387))
  115. cmds.addAll(configCmd(52,2,6500))
  116. cmds.addAll(processAssociations())
  117. sendToDevice(cmds)
  118. }
  119.  
  120. void refresh() {
  121. List<hubitat.zwave.Command> cmds=[]
  122. cmds.add(zwave.switchMultilevelV2.switchMultilevelGet())
  123. cmds.add(zwave.basicV1.basicGet())
  124. cmds.addAll(queryAllColors())
  125. sendToDevice(cmds)
  126. }
  127.  
  128. private void refreshColor() {
  129. sendToDevice(queryAllColors())
  130. }
  131.  
  132. void installed() {
  133. if (logEnable) log.debug "installed()..."
  134. sendEvent(name: "level", value: 100, unit: "%")
  135. sendEvent(name: "colorTemperature", value: 2700)
  136. sendEvent(name: "color", value: "#000000")
  137. sendEvent(name: "hue", value: 0)
  138. sendEvent(name: "saturation", value: 0)
  139. initializeVars()
  140. }
  141.  
  142. private List<hubitat.zwave.Command> queryAllColors() {
  143. List<hubitat.zwave.Command> cmds=[]
  144. WHITE_NAMES.each { cmds.add(zwave.switchColorV2.switchColorGet(colorComponent: it, colorComponentId: ZWAVE_COLOR_COMPONENT_ID[it])) }
  145. RGB_NAMES.each { cmds.add(zwave.switchColorV2.switchColorGet(colorComponent: it, colorComponentId: ZWAVE_COLOR_COMPONENT_ID[it])) }
  146. return cmds
  147. }
  148.  
  149. void eventProcess(Map evt) {
  150. if (device.currentValue(evt.name).toString() != evt.value.toString() || !eventFilter) {
  151. if (txtEnable && evt.descriptionText) log.info evt.descriptionText
  152. evt.isStateChange=true
  153. sendEvent(evt)
  154. }
  155. }
  156.  
  157. void startLevelChange(direction) {
  158. boolean upDownVal = direction == "down" ? true : false
  159. if (logEnable) log.debug "got startLevelChange(${direction})"
  160. sendToDevice(zwave.switchMultilevelV2.switchMultilevelStartLevelChange(ignoreStartLevel: true, startLevel: device.currentValue("level"), upDown: upDownVal))
  161. }
  162.  
  163. void stopLevelChange() {
  164. sendToDevice(zwave.switchMultilevelV2.switchMultilevelStopLevelChange())
  165. }
  166.  
  167. void zwaveEvent(hubitat.zwave.commands.basicv1.BasicReport cmd) {
  168. if (logEnable) log.debug cmd
  169. dimmerEvents(cmd)
  170. }
  171.  
  172. void zwaveEvent(hubitat.zwave.commands.switchmultilevelv2.SwitchMultilevelReport cmd) {
  173. if (logEnable) log.debug cmd
  174. dimmerEvents(cmd)
  175. }
  176.  
  177. def processColors(cmd) {
  178. if (logEnable) log.debug "processColors: $cmd"
  179. if (!state.colorReceived) initializeVars()
  180. state.colorReceived[cmd.colorComponent] = cmd.value
  181. if (RGB_NAMES.every { state.colorReceived[it] != null } && state.colorMode=="RGB") {
  182. List<Integer> colors = RGB_NAMES.collect { state.colorReceived[it] }
  183. if (logEnable) log.debug "colors: $colors"
  184. // Send the color as hex format
  185. String hexColor = "#" + colors.collect { Integer.toHexString(it).padLeft(2, "0") }.join("")
  186. eventProcess(name: "color", value: hexColor)
  187. // Send the color as hue and saturation
  188. List hsv = hubitat.helper.ColorUtils.rgbToHSV(colors)
  189. eventProcess(name: "hue", value: hsv[0].round(), descriptionText: "${device.displayName} hue is ${hsv[0].round()}")
  190. eventProcess(name: "saturation", value: hsv[1].round(), descriptionText: "${device.displayName} saturation is ${hsv[1].round()}")
  191.  
  192. if ((hsv[0] > 0) && (hsv[1] > 0)) {
  193. setGenericName(hsv[0])
  194. eventProcess(name: "level", value: hsv[2].round(), descriptionText: "${device.displayName} level is ${hsv[2].round()}")
  195. }
  196. } else if (WHITE_NAMES.every { state.colorReceived[it] != null} && state.colorMode=="CT") {
  197. int warmWhite = state.colorReceived[WARM_WHITE]
  198. int coldWhite = state.colorReceived[COLD_WHITE]
  199. if (logEnable) log.debug "warmWhite: $warmWhite, coldWhite: $coldWhite"
  200. if (warmWhite == 0 && coldWhite == 0) {
  201. eventProcess(name: "colorTemperature", value: COLOR_TEMP_MIN, descriptionText: "${device.displayName} color temperature is ${COLOR_TEMP_MIN}")
  202. } else {
  203. int colorTemp = COLOR_TEMP_MIN + (COLOR_TEMP_DIFF / 2)
  204. if (warmWhite != coldWhite) {
  205. colorTemp = (COLOR_TEMP_MAX - (COLOR_TEMP_DIFF * warmWhite) / 255) as Integer
  206. }
  207. eventProcess(name: "colorTemperature", value: colorTemp, descriptionText: "${device.displayName} color temperature is ${colorTemp}")
  208. setGenericTempName(colorTemp)
  209. }
  210. }
  211. }
  212.  
  213. void zwaveEvent(hubitat.zwave.commands.switchcolorv2.SwitchColorReport cmd) {
  214. if (logEnable) log.debug "got SwitchColorReport: $cmd"
  215. processColors(cmd)
  216. }
  217.  
  218. private void dimmerEvents(hubitat.zwave.Command cmd) {
  219. def value = (cmd.value ? "on" : "off")
  220. eventProcess(name: "switch", value: value, descriptionText: "${device.displayName} was turned ${value}")
  221. if (cmd.value) {
  222. eventProcess(name: "level", value: cmd.value == 99 ? 100 : cmd.value , unit: "%", descriptionText: "${device.displayName} was set to ${cmd.value}%")
  223. }
  224. }
  225.  
  226. void on() {
  227. //Check if dimming speed exists and set the duration
  228. int duration=0
  229. if (dimmingSpeed) duration=dimmingSpeed.toInteger()
  230. sendToDevice(zwave.switchMultilevelV2.switchMultilevelSet(value: 0xFF, dimmingDuration: duration))
  231. }
  232.  
  233. void off() {
  234. //Check if dimming speed exists and set the duration
  235. int duration=0
  236. if (dimmingSpeed) duration=dimmingSpeed.toInteger()
  237. sendToDevice(zwave.switchMultilevelV2.switchMultilevelSet(value: 0x00, dimmingDuration: duration))
  238. }
  239.  
  240. void setLevel(level) {
  241. //Check if dimming speed exists and set the duration
  242. int duration=1
  243. if (dimmingSpeed) duration=dimmingSpeed.toInteger()
  244. setLevel(level, duration)
  245. }
  246.  
  247. void setLevel(level, duration) {
  248. if (logEnable) log.debug "setLevel($level, $duration)"
  249. if(level > 99) level = 99
  250. sendToDevice(zwave.switchMultilevelV2.switchMultilevelSet(value: level, dimmingDuration: duration))
  251. }
  252.  
  253. void setSaturation(percent) {
  254. if (logEnable) log.debug "setSaturation($percent)"
  255. setColor([saturation: percent, hue: device.currentValue("hue"), level: device.currentValue("level")])
  256. }
  257.  
  258. void setHue(value) {
  259. if (logEnable) log.debug "setHue($value)"
  260. setColor([hue: value, saturation: 100, level: device.currentValue("level")])
  261. }
  262.  
  263. void setColor(value) {
  264. if (value.hue == null || value.saturation == null) return
  265. if (value.level == null) value.level=100
  266. if (logEnable) log.debug "setColor($value)"
  267. state.colorMode="RGB"
  268. eventProcess(name: "colorMode", value: "RGB", descriptionText: "${device.getDisplayName()} color mode is RGB")
  269. int dimmingDuration=0
  270. if (colorTransition) dimmingDuration=colorTransition
  271. List<hubitat.zwave.Command> cmds = []
  272. List rgb = hubitat.helper.ColorUtils.hsvToRGB([value.hue, value.saturation, value.level])
  273. log.debug "r:" + rgb[0] + ", g: " + rgb[1] +", b: " + rgb[2]
  274. if (enableGammaCorrect) {
  275. cmds.add(zwave.switchColorV3.switchColorSet(red: gammaCorrect(rgb[0]), green: gammaCorrect(rgb[1]), blue: gammaCorrect(rgb[2]), warmWhite: 0, coldWhite: 0, dimmingDuration: dimmingDuration))
  276. if (assumeColor) {
  277. processColors([colorComponent:"warmWhite", colorComponentId:0, value:0])
  278. processColors([colorComponent:"coldWhite", colorComponentId:1, value:0])
  279. processColors([colorComponent:"red", colorComponentId:2, value:gammaCorrect(rgb[0])])
  280. processColors([colorComponent:"green", colorComponentId:3, value:gammaCorrect(rgb[1])])
  281. processColors([colorComponent:"blue", colorComponentId:4, value:gammaCorrect(rgb[2])])
  282. }
  283. } else {
  284. cmds.add(zwave.switchColorV2.switchColorSet(red: rgb[0], green: rgb[1], blue: rgb[2], warmWhite: 0, coldWhite: 0, dimmingDuration: dimmingDuration))
  285. if (assumeColor) {
  286. processColors([colorComponent:"warmWhite", colorComponentId:0, value:0])
  287. processColors([colorComponent:"coldWhite", colorComponentId:1, value:0])
  288. processColors([colorComponent:"red", colorComponentId:2, value:rgb[0]])
  289. processColors([colorComponent:"green", colorComponentId:3, value:rgb[1]])
  290. processColors([colorComponent:"blue", colorComponentId:4, value:rgb[2]])
  291. }
  292. }
  293. if ((device.currentValue("switch") != "on") && (!colorStaging)){
  294. if (logEnable) log.debug "Bulb is off. Turning on"
  295. cmds.add(zwave.basicV1.basicSet(value: 0xFF))
  296. }
  297. sendToDevice(cmds)
  298. if (colorTransition>0 && !lowBandwidth) runIn(dimmingDuration, "refreshColor")
  299. }
  300.  
  301. void setColorTemperature(temp) {
  302. if (logEnable) log.debug "setColorTemperature($temp)"
  303. state.colorMode="CT"
  304. eventProcess(name: "colorMode", value: "CT", descriptionText: "${device.getDisplayName()} color mode is CT")
  305. int dimmingDuration=0
  306. if (colorTransition) dimmingDuration=colorTransition
  307. List<hubitat.zwave.Command> cmds = []
  308. if (temp < COLOR_TEMP_MIN) temp = COLOR_TEMP_MIN
  309. if (temp > COLOR_TEMP_MAX) temp = COLOR_TEMP_MAX
  310. int warmValue = ((COLOR_TEMP_MAX - temp) / COLOR_TEMP_DIFF * 255) as Integer
  311. int coldValue = 255 - warmValue
  312. cmds.add(zwave.switchColorV2.switchColorSet(warmWhite: warmValue, coldWhite: coldValue, dimmingDuration: dimmingDuration))
  313. if (assumeColor) {
  314. processColors([colorComponent:"warmWhite", colorComponentId:0, value:warmValue])
  315. processColors([colorComponent:"coldWhite", colorComponentId:1, value:coldValue])
  316. processColors([colorComponent:"red", colorComponentId:2, value:0])
  317. processColors([colorComponent:"green", colorComponentId:3, value:0])
  318. processColors([colorComponent:"blue", colorComponentId:4, value:0])
  319. }
  320. if ((device.currentValue("switch") != "on") && (!colorStaging)) {
  321. if (logEnable) log.debug "Bulb is off. Turning on"
  322. cmds.add(zwave.basicV1.basicSet(value: 0xFF))
  323. }
  324. sendToDevice(cmds)
  325. if (colorTransition>0 && !lowBandwidth) runIn(dimmingDuration, "refreshColor")
  326. }
  327.  
  328. private void setGenericTempName(temp){
  329. if (!temp) return
  330. String genericName
  331. int value = temp.toInteger()
  332. if (value <= 2000) genericName = "Sodium"
  333. else if (value <= 2100) genericName = "Starlight"
  334. else if (value < 2400) genericName = "Sunrise"
  335. else if (value < 2800) genericName = "Incandescent"
  336. else if (value < 3300) genericName = "Soft White"
  337. else if (value < 3500) genericName = "Warm White"
  338. else if (value < 4150) genericName = "Moonlight"
  339. else if (value <= 5000) genericName = "Horizon"
  340. else if (value < 5500) genericName = "Daylight"
  341. else if (value < 6000) genericName = "Electronic"
  342. else if (value <= 6500) genericName = "Skylight"
  343. else if (value < 20000) genericName = "Polar"
  344. String descriptionText = "${device.getDisplayName()} color is ${genericName}"
  345. eventProcess(name: "colorName", value: genericName ,descriptionText: descriptionText)
  346. }
  347.  
  348. private void setGenericName(hue){
  349. String colorName
  350. hue = hue.toInteger()
  351. hue = (hue * 3.6)
  352. switch (hue.toInteger()){
  353. case 0..15: colorName = "Red"
  354. break
  355. case 16..45: colorName = "Orange"
  356. break
  357. case 46..75: colorName = "Yellow"
  358. break
  359. case 76..105: colorName = "Chartreuse"
  360. break
  361. case 106..135: colorName = "Green"
  362. break
  363. case 136..165: colorName = "Spring"
  364. break
  365. case 166..195: colorName = "Cyan"
  366. break
  367. case 196..225: colorName = "Azure"
  368. break
  369. case 226..255: colorName = "Blue"
  370. break
  371. case 256..285: colorName = "Violet"
  372. break
  373. case 286..315: colorName = "Magenta"
  374. break
  375. case 316..345: colorName = "Rose"
  376. break
  377. case 346..360: colorName = "Red"
  378. break
  379. }
  380. String descriptionText = "${device.getDisplayName()} color is ${colorName}"
  381. eventProcess(name: "colorName", value: colorName ,descriptionText: descriptionText)
  382. }
  383.  
  384. void zwaveEvent(hubitat.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {
  385. hubitat.zwave.Command encapsulatedCommand = cmd.encapsulatedCommand(CMD_CLASS_VERS)
  386. if (encapsulatedCommand) {
  387. zwaveEvent(encapsulatedCommand)
  388. }
  389. }
  390.  
  391. void parse(String description) {
  392. if (logEnable) log.debug "parse:${description}"
  393. hubitat.zwave.Command cmd = zwave.parse(description, CMD_CLASS_VERS)
  394. if (cmd) {
  395. zwaveEvent(cmd)
  396. }
  397. }
  398.  
  399. void zwaveEvent(hubitat.zwave.commands.supervisionv1.SupervisionGet cmd) {
  400. if (logEnable) log.debug "Supervision get: ${cmd}"
  401. hubitat.zwave.Command encapsulatedCommand = cmd.encapsulatedCommand(CMD_CLASS_VERS)
  402. if (encapsulatedCommand) {
  403. zwaveEvent(encapsulatedCommand)
  404. }
  405. sendToDevice(new hubitat.zwave.commands.supervisionv1.SupervisionReport(sessionID: cmd.sessionID, reserved: 0, moreStatusUpdates: false, status: 0xFF, duration: 0))
  406. }
  407.  
  408. void zwaveEvent(hubitat.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {
  409. if (logEnable) log.debug "Device Specific Report: ${cmd}"
  410. switch (cmd.deviceIdType) {
  411. case 1:
  412. // serial number
  413. def serialNumber=""
  414. if (cmd.deviceIdDataFormat==1) {
  415. cmd.deviceIdData.each { serialNumber += hubitat.helper.HexUtils.integerToHexString(it & 0xff,1).padLeft(2, '0')}
  416. } else {
  417. cmd.deviceIdData.each { serialNumber += (char) it }
  418. }
  419. device.updateDataValue("serialNumber", serialNumber)
  420. break
  421. }
  422. }
  423.  
  424. void zwaveEvent(hubitat.zwave.commands.versionv2.VersionReport cmd) {
  425. if (logEnable) log.debug "version3 report: ${cmd}"
  426. device.updateDataValue("firmwareVersion", "${cmd.firmware0Version}.${cmd.firmware0SubVersion}")
  427. device.updateDataValue("protocolVersion", "${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}")
  428. device.updateDataValue("hardwareVersion", "${cmd.hardwareVersion}")
  429. }
  430.  
  431. void sendToDevice(List<hubitat.zwave.Command> cmds) {
  432. sendHubCommand(new hubitat.device.HubMultiAction(commands(cmds), hubitat.device.Protocol.ZWAVE))
  433. }
  434.  
  435. void sendToDevice(hubitat.zwave.Command cmd) {
  436. sendHubCommand(new hubitat.device.HubAction(secureCommand(cmd), hubitat.device.Protocol.ZWAVE))
  437. }
  438.  
  439. void sendToDevice(String cmd) {
  440. sendHubCommand(new hubitat.device.HubAction(secureCommand(cmd), hubitat.device.Protocol.ZWAVE))
  441. }
  442.  
  443. List<String> commands(List<hubitat.zwave.Command> cmds, Long delay=200) {
  444. return delayBetween(cmds.collect{ secureCommand(it) }, delay)
  445. }
  446.  
  447. String secureCommand(hubitat.zwave.Command cmd) {
  448. secureCommand(cmd.format())
  449. }
  450.  
  451. String secureCommand(String cmd) {
  452. String encap=""
  453. if (getDataValue("zwaveSecurePairingComplete") != "true") {
  454. return cmd
  455. } else {
  456. encap = "988100"
  457. }
  458. return "${encap}${cmd}"
  459. }
  460.  
  461. void zwaveEvent(hubitat.zwave.Command cmd) {
  462. if (logEnable) log.debug "skip:${cmd}"
  463. }
  464.  
  465. List<hubitat.zwave.Command> setDefaultAssociation() {
  466. List<hubitat.zwave.Command> cmds=[]
  467. cmds.add(zwave.associationV2.associationSet(groupingIdentifier: 1, nodeId: zwaveHubNodeId))
  468. cmds.add(zwave.associationV2.associationGet(groupingIdentifier: 1))
  469. return cmds
  470. }
  471.  
  472. List<hubitat.zwave.Command> processAssociations(){
  473. List<hubitat.zwave.Command> cmds = []
  474. cmds.addAll(setDefaultAssociation())
  475. return cmds
  476. }
  477.  
  478. void zwaveEvent(hubitat.zwave.commands.associationv2.AssociationReport cmd) {
  479. if (logEnable) log.debug "${device.label?device.label:device.name}: ${cmd}"
  480. List<String> temp = []
  481. if (cmd.nodeId != []) {
  482. cmd.nodeId.each {
  483. temp.add(it.toString().format( '%02x', it.toInteger() ).toUpperCase())
  484. }
  485. }
  486. updateDataValue("zwaveAssociationG${cmd.groupingIdentifier}", "$temp")
  487. }
  488.  
  489. void zwaveEvent(hubitat.zwave.commands.associationv2.AssociationGroupingsReport cmd) {
  490. if (logEnable) log.debug "${device.label?device.label:device.name}: ${cmd}"
  491. log.info "${device.label?device.label:device.name}: Supported association groups: ${cmd.supportedGroupings}"
  492. state.associationGroups = cmd.supportedGroupings
  493. }
  494.  
  495. private int gammaCorrect(value) {
  496. def temp=value/255
  497. def correctedValue=(temp>0.4045) ? Math.pow((temp+0.055)/ 1.055, 2.4) : (temp / 12.92)
  498. return Math.round(correctedValue * 255) as Integer
  499. }
Add Comment
Please, Sign In to add comment