erocm123

LZW42 Alternate Plus LZW42

Jun 10th, 2020
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.55 KB | None | 0 0
  1. /**
  2. * Copyright 2019 Inovelli / Eric Maycock
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  5. * in compliance with the License. You may obtain a copy of the License at:
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  10. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing permissions and limitations under the License.
  12. *
  13. * Inovelli Bulb Multi-Color LZW42
  14. *
  15. * Author: Eric Maycock
  16. * Date: 2019-9-9
  17. * updated by bcopeland 1/7/2020
  18. * Added color pre-staging option
  19. * Added power restored memory configuration
  20. * Added debug logging configuration
  21. * Fixed color setting
  22. * Fixed color temperature setting
  23. * Fixed reporting
  24. * Removed SmartThings related code
  25. * Added importURL
  26. * Added color name
  27. * updated by bcopeland 1/9/2020
  28. * added firmware version reporting
  29. * fix for scene capture and level in setcolor
  30. * updated by bcopeland 1/10/2020
  31. * fix for hsl level from received color report
  32. * updated by bcopeland 1/21/2020
  33. * fixes for reported bugs
  34. * correct comand class versions to match what the hardware supports
  35. * add z-wave color component ids manually as it didnt seem to match in correct command class version from he
  36. * updated by bcopeland 2/6/2020
  37. * added ChangeLevel capability and relevant commands
  38. * updated by bcopeland 2/15/2020
  39. * dramatically improved speed of CT operations and reduced packet count - Make sure to hit configure after updating.
  40. * improved speed of on/off events also reducing packets
  41. * improved speed of setLevel events also reducing packets
  42. * bug fix for null value in setColor
  43. * updated by bcopeland 3/11/2020
  44. * improved speed / reduced packets on CT set operations
  45. * added color fade time preference for smoother CT transitions
  46. * update by bcopeland 4/9/2020
  47. * major re-write for new coding standards / cleanup
  48. * stabilization of color temp and color reporting
  49. * re-organization of device data for standardization / addition of serialnumber, hardware ver, protocol ver, firmware
  50. * re-work of associations
  51. * updated by npk22 4/9/2020
  52. * added dimming speed parameter
  53. * added dimming speed to on / off
  54. * updated by bcopeland 4/11/2020
  55. * fixed type definitions
  56. * fixed fingerprint
  57. * updated by bcopeland 4/12/2020
  58. * added duplicate event filtering (optional as it has a slight possibility of causing issues with voice assistants)
  59. * changed dimming speed default to 1 to match previous default functionality
  60. * updated by InovelliUSA 4/15/2020
  61. * corrected incorrect options for parameter 2
  62. * updated by bcopeland 4/15/2020
  63. * fixed bug in CT report
  64. * added gamma correction as an optional setting
  65. * updated by bcopeland 4/16/2020
  66. * updated ambiguous language
  67. *
  68. */
  69.  
  70. import groovy.transform.Field
  71.  
  72. metadata {
  73. definition (name: "Inovelli Bulb Multi-Color LZW42 Plus GP1", namespace: "InovelliUSA", author: "InovelliUSA", importUrl: "https://raw.githubusercontent.com/InovelliUSA/Hubitat/master/Drivers/inovelli-bulb-multi-color-lzw42.src/inovelli-bulb-multi-color-lzw42.groovy") {
  74. capability "SwitchLevel"
  75. capability "ColorTemperature"
  76. capability "ColorControl"
  77. capability "Switch"
  78. capability "Refresh"
  79. capability "Actuator"
  80. capability "Sensor"
  81. capability "Configuration"
  82. capability "ChangeLevel"
  83. capability "ColorMode"
  84.  
  85. attribute "colorName", "string"
  86.  
  87. 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"
  88.  
  89. }
  90. preferences {
  91. configParams.each { input it.value.input }
  92. input name: "colorStaging", type: "bool", description: "", title: "Enable color pre-staging", defaultValue: false
  93. input name: "colorTransition", type: "number", description: "", title: "Color fade time:", defaultValue: 0
  94. input name: "dimmingSpeed", type: "number", description: "", title: "Dimming speed:", defaultValue: 1
  95. input name: "eventFilter", type: "bool", title: "Filter out duplicate events", defaultValue: false
  96. input name: "enableGammaCorrect", type: "bool", description: "May cause a slight difference in reported color", title: "Enable gamma correction on setColor", defaultValue: false
  97. input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
  98. }
  99. }
  100. @Field static Map configParams = [
  101. 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]
  102. ]
  103. @Field static Map CMD_CLASS_VERS=[0x33:2,0x26:2,0x86:2,0x70:1]
  104. @Field static int COLOR_TEMP_MIN=2700
  105. @Field static int COLOR_TEMP_MAX=6500
  106. @Field static int WARM_WHITE_CONFIG=0x51
  107. @Field static int COLD_WHITE_CONFIG=0x52
  108. @Field static String RED="red"
  109. @Field static String GREEN="green"
  110. @Field static String BLUE="blue"
  111. @Field static String WARM_WHITE="warmWhite"
  112. @Field static String COLD_WHITE="coldWhite"
  113. @Field static Map ZWAVE_COLOR_COMPONENT_ID=[warmWhite: 0, coldWhite: 1, red: 2, green: 3, blue: 4]
  114. @Field static List<String> RGB_NAMES=["red", "green", "blue"]
  115. @Field static List<String> WHITE_NAMES=["warmWhite", "coldWhite"]
  116. private getCOLOR_TEMP_DIFF() { COLOR_TEMP_MAX - COLOR_TEMP_MIN }
  117.  
  118. void logsOff(){
  119. log.warn "debug logging disabled..."
  120. device.updateSetting("logEnable",[value:"false",type:"bool"])
  121. }
  122.  
  123. void configure() {
  124. if (!state.initialized) initializeVars()
  125. runIn(5,pollDeviceData)
  126. }
  127.  
  128. void initializeVars() {
  129. // first run only
  130. state.colorReceived=[red: null, green: null, blue: null, warmWhite: null, coldWhite: null]
  131. state.initialized=true
  132. runIn(5, refresh)
  133. }
  134.  
  135. void updated() {
  136. log.info "updated..."
  137. log.warn "debug logging is: ${logEnable == true}"
  138. unschedule()
  139. if (logEnable) runIn(1800,logsOff)
  140. runConfigs()
  141. sendToDevice([zwave.associationV2.associationRemove(groupingIdentifier: 1, nodeId: zwaveHubNodeId),
  142. zwave.associationV2.associationGet(groupingIdentifier: 1)])
  143. }
  144.  
  145. void runConfigs() {
  146. List<hubitat.zwave.Command> cmds=[]
  147. configParams.each { param, data ->
  148. if (settings[data.input.name]) {
  149. cmds.addAll(configCmd(param, data.parameterSize, settings[data.input.name]))
  150. }
  151. }
  152. sendToDevice(cmds)
  153. }
  154.  
  155. List<hubitat.zwave.Command> configCmd(parameterNumber, size, scaledConfigurationValue) {
  156. List<hubitat.zwave.Command> cmds = []
  157. cmds.add(zwave.configurationV1.configurationSet(parameterNumber: parameterNumber.toInteger(), size: size.toInteger(), scaledConfigurationValue: scaledConfigurationValue.toInteger()))
  158. cmds.add(zwave.configurationV1.configurationGet(parameterNumber: parameterNumber.toInteger()))
  159. return cmds
  160. }
  161.  
  162. void zwaveEvent(hubitat.zwave.commands.configurationv1.ConfigurationReport cmd) {
  163. if(configParams[cmd.parameterNumber.toInteger()]) {
  164. Map configParam=configParams[cmd.parameterNumber.toInteger()]
  165. int scaledValue
  166. cmd.configurationValue.reverse().eachWithIndex { v, index -> scaledValue=scaledValue | v << (8*index) }
  167. device.updateSetting(configParam.input.name, [value: "${scaledValue}", type: configParam.input.type])
  168. }
  169. }
  170.  
  171. void pollDeviceData() {
  172. List<hubitat.zwave.Command> cmds = []
  173. cmds.add(zwave.versionV2.versionGet())
  174. cmds.add(zwave.manufacturerSpecificV2.deviceSpecificGet(deviceIdType: 1))
  175. cmds.add(zwave.configurationV1.configurationGet(parameterNumber: 2))
  176. cmds.addAll(configCmd(51,2,1387))
  177. cmds.addAll(configCmd(52,2,6500))
  178. cmds.addAll(processAssociations())
  179. sendToDevice(cmds)
  180. }
  181.  
  182. void refresh() {
  183. List<hubitat.zwave.Command> cmds=[]
  184. cmds.add(zwave.switchMultilevelV2.switchMultilevelGet())
  185. cmds.add(zwave.basicV1.basicGet())
  186. cmds.addAll(queryAllColors())
  187. sendToDevice(cmds)
  188. }
  189.  
  190. private void refreshColor() {
  191. sendToDevice(queryAllColors())
  192. }
  193.  
  194. void installed() {
  195. if (logEnable) log.debug "installed()..."
  196. sendEvent(name: "level", value: 100, unit: "%")
  197. sendEvent(name: "colorTemperature", value: 2700)
  198. sendEvent(name: "color", value: "#000000")
  199. sendEvent(name: "hue", value: 0)
  200. sendEvent(name: "saturation", value: 0)
  201. initializeVars()
  202. }
  203.  
  204. private List<hubitat.zwave.Command> queryAllColors() {
  205. List<hubitat.zwave.Command> cmds=[]
  206. WHITE_NAMES.each { cmds.add(zwave.switchColorV2.switchColorGet(colorComponent: it, colorComponentId: ZWAVE_COLOR_COMPONENT_ID[it])) }
  207. RGB_NAMES.each { cmds.add(zwave.switchColorV2.switchColorGet(colorComponent: it, colorComponentId: ZWAVE_COLOR_COMPONENT_ID[it])) }
  208. cmds.add(zwave.switchMultilevelV1.switchMultilevelGet())
  209. return cmds
  210. }
  211.  
  212. void eventProcess(Map evt) {
  213. if (device.currentValue(evt.name).toString() != evt.value.toString() || !eventFilter) {
  214. evt.isStateChange=true
  215. sendEvent(evt)
  216. }
  217. }
  218.  
  219. void startLevelChange(direction) {
  220. boolean upDownVal = direction == "down" ? true : false
  221. if (logEnable) log.debug "got startLevelChange(${direction})"
  222. sendToDevice(zwave.switchMultilevelV2.switchMultilevelStartLevelChange(ignoreStartLevel: true, startLevel: device.currentValue("level"), upDown: upDownVal))
  223. }
  224.  
  225. void stopLevelChange() {
  226. sendToDevice(zwave.switchMultilevelV2.switchMultilevelStopLevelChange())
  227. }
  228.  
  229. void zwaveEvent(hubitat.zwave.commands.basicv1.BasicReport cmd) {
  230. if (logEnable) log.debug cmd
  231. dimmerEvents(cmd)
  232. }
  233.  
  234. void zwaveEvent(hubitat.zwave.commands.switchmultilevelv2.SwitchMultilevelReport cmd) {
  235. if (logEnable) log.debug cmd
  236. dimmerEvents(cmd)
  237. }
  238.  
  239. void zwaveEvent(hubitat.zwave.commands.switchcolorv2.SwitchColorReport cmd) {
  240. if (logEnable) log.debug "got SwitchColorReport: $cmd"
  241. if (!state.colorReceived) initializeVars()
  242. state.colorReceived[cmd.colorComponent] = cmd.value
  243. if (RGB_NAMES.every { state.colorReceived[it] != null } && device.currentValue("colorMode")=="RGB") {
  244. List<Integer> colors = RGB_NAMES.collect { state.colorReceived[it] }
  245. if (logEnable) log.debug "colors: $colors"
  246. // Send the color as hex format
  247. String hexColor = "#" + colors.collect { Integer.toHexString(it).padLeft(2, "0") }.join("")
  248. eventProcess(name: "color", value: hexColor)
  249. // Send the color as hue and saturation
  250. List hsv = hubitat.helper.ColorUtils.rgbToHSV(colors)
  251. eventProcess(name: "hue", value: hsv[0].round())
  252. eventProcess(name: "saturation", value: hsv[1].round())
  253.  
  254. if ((hsv[0] > 0) && (hsv[1] > 0)) {
  255. setGenericName(hsv[0])
  256. eventProcess(name: "level", value: hsv[2].round())
  257. }
  258. } else if (WHITE_NAMES.every { state.colorReceived[it] != null} && device.currentValue("colorMode")=="CT") {
  259. int warmWhite = state.colorReceived[WARM_WHITE]
  260. int coldWhite = state.colorReceived[COLD_WHITE]
  261. if (logEnable) log.debug "warmWhite: $warmWhite, coldWhite: $coldWhite"
  262. if (warmWhite == 0 && coldWhite == 0) {
  263. eventProcess(name: "colorTemperature", value: COLOR_TEMP_MIN)
  264. } else {
  265. int colorTemp = COLOR_TEMP_MIN + (COLOR_TEMP_DIFF / 2)
  266. if (warmWhite != coldWhite) {
  267. colorTemp = (COLOR_TEMP_MAX - (COLOR_TEMP_DIFF * warmWhite) / 255) as Integer
  268. }
  269. eventProcess(name: "colorTemperature", value: colorTemp)
  270. setGenericTempName(colorTemp)
  271. }
  272. }
  273. }
  274.  
  275. private void dimmerEvents(hubitat.zwave.Command cmd) {
  276. def value = (cmd.value ? "on" : "off")
  277. eventProcess(name: "switch", value: value, descriptionText: "$device.displayName was turned $value")
  278. if (cmd.value) {
  279. eventProcess(name: "level", value: cmd.value == 99 ? 100 : cmd.value , unit: "%")
  280. }
  281. }
  282.  
  283. void on() {
  284. //Check if dimming speed exists and set the duration
  285. int duration=0
  286. if (dimmingSpeed) duration=dimmingSpeed.toInteger()
  287. sendToDevice(zwave.switchMultilevelV2.switchMultilevelSet(value: 0xFF, dimmingDuration: duration))
  288. }
  289.  
  290. void off() {
  291. //Check if dimming speed exists and set the duration
  292. int duration=0
  293. if (dimmingSpeed) duration=dimmingSpeed.toInteger()
  294. sendToDevice(zwave.switchMultilevelV2.switchMultilevelSet(value: 0x00, dimmingDuration: duration))
  295. }
  296.  
  297. void setLevel(level) {
  298. //Check if dimming speed exists and set the duration
  299. int duration=1
  300. if (dimmingSpeed) duration=dimmingSpeed.toInteger()
  301. setLevel(level, duration)
  302. }
  303.  
  304. void setLevel(level, duration) {
  305. if (logEnable) log.debug "setLevel($level, $duration)"
  306. if(level > 99) level = 99
  307. sendToDevice(zwave.switchMultilevelV2.switchMultilevelSet(value: level, dimmingDuration: duration))
  308. }
  309.  
  310. void setSaturation(percent) {
  311. if (logEnable) log.debug "setSaturation($percent)"
  312. setColor([saturation: percent, hue: device.currentValue("hue"), level: device.currentValue("level")])
  313. }
  314.  
  315. void setHue(value) {
  316. if (logEnable) log.debug "setHue($value)"
  317. setColor([hue: value, saturation: 100, level: device.currentValue("level")])
  318. }
  319.  
  320. void setColor(value) {
  321. if (value.hue == null || value.saturation == null) return
  322. if (value.level == null) value.level=100
  323. if (logEnable) log.debug "setColor($value)"
  324. int dimmingDuration=0
  325. if (colorTransition) dimmingDuration=colorTransition
  326. List<hubitat.zwave.Command> cmds = []
  327. List rgb = hubitat.helper.ColorUtils.hsvToRGB([value.hue, value.saturation, value.level])
  328. log.debug "r:" + rgb[0] + ", g: " + rgb[1] +", b: " + rgb[2]
  329. if (enableGammaCorrect) {
  330. cmds.add(zwave.switchColorV3.switchColorSet(red: gammaCorrect(rgb[0]), green: gammaCorrect(rgb[1]), blue: gammaCorrect(rgb[2]), warmWhite: 0, coldWhite: 0, dimmingDuration: dimmingDuration))
  331. } else {
  332. cmds.add(zwave.switchColorV2.switchColorSet(red: rgb[0], green: rgb[1], blue: rgb[2], warmWhite: 0, coldWhite: 0, dimmingDuration: dimmingDuration))
  333. }
  334. if ((device.currentValue("switch") != "on") && (!colorStaging)){
  335. if (logEnable) log.debug "Bulb is off. Turning on"
  336. cmds.add(zwave.basicV1.basicSet(value: 0xFF))
  337. }
  338. sendToDevice(cmds)
  339. eventProcess(name: "colorMode", value: "RGB", descriptionText: "${device.getDisplayName()} color mode is RGB")
  340. runIn(5, "refreshColor")
  341. }
  342.  
  343. void setColorTemperature(temp) {
  344. if (logEnable) log.debug "setColorTemperature($temp)"
  345. int dimmingDuration=0
  346. if (colorTransition) dimmingDuration=colorTransition
  347. List<hubitat.zwave.Command> cmds = []
  348. if (temp < COLOR_TEMP_MIN) temp = COLOR_TEMP_MIN
  349. if (temp > COLOR_TEMP_MAX) temp = COLOR_TEMP_MAX
  350. int warmValue = ((COLOR_TEMP_MAX - temp) / COLOR_TEMP_DIFF * 255) as Integer
  351. int coldValue = 255 - warmValue
  352. cmds.add(zwave.switchColorV2.switchColorSet(warmWhite: warmValue, coldWhite: coldValue, dimmingDuration: dimmingDuration))
  353. if ((device.currentValue("switch") != "on") && (!colorStaging)) {
  354. if (logEnable) log.debug "Bulb is off. Turning on"
  355. cmds.add(zwave.basicV1.basicSet(value: 0xFF))
  356. }
  357. sendToDevice(cmds)
  358. eventProcess(name: "colorMode", value: "CT", descriptionText: "${device.getDisplayName()} color mode is CT")
  359. runIn(5, "refreshColor")
  360. }
  361.  
  362. private void setGenericTempName(temp){
  363. if (!temp) return
  364. String genericName
  365. int value = temp.toInteger()
  366. if (value <= 2000) genericName = "Sodium"
  367. else if (value <= 2100) genericName = "Starlight"
  368. else if (value < 2400) genericName = "Sunrise"
  369. else if (value < 2800) genericName = "Incandescent"
  370. else if (value < 3300) genericName = "Soft White"
  371. else if (value < 3500) genericName = "Warm White"
  372. else if (value < 4150) genericName = "Moonlight"
  373. else if (value <= 5000) genericName = "Horizon"
  374. else if (value < 5500) genericName = "Daylight"
  375. else if (value < 6000) genericName = "Electronic"
  376. else if (value <= 6500) genericName = "Skylight"
  377. else if (value < 20000) genericName = "Polar"
  378. String descriptionText = "${device.getDisplayName()} color is ${genericName}"
  379. eventProcess(name: "colorName", value: genericName ,descriptionText: descriptionText)
  380. }
  381.  
  382. private void setGenericName(hue){
  383. String colorName
  384. hue = hue.toInteger()
  385. hue = (hue * 3.6)
  386. switch (hue.toInteger()){
  387. case 0..15: colorName = "Red"
  388. break
  389. case 16..45: colorName = "Orange"
  390. break
  391. case 46..75: colorName = "Yellow"
  392. break
  393. case 76..105: colorName = "Chartreuse"
  394. break
  395. case 106..135: colorName = "Green"
  396. break
  397. case 136..165: colorName = "Spring"
  398. break
  399. case 166..195: colorName = "Cyan"
  400. break
  401. case 196..225: colorName = "Azure"
  402. break
  403. case 226..255: colorName = "Blue"
  404. break
  405. case 256..285: colorName = "Violet"
  406. break
  407. case 286..315: colorName = "Magenta"
  408. break
  409. case 316..345: colorName = "Rose"
  410. break
  411. case 346..360: colorName = "Red"
  412. break
  413. }
  414. String descriptionText = "${device.getDisplayName()} color is ${colorName}"
  415. eventProcess(name: "colorName", value: colorName ,descriptionText: descriptionText)
  416. }
  417.  
  418. void zwaveEvent(hubitat.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {
  419. hubitat.zwave.Command encapsulatedCommand = cmd.encapsulatedCommand(CMD_CLASS_VERS)
  420. if (encapsulatedCommand) {
  421. zwaveEvent(encapsulatedCommand)
  422. }
  423. }
  424.  
  425. void parse(String description) {
  426. if (logEnable) log.debug "parse:${description}"
  427. hubitat.zwave.Command cmd = zwave.parse(description, CMD_CLASS_VERS)
  428. if (cmd) {
  429. zwaveEvent(cmd)
  430. }
  431. }
  432.  
  433. void zwaveEvent(hubitat.zwave.commands.supervisionv1.SupervisionGet cmd) {
  434. if (logEnable) log.debug "Supervision get: ${cmd}"
  435. hubitat.zwave.Command encapsulatedCommand = cmd.encapsulatedCommand(CMD_CLASS_VERS)
  436. if (encapsulatedCommand) {
  437. zwaveEvent(encapsulatedCommand)
  438. }
  439. sendToDevice(new hubitat.zwave.commands.supervisionv1.SupervisionReport(sessionID: cmd.sessionID, reserved: 0, moreStatusUpdates: false, status: 0xFF, duration: 0))
  440. }
  441.  
  442. void zwaveEvent(hubitat.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {
  443. if (logEnable) log.debug "Device Specific Report: ${cmd}"
  444. switch (cmd.deviceIdType) {
  445. case 1:
  446. // serial number
  447. def serialNumber=""
  448. if (cmd.deviceIdDataFormat==1) {
  449. cmd.deviceIdData.each { serialNumber += hubitat.helper.HexUtils.integerToHexString(it & 0xff,1).padLeft(2, '0')}
  450. } else {
  451. cmd.deviceIdData.each { serialNumber += (char) it }
  452. }
  453. device.updateDataValue("serialNumber", serialNumber)
  454. break
  455. }
  456. }
  457.  
  458. void zwaveEvent(hubitat.zwave.commands.versionv2.VersionReport cmd) {
  459. if (logEnable) log.debug "version3 report: ${cmd}"
  460. device.updateDataValue("firmwareVersion", "${cmd.firmware0Version}.${cmd.firmware0SubVersion}")
  461. device.updateDataValue("protocolVersion", "${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}")
  462. device.updateDataValue("hardwareVersion", "${cmd.hardwareVersion}")
  463. }
  464.  
  465. void sendToDevice(List<hubitat.zwave.Command> cmds) {
  466. sendHubCommand(new hubitat.device.HubMultiAction(commands(cmds), hubitat.device.Protocol.ZWAVE))
  467. }
  468.  
  469. void sendToDevice(hubitat.zwave.Command cmd) {
  470. sendHubCommand(new hubitat.device.HubAction(secureCommand(cmd), hubitat.device.Protocol.ZWAVE))
  471. }
  472.  
  473. void sendToDevice(String cmd) {
  474. sendHubCommand(new hubitat.device.HubAction(secureCommand(cmd), hubitat.device.Protocol.ZWAVE))
  475. }
  476.  
  477. List<String> commands(List<hubitat.zwave.Command> cmds, Long delay=200) {
  478. return delayBetween(cmds.collect{ secureCommand(it) }, delay)
  479. }
  480.  
  481. String secureCommand(hubitat.zwave.Command cmd) {
  482. secureCommand(cmd.format())
  483. }
  484.  
  485. String secureCommand(String cmd) {
  486. String encap=""
  487. if (getDataValue("zwaveSecurePairingComplete") != "true") {
  488. return cmd
  489. } else {
  490. encap = "988100"
  491. }
  492. return "${encap}${cmd}"
  493. }
  494.  
  495. void zwaveEvent(hubitat.zwave.Command cmd) {
  496. if (logEnable) log.debug "skip:${cmd}"
  497. }
  498.  
  499. List<hubitat.zwave.Command> setDefaultAssociation() {
  500. List<hubitat.zwave.Command> cmds=[]
  501. cmds.add(zwave.associationV2.associationSet(groupingIdentifier: 1, nodeId: zwaveHubNodeId))
  502. cmds.add(zwave.associationV2.associationGet(groupingIdentifier: 1))
  503. return cmds
  504. }
  505.  
  506. List<hubitat.zwave.Command> processAssociations(){
  507. List<hubitat.zwave.Command> cmds = []
  508. cmds.addAll(setDefaultAssociation())
  509. return cmds
  510. }
  511.  
  512. void zwaveEvent(hubitat.zwave.commands.associationv2.AssociationReport cmd) {
  513. if (logEnable) log.debug "${device.label?device.label:device.name}: ${cmd}"
  514. List<String> temp = []
  515. if (cmd.nodeId != []) {
  516. cmd.nodeId.each {
  517. temp.add(it.toString().format( '%02x', it.toInteger() ).toUpperCase())
  518. }
  519. }
  520. updateDataValue("zwaveAssociationG${cmd.groupingIdentifier}", "$temp")
  521. }
  522.  
  523. void zwaveEvent(hubitat.zwave.commands.associationv2.AssociationGroupingsReport cmd) {
  524. if (logEnable) log.debug "${device.label?device.label:device.name}: ${cmd}"
  525. log.info "${device.label?device.label:device.name}: Supported association groups: ${cmd.supportedGroupings}"
  526. state.associationGroups = cmd.supportedGroupings
  527. }
  528.  
  529. private int gammaCorrect(value) {
  530. def temp=value/255
  531. def correctedValue=(temp>0.4045) ? Math.pow((temp+0.055)/ 1.055, 2.4) : (temp / 12.92)
  532. return Math.round(correctedValue * 255) as Integer
  533. }
Add Comment
Please, Sign In to add comment