├── .gitignore ├── LICENSE ├── README.md ├── devicetypes ├── codersaur │ └── evohome │ │ └── evohome-heating-zone.groovy ├── digitalgecko │ └── hue-dimmer-switch-zha.src │ │ └── hue-dimmer-switch-zha.groovy ├── paulsheldon │ ├── aqara-cube-controller.src │ │ └── aqara-cube-controller.groovy │ ├── hue-dimmer-switch-zha.src │ │ └── hue-dimmer-switch-zha.groovy │ ├── lightify-bulb.src │ │ └── lightify-bulb.groovy │ └── zigbee-switch-power.src │ │ └── zigbee-switch-power.groovy ├── scottgibson │ └── lightify-bulb.src │ │ └── lightify-bulb.groovy └── smartthings │ └── zigbee-switch-power.src │ └── zigbee-switch-power.groovy ├── resources ├── abc │ └── images │ │ ├── AeonMinimote1.png │ │ ├── AeonMinimote2.png │ │ ├── AeonMinimote3.png │ │ ├── AeonMinimote4.png │ │ ├── CubeController1.png │ │ ├── CubeController2.png │ │ ├── CubeController3.png │ │ ├── CubeController4.png │ │ ├── CubeController5.png │ │ ├── CubeController6.png │ │ ├── CubeController7.png │ │ ├── HueDimmer1.png │ │ ├── HueDimmer2.png │ │ ├── HueDimmer3.png │ │ ├── HueDimmer4.png │ │ ├── InovelliDimmerNZW31wScene1.png │ │ ├── InovelliDimmerNZW31wScene2.png │ │ ├── InovelliDimmerNZW31wScene3.png │ │ ├── InovelliDimmerNZW31wScene4.png │ │ ├── InovelliDimmerNZW31wScene5.png │ │ ├── InovelliDimmerNZW31wScene6.png │ │ ├── InovelliRed1.png │ │ ├── InovelliRed2.png │ │ ├── InovelliRed3.png │ │ ├── InovelliRed4 .png │ │ ├── InovelliRed5.png │ │ ├── InovelliRed6.png │ │ ├── InovelliRed7.png │ │ ├── InovelliSwitchNZW30wScene1.png │ │ ├── InovelliSwitchNZW30wScene2.png │ │ ├── InovelliSwitchNZW30wScene3.png │ │ ├── InovelliSwitchNZW30wScene4.png │ │ ├── InovelliSwitchNZW30wScene5.png │ │ ├── InovelliSwitchNZW30wScene6.png │ │ ├── LutronPico1.png │ │ ├── LutronPico2.png │ │ ├── LutronPico3.png │ │ ├── LutronPico4.png │ │ ├── LutronPico5.png │ │ ├── RemotecZRC90SceneMaster1.png │ │ ├── RemotecZRC90SceneMaster10.png │ │ ├── RemotecZRC90SceneMaster11.png │ │ ├── RemotecZRC90SceneMaster12.png │ │ ├── RemotecZRC90SceneMaster13.png │ │ ├── RemotecZRC90SceneMaster14.png │ │ ├── RemotecZRC90SceneMaster15.png │ │ ├── RemotecZRC90SceneMaster16.png │ │ ├── RemotecZRC90SceneMaster2.png │ │ ├── RemotecZRC90SceneMaster3.png │ │ ├── RemotecZRC90SceneMaster4.png │ │ ├── RemotecZRC90SceneMaster5.png │ │ ├── RemotecZRC90SceneMaster6.png │ │ ├── RemotecZRC90SceneMaster7.png │ │ ├── RemotecZRC90SceneMaster8.png │ │ ├── RemotecZRC90SceneMaster9.png │ │ ├── WD100+Dimmer1.png │ │ ├── WD100+Dimmer2.png │ │ ├── WD100+Dimmer3.png │ │ ├── WD100+Dimmer4.png │ │ ├── WD100+Dimmer5.png │ │ ├── WD100+Dimmer6.png │ │ ├── WD100+Dimmer7.png │ │ ├── WD100+Dimmer8.png │ │ ├── WS100+Switch1.png │ │ ├── WS100+Switch2.png │ │ ├── WS100+Switch3.png │ │ ├── WS100+Switch4.png │ │ ├── WS100+Switch5.png │ │ ├── WS100+Switch6.png │ │ ├── WS100+Switch7.png │ │ ├── WS100+Switch8.png │ │ ├── abcNew.png │ │ ├── abc_InitialSetup.png │ │ ├── abc_v0.1.170620.png │ │ ├── abc_v0.2.180212.png │ │ ├── abc_v0.2.190205.png │ │ ├── abc_v0.2.190925.png │ │ ├── abc_v0.3.200201.png │ │ ├── abc_v1.200505.png │ │ ├── abc_v1.200512.png │ │ ├── abc_v1.200709.png │ │ ├── abc_v1.210602.png │ │ ├── abc_v1.210707.png │ │ ├── update.png │ │ └── updatea.png ├── aquara-cube-controller │ └── images │ │ ├── 180.png │ │ ├── 90.png │ │ ├── bat_face.png │ │ ├── button_icon.png │ │ ├── cube_icon.png │ │ ├── def_face.png │ │ ├── knock.png │ │ ├── mi_face.png │ │ ├── mi_face_s.png │ │ ├── rotate_left.png │ │ ├── rotate_right.png │ │ ├── shake.png │ │ └── slide.png └── devicetype-icons │ ├── battery000.png │ ├── battery025.png │ ├── battery050.png │ ├── battery075.png │ └── battery100.png ├── smartapps └── paulsheldon │ ├── abc-child-creator.src │ └── abc-child-creator.groovy │ ├── abc-manager.src │ └── abc-manager.groovy │ └── evohome-connect │ └── evohome-connect.groovy └── webCoRe ├── Security Lights └── SecurityLights.piston.groovy └── Speech Controller ├── SpeechController.piston.groovy └── speechController.png /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/phpstorm 3 | # Edit at https://www.gitignore.io/?templates=phpstorm 4 | 5 | ### PhpStorm ### 6 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 7 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 8 | 9 | # User-specific stuff 10 | .idea/* 11 | /idea/* 12 | 13 | 14 | # Gradle and Maven with auto-import 15 | # When using Gradle or Maven with auto-import, you should exclude module files, 16 | # since they will be recreated, and may cause churn. Uncomment if using 17 | # auto-import. 18 | # .idea/modules.xml 19 | # .idea/*.iml 20 | # .idea/modules 21 | 22 | # CMake 23 | cmake-build-*/ 24 | 25 | # Mongo Explorer plugin 26 | .idea/**/mongoSettings.xml 27 | 28 | # File-based project format 29 | *.iws 30 | 31 | # IntelliJ 32 | out/ 33 | 34 | # mpeltonen/sbt-idea plugin 35 | .idea_modules/ 36 | 37 | # JIRA plugin 38 | atlassian-ide-plugin.xml 39 | 40 | # Cursive Clojure plugin 41 | .idea/replstate.xml 42 | 43 | # Crashlytics plugin (for Android Studio and IntelliJ) 44 | com_crashlytics_export_strings.xml 45 | crashlytics.properties 46 | crashlytics-build.properties 47 | fabric.properties 48 | 49 | # Editor-based Rest Client 50 | .idea/httpRequests 51 | 52 | # Android studio 3.1+ serialized cache file 53 | .idea/caches/build_file_checksums.ser 54 | 55 | ### PhpStorm Patch ### 56 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 57 | 58 | # *.iml 59 | # modules.xml 60 | # .idea/misc.xml 61 | # *.ipr 62 | 63 | # Sonarlint plugin 64 | .idea/sonarlint 65 | 66 | # End of https://www.gitignore.io/api/phpstorm 67 | 68 | smartapps/paulsheldon/abc-manager.src/.idea/.gitignore 69 | smartapps/paulsheldon/abc-manager.src/.idea/abc-manager.src.iml 70 | smartapps/paulsheldon/abc-manager.src/.idea/deployment.xml 71 | smartapps/paulsheldon/abc-manager.src/.idea/misc.xml 72 | smartapps/paulsheldon/abc-manager.src/.idea/modules.xml 73 | smartapps/paulsheldon/abc-manager.src/.idea/vcs.xml 74 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Welcome to my SmartThings Repository 2 | 3 | Here you will find my created SmartApps and Device Handlers as listed below. 4 | 5 | *Please note I acknowledge all original developers of updated Smart Apps & Device Handlers where appropriate* 6 | 7 | # Smart Apps 8 | 9 | ## ABC Advanced Button Controller - Updated 2020-05-05 10 | 11 | # Updated Features 12 | - Added Inovelli Red Series Switch (may also support Black Series) 13 | - Added ZRC-90 Scene Controller 14 | - Added Zen27 15 | - Added Ikea Button (5 buttons) 16 | - Added WS200+ Switch & Dimmer 17 | - Added Sonos Integration (Beta) 18 | - Updated Lightify Device Handler to allow Colour Temperature settings 19 | 20 | 21 | This is an updated version of **ABC** by Stephan Hackett ([See original repository here](https://github.com/stephack/ABC)). 22 | 23 | ### Updated Features 24 | - Added support for **Philips Hue Dimmer** 25 | - Added option to control **Color Temperature** 26 | - Code improvements 27 | 28 | # Device Handlers 29 | 30 | ## Hue Dimmer Switch 31 | 32 | This is an updated version **Hue Dimmer Switch** by Stephen McLaughlin ([See original repository here](https://github.com/sticks18/Lightify-Bulb)) 33 | 34 | ### Updated Features 35 | - Added support for **Smart App button numbers (1,2,3,4)** 36 | - Added option to switch between button names or numbers 37 | 38 | ## Lightify Bulb -ABC 39 | 40 | This is an updated version **Lightify Bulb ** by Scott Gibson ([See original repository here](https://github.com/digitalgecko/mySmartThings))) 41 | This has corrected colour temperature to work with ABC and a few other tweaks 42 | 43 | ## Zigbee Switch Power 44 | 45 | This is an updated version **Zigbee Power Switch** by SmartThings ([See original repository here](https://github.com/SmartThingsCommunity/SmartThingsPublic)) 46 | 47 | ### Updated Features 48 | - Added support for **Salus SP600 Smart Plug** 49 | 50 | ## Aqara Cube Controller (MFKZQ01LM). 51 | It is based on code by @DroidSector & @ClassicGod and would not be possible without their work. 52 | 53 | _To pair your Aqara Cube Controller with SmartThings HUB follow the instructions outlined here: https://community.smartthings.com/t/xiaomi-zigbee-outlet-steps-to-pair-any-xiaomi-zigbee-device/67582_ 54 | 55 | This DTH offers 3 modes of operation (that can be changed in the settings): 56 | 57 | 1. **Simple** (set by default)- designed for backwards compatibility with the previous DTH - presents only 7 buttons for basic gestures like shake, 90-degree flip, 180-degree flip, slide, knock, rotate right and rotate left. 58 | 2. **Advanced** - presents 36 buttons for maximum functionality. Buttons are assigned as follows: 59 | * buttons 1 to 6 - "push" event on face 0 to 5 activation (corresponds to face pointing up) 60 | * buttons 7 to 12 - "push" event on slide gesture with faces 0 to 5 pointing up 61 | * buttons 13 to 18 - "push" event on knock gesture with faces 0 to 5 pointing up 62 | * buttons 19 to 24 - "push" event on right rotation with faces 0 to 5 pointing up 63 | * buttons 25 to 30 - "push" event on left rotation with faces 0 to 5 pointing up 64 | * buttons 31 to 36 - "push" event on shake gesture with faces 0 to 5 pointing up 65 | 3. **Combined** - with this DTH will present 43 buttons assigned as follows: 66 | * buttons 1 to 7 - basic actions just like in Simple mode 67 | * buttons 8 to 43 - actions from Advanced mode moved by 7 positions. 68 | 69 | **I recommend using the Advanced mode** 70 | 71 | DTH also offers emulated "Three-Axis" capability for easy usage in SmartApps like Mood Cube. It is dependent on the selected face and affected by the limitation mentioned below. 72 | 73 | **_Due to limitations imposed by data sent by the hardware there are some things to keep in mind:_** 74 | 75 | * The device sends orientation only on those gestures: 76 | * 90-degree flip 77 | * 180-degree flip 78 | * slide 79 | * knock 80 | * Because of that orientation data for rotation and shake events is based on the last know orientation. 81 | * Device does not send any data if a gesture is unrecognized - rotating the cube randomly in the air and placing it down will most likely not send any event. 82 | * The DTH will correct the last known orientation and send missing flip/face activation events if needed as soon as it's got the orientation data from the device. 83 | * Due to the above rotation and shake events can execute for wrong faces if the flip gestures are not performed correctly (like rotating the cube randomly in the air) 84 | 85 | ## Installation 86 | To install the ABC Manager Smartapp 87 | * Login to the Smartthings IDE at https://graph.api.smartthings.com/ 88 | * Click My Locations and select your home location 89 | * Click My SmartApps 90 | * Click New SmartApp 91 | * Fill out the Name, Namespace, Author and Description 92 | * Click From Code tab 93 | * Copy the raw code from the abc-manager.src file and paste in the From Code box 94 | * Click Create 95 | * Click Publish, For Me 96 | 97 | Next, create the ABC Child Creator 98 | * Click My SmartApps 99 | * Click New SmartApp 100 | * Fill out the Name, Namespace, Author and Description 101 | * Click From Code tab 102 | * Copy the raw code from the abc-child-creator.src file and paste in the From Code box 103 | * Click Create 104 | * DO NOT PUBLISH 105 | 106 | The app will now be available to add to your app. 107 | * Open the SmartThings app 108 | * Click the hamburger menu and select SmartApps 109 | * Click + to add an app 110 | * Scroll down to custom apps and select ABC Manager 111 | * Follow prompts to complete install 112 | 113 | -------------------------------------------------------------------------------- /devicetypes/codersaur/evohome/evohome-heating-zone.groovy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/devicetypes/codersaur/evohome/evohome-heating-zone.groovy -------------------------------------------------------------------------------- /devicetypes/digitalgecko/hue-dimmer-switch-zha.src/hue-dimmer-switch-zha.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Hue Dimmer Switch 3 | * 4 | * Copyright 2016 Stephen McLaughlin 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | metadata { 18 | definition (name: "Hue Dimmer Switch ZHA", namespace: "digitalgecko", author: "Stephen McLaughlin") { 19 | capability "Configuration" 20 | capability "Battery" 21 | capability "Refresh" 22 | capability "Button" 23 | capability "Sensor" 24 | 25 | fingerprint profileId: "0104", endpointId: "02", application:"02", outClusters: "0019", inClusters: "0000,0001,0003,000F,FC00", manufacturer: "Philips", model: "RWL020", deviceJoinName: "Hue Dimmer Switch (ZHA)" 26 | fingerprint profileId: "0104", endpointId: "02", application:"02", outClusters: "0019", inClusters: "0000,0001,0003,000F,FC00", manufacturer: "Philips", model: "RWL021", deviceJoinName: "Hue Dimmer Switch" 27 | 28 | attribute "lastAction", "string" 29 | attribute "useButtonNames", "boolean" 30 | } 31 | 32 | simulator { 33 | // TODO: define status and reply messages here 34 | } 35 | 36 | tiles(scale: 2) { 37 | 38 | multiAttributeTile(name:"lastAction", type: "generic", width: 6, height: 4){ 39 | tileAttribute ("device.battery", key: "SECONDARY_CONTROL") { 40 | attributeState "battery", label: '${currentValue}%',icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/develop/resources/devicetype-icons/battery050.png" 41 | } 42 | tileAttribute ("device.lastAction", key: "PRIMARY_CONTROL") { 43 | attributeState "active", label:'${currentValue}', icon:"st.Home.home30" 44 | } 45 | } 46 | 47 | valueTile("battery", "device.battery", decoration: "flat", inactiveLabel: false, width: 5, height: 1) { 48 | state("battery", label:'${currentValue}% battery', unit:"") 49 | } 50 | standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 1, height: 1) { 51 | state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" 52 | } 53 | 54 | main "lastAction" 55 | details(["lastAction","battery","refresh","configure"]) 56 | } 57 | 58 | preferences { 59 | input description: "The settings below allow the button to be returned as 1,2,3,4 as required for Smart Apps or 'on','up','down','off' as per original device handler.", type: "paragraph", element: "paragraph", title: "BUTTON NAMES" 60 | input "buttonNames", "bool", title:"Button Names - Use 1,2,3,4", description:"Use Button Numbers for Smart Apps" 61 | } 62 | } 63 | 64 | // parse events into attributes 65 | def parse(String description) { 66 | def msg = zigbee.parse(description) 67 | 68 | //log.warn msg 69 | /// Actual code down here 70 | List map = [] 71 | if (description?.startsWith('catchall:')) { 72 | map = parseCatchAllMessage(description) 73 | } 74 | 75 | def result = map ? map : null 76 | 77 | if (description?.startsWith('enroll request')) { 78 | List cmds = enrollResponse() 79 | result = cmds?.collect { new physicalgraph.device.HubAction(it) } 80 | } 81 | else if (description?.startsWith('read attr -')) { 82 | result = parseReportAttributeMessage(description).each { createEvent(it) } 83 | } 84 | return result 85 | } 86 | 87 | private List parseReportAttributeMessage(String description) { 88 | Map descMap = (description - "read attr - ").split(",").inject([:]) { map, param -> 89 | def nameAndValue = param.split(":") 90 | map += [(nameAndValue[0].trim()):nameAndValue[1].trim()] 91 | } 92 | 93 | List result = [] 94 | 95 | // Battery 96 | if (descMap.cluster == "0001" && descMap.attrId == "0020") { 97 | // log.warn descMap 98 | result << getBatteryResult(Integer.parseInt(descMap.value, 16)) 99 | } 100 | 101 | return result 102 | } 103 | 104 | private boolean shouldProcessMessage(cluster) { 105 | // 0x0B is default response indicating message got through 106 | boolean ignoredMessage = cluster.profileId != 0x0104 || 107 | cluster.command == 0x0B || 108 | (cluster.data.size() > 0 && cluster.data.first() == 0x3e) 109 | return !ignoredMessage 110 | } 111 | 112 | /* 113 | getBatteryResult 114 | */ 115 | //TODO: needs calibration 116 | private Map getBatteryResult(rawValue) { 117 | //log.debug "Battery rawValue = ${rawValue}" 118 | 119 | def result = [ 120 | name: 'battery', 121 | value: '--', 122 | translatable: true 123 | ] 124 | 125 | def volts = rawValue / 10 126 | 127 | if (rawValue == 0 || rawValue == 255) {} 128 | else { 129 | if (volts > 3.5) { 130 | result.descriptionText = "{{ device.displayName }} battery has too much power: (> 3.5) volts." 131 | } 132 | else { 133 | if (device.getDataValue("manufacturer") == "SmartThings") { 134 | volts = rawValue // For the batteryMap to work the key needs to be an int 135 | def batteryMap = [28:100, 27:100, 26:100, 25:90, 24:90, 23:70, 136 | 22:70, 21:50, 20:50, 19:30, 18:30, 17:15, 16:1, 15:0] 137 | def minVolts = 15 138 | def maxVolts = 28 139 | 140 | if (volts < minVolts) 141 | volts = minVolts 142 | else if (volts > maxVolts) 143 | volts = maxVolts 144 | def pct = batteryMap[volts] 145 | if (pct != null) { 146 | result.value = pct 147 | result.descriptionText = "{{ device.displayName }} battery was {{ value }}%" 148 | } 149 | } 150 | else { 151 | def minVolts = 2.1 152 | def maxVolts = 3.0 153 | def pct = (volts - minVolts) / (maxVolts - minVolts) 154 | def roundedPct = Math.round(pct * 100) 155 | if (roundedPct <= 0) 156 | roundedPct = 1 157 | result.value = Math.min(100, roundedPct) 158 | result.descriptionText = "{{ device.displayName }} battery was {{ value }}%" 159 | } 160 | } 161 | } 162 | 163 | return result 164 | } 165 | 166 | private List getButtonResult(rawValue) { 167 | def result 168 | def button = rawValue[0] 169 | def buttonState = rawValue[4] 170 | def buttonHoldTime = rawValue[6] 171 | def hueStatus = (button as String) + "00" + (buttonState as String) // This is the state in the HUE api 172 | log.info "Button: " + button + " Hue Code: " + hueStatus + " Hold Time: " + buttonHoldTime + " Button State: " + buttonState 173 | // result.data = ['buttonNumber': button] 174 | 175 | def buttonValue=["on","up","down", "off"] 176 | sendEvent(name: "buttonNames", value: buttonNames) 177 | def buttonName= (buttonNames)? "$button" : buttonValue[button-1] 178 | def buttonTitle= buttonValue[button-1] 179 | log.info "Button Names: $buttonNames : $buttonName" 180 | 181 | // The button is pressed, aka: pushed + released, with 0 hold time 182 | if ( buttonState == 0 ) { 183 | result = [createEvent(name: "button", value: "pressed" , data: [buttonNumber: buttonName], descriptionText: "$device.displayName button $button was pushed", isStateChange: true)] 184 | sendEvent(name: "lastAction", value: buttonTitle + " pressed") 185 | } 186 | // The button is pressed, aka: pushed + released, with at least 1s hold time 187 | else if ( buttonState == 2 ) { 188 | result = [ 189 | createEvent(name: "button", value: "pushed" , data: [buttonNumber: buttonName], descriptionText: "$device.displayName button $button was pushed", isStateChange: true), 190 | createEvent(name: "button", value: "released" , data: [buttonNumber: buttonName], descriptionText: "$device.displayName button $button was pushed", isStateChange: true) 191 | ] 192 | sendEvent(name: "lastAction", value: buttonTitle + " pushed") 193 | sendEvent(name: "lastAction", value: buttonTitle + " released") 194 | } 195 | // The button is released, with at least 1s hold time. This code happens after the button is held 196 | else if ( buttonState == 3 ) { 197 | result = [ 198 | createEvent(name: "button", value: "released", data: [buttonNumber: buttonName], descriptionText: "$device.displayName button $button was pushed", isStateChange: true) 199 | ] 200 | sendEvent(name: "lastAction", value: buttonTitle + " released") 201 | } 202 | // The button is held 203 | else if ( buttonHoldTime == 8 ) { 204 | result = [createEvent(name: "button", value: "held", data: [buttonNumber: buttonName], descriptionText: "$device.displayName button $button was held", isStateChange: true)] 205 | sendEvent(name: "lastAction", value: buttonTitle + " held") 206 | } 207 | else { 208 | return 209 | } 210 | return result 211 | 212 | } 213 | 214 | /* 215 | parseCatchAllMessage 216 | */ 217 | private List parseCatchAllMessage(String description) { 218 | List resultMap = [] 219 | def cluster = zigbee.parse(description) 220 | if (shouldProcessMessage(cluster)) { 221 | switch(cluster.clusterId) { 222 | case 0x0001: 223 | // 0x07 - configure reporting 224 | if (cluster.command != 0x07) { 225 | resultMap = [getBatteryResult(cluster.data.last())] 226 | } 227 | break 228 | 229 | case 0xFC00: 230 | if ( cluster.command == 0x00 ) { 231 | resultMap = getButtonResult( cluster.data ); 232 | } 233 | break 234 | 235 | } 236 | } 237 | 238 | return resultMap 239 | } 240 | 241 | 242 | def refresh() { 243 | //log.debug "Refresh" 244 | 245 | def refreshCmds = [] 246 | 247 | refreshCmds += "st rattr 0x${device.deviceNetworkId} 0x02 0x0001 0x0020"; // WORKS! - Fetches battery from 0x02 248 | 249 | 250 | // configCmds += zigbee.configureReporting(0x406,0x0000, 0x18, 30, 600, null) // motion // confirmed 251 | 252 | //refreshCmds += zigbee.configureReporting(0x000F, 0x0055, 0x10, 30, 30, null); 253 | // refreshCmds += "zdo bind 0xDAD6 0x01 0x02 0x000F {00178801103317AA} {}" 254 | // refreshCmds += "delay 2000" 255 | // refreshCmds += "st cr 0xDAD6 0x02 0x000F 0x0055 0x10 0x001E 0x001E {}" 256 | // refreshCmds += "delay 2000" 257 | 258 | //refreshCmds += zigbee.configureReporting(0x000F, 0x006F, 0x18, 0x30, 0x30); 259 | // refreshCmds += "zdo bind 0x${device.deviceNetworkId} 0x02 0x02 0xFC00 {${device.zigbeeId}} {}" 260 | // refreshCmds += "delay 2000" 261 | // refreshCmds += "st cr 0x${device.deviceNetworkId} 0x02 0xFC00 0x0000 0x18 0x001E 0x001E {}" 262 | // refreshCmds += "delay 2000" 263 | //log.debug refreshCmds 264 | 265 | return refreshCmds 266 | } 267 | 268 | def configure() { 269 | // String zigbeeId = swapEndianHex(device.hub.zigbeeId) 270 | //log.debug "Configuring Reporting and Bindings." 271 | def configCmds = [] 272 | 273 | // Configure Button Count 274 | sendEvent(name: "numberOfButtons", value: 4, displayed: false) 275 | 276 | // Monitor Buttons 277 | //TODO: This could be zigbee.configureReporting(0xFC00, 0x0000, 0x18, 0x001e, 0x001e); but no idea how to point it at a different endpoint 278 | configCmds += "zdo bind 0x${device.deviceNetworkId} 0x02 0x02 0xFC00 {${device.zigbeeId}} {}" 279 | configCmds += "delay 2000" 280 | configCmds += "st cr 0x${device.deviceNetworkId} 0x02 0xFC00 0x0000 0x18 0x001E 0x001E {}" 281 | configCmds += "delay 2000" 282 | 283 | // Monitor Battery 284 | //TODO: This could be zigbee.batteryConfig(); but no idea how to point it at a different endpoint 285 | configCmds += "zdo bind 0x${device.deviceNetworkId} 0x02 0x02 0x0001 {${device.zigbeeId}} {}" 286 | configCmds += "delay 2000" 287 | configCmds += "st cr 0x${device.deviceNetworkId} 0x02 0x0001 0x0020 0x20 0x001E 0x0258 {}" 288 | // configCmds += "st cr 0x${device.deviceNetworkId} 0x02 0x0001 0x0020 0x20 0x001E 0x001e {}" 289 | 290 | configCmds += "delay 2000" 291 | return configCmds + refresh() 292 | } 293 | 294 | def configureHealthCheck() { 295 | Integer hcIntervalMinutes = 12 296 | refresh() 297 | sendEvent(name: "checkInterval", value: hcIntervalMinutes * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) 298 | } 299 | 300 | def updated() { 301 | configureHealthCheck() 302 | } -------------------------------------------------------------------------------- /devicetypes/paulsheldon/aqara-cube-controller.src/aqara-cube-controller.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * "Xiaomi Magic Cube Controller" 3 | * 4 | * Author: Paul Sheldon 5 | * 6 | * Based on code updated by: Artur "ClassicGod" Draga 7 | * Based on code by: Oleg "DroidSector" Smirnov 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 10 | * in compliance with the License. You may obtain a copy of the License at: 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 15 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 16 | * for the specific language governing permissions and limitations under the License. 17 | * 18 | * 19 | * Release Notes 20 | * ============= 21 | * Added fingerprint for Aqara Cube Controller MFKZQ01LM 22 | * Added Battery for Battery Monitor 23 | */ 24 | 25 | metadata { 26 | definition (name: "Aqara Cube Controller", namespace: "paulsheldon", author: "Paul Sheldon") { 27 | capability "Actuator" 28 | capability "Button" 29 | capability "Configuration" 30 | capability "Battery" 31 | capability "Three Axis" //Simulated! 32 | capability "Sensor" 33 | 34 | // Aqara Cube Controller MFKZQ01LM 35 | fingerprint profileId: "0104", inClusters: "0000,0003,0019,0012", outClusters: "0000,0004,0003,0005,0019,0012", manufacturer: "LUMI", model: "lumi.sensor_cube", deviceJoinName: "Aqara Cube Controller" 36 | fingerprint profileId: "0104", inClusters: "0003,0012", outClusters: "0004,0003,0005,0012" 37 | fingerprint profileId: "0104", inClusters: "0003,000C", outClusters: "0004,0003,0005,000C" 38 | 39 | attribute "face", "number" 40 | attribute "angle", "number" 41 | attribute "batteryType", "string" 42 | 43 | command "setFace0" 44 | command "setFace1" 45 | command "setFace2" 46 | command "setFace3" 47 | command "setFace4" 48 | command "setFace5" 49 | 50 | command "flip90" 51 | command "flip180" 52 | command "slide" 53 | command "knock" 54 | command "rotateR" 55 | command "rotateL" 56 | command "shake" 57 | } 58 | 59 | simulator { 60 | } 61 | 62 | tiles (scale: 2){ 63 | //button tiles! 64 | standardTile("face0", "device.face", decoration: "flat", width: 2, height: 2) { 65 | state "default", label:'Face 0', action:"setFace0", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/def_face.png", backgroundColor: "#ffffff" 66 | state "0", label:'Face 0', action:"setFace0", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/def_face.png", backgroundColor: "#00a0dc" 67 | } 68 | standardTile("face1", "device.face", decoration: "flat", width: 2, height: 2) { 69 | state "default", label:'Face 1', action:"setFace1", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/def_face.png", backgroundColor: "#ffffff" 70 | state "1", label:'Face 1', action:"setFace1", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/def_face.png", backgroundColor: "#00a0dc" 71 | } 72 | standardTile("face2", "device.face", decoration: "flat", width: 2, height: 2) { 73 | state "default", label:'Face 2', action:"setFace2", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/def_face.png", backgroundColor: "#ffffff" 74 | state "2", label:'Face 2', action:"setFace2", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/def_face.png", backgroundColor: "#00a0dc" 75 | } 76 | standardTile("face3", "device.face", decoration: "flat", width: 2, height: 2) { 77 | state "default", label:'Face 3', action:"setFace3", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/bat_face.png", backgroundColor: "#ffffff" 78 | state "3", label:'Face 3', action:"setFace3", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/bat_face.png", backgroundColor: "#00a0dc" 79 | } 80 | standardTile("face4", "device.face", decoration: "flat", width: 2, height: 2) { 81 | state "default", label:'Face 4', action:"setFace4", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/def_face.png", backgroundColor: "#ffffff" 82 | state "4", label:'Face 4', action:"setFace4", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/def_face.png", backgroundColor: "#00a0dc" 83 | } 84 | standardTile("face5", "device.face", decoration: "flat", width: 2, height: 2) { 85 | state "default", label:'Face 5', action:"setFace5", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/mi_face.png", backgroundColor: "#ffffff" 86 | state "5", label:'Face 5', action:"setFace5", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/mi_face_s.png", backgroundColor: "#00a0dc" 87 | } 88 | //function tiles! 89 | standardTile("flip90", "device.button", decoration: "flat", width: 2, height: 2) { 90 | state "default", label: "90°", action: "flip90", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/90.png", backgroundColor: "#ffffff" 91 | } 92 | standardTile("flip180", "device.button", decoration: "flat", width: 2, height: 2) { 93 | state "default", label: "180°", action: "flip180", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/180.png", backgroundColor: "#ffffff" 94 | } 95 | standardTile("rotateL", "device.button", decoration: "flat", width: 2, height: 2) { 96 | state "default", label: "rotate left", action: "rotateL", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/rotate_left.png", backgroundColor: "#ffffff" 97 | } 98 | standardTile("rotateR", "device.button", decoration: "flat", width: 2, height: 2) { 99 | state "default", label: "rotate right", action: "rotateR", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/rotate_right.png", backgroundColor: "#ffffff" 100 | } 101 | standardTile("slide", "device.button", decoration: "flat", width: 2, height: 2) { 102 | state "default", label: "slide", action: "slide", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/slide.png", backgroundColor: "#ffffff" 103 | } 104 | standardTile("knock", "device.button", decoration: "flat", width: 2, height: 2) { 105 | state "default", label: "knock", action: "knock", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/knock.png", backgroundColor: "#ffffff" 106 | } 107 | standardTile("shake", "device.button", decoration: "flat", width: 2, height: 2) { 108 | state "default", label: "shake" , action: "shake", icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/shake.png", backgroundColor: "#ffffff" 109 | } 110 | valueTile("battery", "device.battery", decoration: "flat", width: 4, height: 2) { 111 | state "val", label: '${currentValue}% battery', backgroundColors:[ 112 | [value: 0, color: "#ff0000"], 113 | [value: 20, color: "#e86d13"], 114 | [value: 100, color: "#00ff00"] 115 | ] 116 | } 117 | standardTile("faceMain", "device.face", decoration: "flat", width: 2, height: 2) { 118 | state "default", label:'Face: ${currentValue} ', icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/aqara-cube-controller/images/cube_icon.png", backgroundColor: "#ffffff" 119 | } 120 | 121 | main(["faceMain"]) 122 | details(["flip90","face0","flip180","face4","face5","face1","rotateL","face3","rotateR","slide","face2","knock","battery","shake"]) 123 | } 124 | 125 | preferences { 126 | input ( 127 | name: "cubeMode", 128 | title: "Cube Mode", 129 | description: "Select how many button events should be sent by the device handler.\n\nSimple presents just 7 buttons on basic gestures (shake,flip 90, flip 180, slide, knock, rotate R, rotate L).\n\nAdvanced presents 36 buttons for separate actions on every face (activate, slide, knock, rotate R, rotate L, shake).\n\nCombined offers both for total of 43 buttons. ", 130 | type: "enum", 131 | options: [ 132 | 0: "Simple - 7 buttons", 133 | 1: "Advanced - 36 buttons", 134 | 2: "Combined - 43 buttons" 135 | ], 136 | required: false 137 | ) 138 | } 139 | } 140 | 141 | def setFace0() { setFace(0) } 142 | def setFace1() { setFace(1) } 143 | def setFace2() { setFace(2) } 144 | def setFace3() { setFace(3) } 145 | def setFace4() { setFace(4) } 146 | def setFace5() { setFace(5) } 147 | def flip90() { 148 | def flipMap = [0:5, 1:2, 2:0, 3:2, 4:5, 5:3] 149 | flipEvents(flipMap[device.currentValue("face") as Integer], "90") 150 | } 151 | def flip180() { 152 | def flipMap = [0:3, 1:4, 2:5, 3:0, 4:1, 5:2] 153 | flipEvents(flipMap[device.currentValue("face") as Integer], "180") 154 | } 155 | def rotateL() { rotateEvents(-90) } 156 | def rotateR() { rotateEvents(90) } 157 | def slide() { slideEvents(device.currentValue("face") as Integer) } 158 | def knock() { knockEvents(device.currentValue("face") as Integer) } 159 | def shake() { shakeEvents() } 160 | 161 | def setFace(Integer faceId) { 162 | def Integer prevFaceId = device.currentValue("face") 163 | if (prevFaceId == faceId) { 164 | flipEvents(faceId, "0") 165 | } else if ((prevFaceId == 0 && faceId == 3)||(prevFaceId == 1 && faceId == 4)||(prevFaceId == 2 && faceId == 5)||(prevFaceId == 3 && faceId == 0)||(prevFaceId == 4 && faceId == 1)||(prevFaceId == 5 && faceId == 2)){ 166 | flipEvents(faceId, "180") 167 | } else { 168 | flipEvents(faceId, "90") 169 | } 170 | } 171 | 172 | def parse(String description) { 173 | def value = zigbee.parse(description)?.text 174 | 175 | 176 | if (description?.startsWith('catchall:')) { 177 | parseCatchAllMessage(description) 178 | } 179 | else if (description?.startsWith('read attr -')) { 180 | parseReportAttributeMessage(description) 181 | } 182 | 183 | 184 | if (description?.startsWith('enroll request')) { 185 | List cmds = enrollResponse() 186 | log.debug "enroll response: ${cmds}" 187 | result = cmds?.collect { new physicalgraph.device.HubAction(it) } 188 | } 189 | return result 190 | } 191 | 192 | // not tested 193 | private parseCatchAllMessage(String description) { 194 | def cluster = zigbee.parse(description) 195 | if (shouldProcessMessage(cluster)) { 196 | switch(cluster.clusterId) { 197 | case 0x0000: 198 | log.debug "battery! " + cluster.data + " : " + cluster.data.get(6) + " : " + cluster 199 | getBatteryResult(cluster.data.get(6)) 200 | break 201 | } 202 | } 203 | } 204 | 205 | // not tested 206 | private boolean shouldProcessMessage(cluster) { 207 | boolean ignoredMessage = cluster.profileId != 0x0104 || 208 | cluster.command == 0x0B || 209 | cluster.command == 0x07 || 210 | (cluster.data.size() > 0 && cluster.data.first() == 0x3e) 211 | return !ignoredMessage 212 | } 213 | 214 | private Map parseReportAttributeMessage(String description) { 215 | Map descMap = (description - "read attr - ").split(",").inject([:]) { map, param -> 216 | def nameAndValue = param.split(":") 217 | map += [(nameAndValue[0].trim()):nameAndValue[1].trim()] 218 | } 219 | if (descMap.cluster == "0001" && descMap.attrId == "0020") { 220 | getBatteryResult(Integer.parseInt(descMap.value, 16)) 221 | } 222 | else if (descMap.cluster == "0012" && descMap.attrId == "0055") { // Shake, flip, knock, slide 223 | getMotionResult(descMap.value) 224 | } 225 | else if (descMap.cluster == "000C" && descMap.attrId == "ff05") { // Rotation (90 and 180 degrees) 226 | getRotationResult(descMap.value) 227 | } else { log.debug descMap } 228 | 229 | } 230 | 231 | def String hexToBinOld(String thisByte) { 232 | return String.format("%8s", Integer.toBinaryString(Integer.parseInt(thisByte,16))).replace(' ', '0') 233 | } 234 | 235 | def String hexToBin(String thisByte, Integer size = 8) { 236 | String binaryValue = new BigInteger(thisByte, 16).toString(2); 237 | return String.format("%${size}s", binaryValue).replace(' ', '0') 238 | } 239 | private Map parseCustomMessage(String description) { 240 | Map resultMap = [:] 241 | return resultMap 242 | } 243 | 244 | private getBatteryResult(rawValue) { 245 | def batteryLevel = Math.round(rawValue * 100 / 255) 246 | 247 | if (batteryLevel > 100) { 248 | batteryLevel = 100 249 | } 250 | 251 | if (batteryLevel) { sendEvent( [ name: "battery", value: batteryLevel, descriptionText: "$device.displayName battery is ${batteryLevel}%", isStateChange: true] ) } 252 | } 253 | 254 | private Map getMotionResult(String value) { 255 | String motionType = value[0..1] 256 | String binaryValue = hexToBin(value[2..3]) 257 | Integer sourceFace = Integer.parseInt(binaryValue[2..4],2) 258 | Integer targetFace = Integer.parseInt(binaryValue[5..7],2) 259 | 260 | if (motionType == "00") { 261 | switch(binaryValue[0..1]) { 262 | case "00": 263 | if (targetFace==0) { shakeEvents() } 264 | break 265 | case "01": 266 | flipEvents(targetFace, "90") 267 | break 268 | case "10": 269 | flipEvents(targetFace, "180") 270 | break 271 | } 272 | } else if (motionType == "01") { 273 | slideEvents(targetFace) 274 | } else if (motionType == "02") { 275 | knockEvents(targetFace) 276 | } 277 | } 278 | 279 | private Map getRotationResult(value) { 280 | Integer angle = Math.round(Float.intBitsToFloat(Long.parseLong(value[0..7],16).intValue())); 281 | rotateEvents(angle) 282 | } 283 | 284 | def Map shakeEvents() { 285 | if (!settings.cubeMode || settings.cubeMode in ['0','2'] ) { 286 | sendEvent([ 287 | name: "button", 288 | value: "pushed", 289 | data: [buttonNumber: 1, face: device.currentValue("face")], 290 | descriptionText: (settings.cubeMode == '0') ? "$device.displayName was shaken" : null, 291 | isStateChange: true, 292 | displayed: (settings.cubeMode == '0') ? true : false 293 | ]) 294 | } 295 | 296 | if (settings.cubeMode in ['1','2'] ){ 297 | sendEvent([ 298 | name: "button", 299 | value: "pushed", 300 | data: [buttonNumber: (device.currentValue("face") as Integer) + ((settings.cubeMode == '1') ? 31 : 38), 301 | face: device.currentValue("face")], 302 | descriptionText: "$device.displayName was shaken (Face # ${device.currentValue("face")}).", 303 | isStateChange: true]) 304 | } 305 | } 306 | 307 | def flipEvents(Integer faceId, String flipType) { 308 | if (flipType == "0") { 309 | sendEvent( [name: 'face', value: -1, isStateChange: false] ) 310 | sendEvent( [name: 'face', value: faceId, isStateChange: false] ) 311 | } else if (flipType == "90") { 312 | if (settings.cubeMode in ['0','2']) { 313 | sendEvent( [ 314 | name: 'button', 315 | value: "pushed" , 316 | data: [buttonNumber: 2, face: faceId], 317 | descriptionText: (settings.cubeMode == '0') ? "$device.displayName detected $flipType degree flip" : null, 318 | isStateChange: true, 319 | displayed: (settings.cubeMode == '0') ? true : false 320 | ] ) 321 | } 322 | } else if (flipType == "180") { 323 | if (settings.cubeMode in ['0','2']) { 324 | sendEvent( [ 325 | name: 'button', 326 | value: "pushed" , 327 | data: [buttonNumber: 3, face: faceId], 328 | descriptionText: (settings.cubeMode == '0') ? "$device.displayName detected $flipType degree flip" : null, 329 | isStateChange: true, 330 | displayed: (settings.cubeMode == '0') ? true : false 331 | ] ) 332 | } 333 | } 334 | sendEvent( [name: 'face', value: faceId, isStateChange: true, displayed: false ] ) 335 | if (settings.cubeMode in ['1','2']) { 336 | sendEvent( [ 337 | name: "button", 338 | value: "pushed", 339 | data: [buttonNumber: faceId+((settings.cubeMode == '1') ? 1 : 8), face: faceId], 340 | descriptionText: "$device.displayName was flipped to face # $faceId", 341 | isStateChange: true 342 | ] ) 343 | } 344 | switch (faceId) { 345 | case 0: sendEvent( [ name: "threeAxis", value: "0,-1000,0", isStateChange: true, displayed: false] ); break 346 | case 1: sendEvent( [ name: "threeAxis", value: "-1000,0,0", isStateChange: true, displayed: false] ); break 347 | case 2: sendEvent( [ name: "threeAxis", value: "0,0,1000", isStateChange: true, displayed: false] ); break 348 | case 3: sendEvent( [ name: "threeAxis", value: "1000,0,0", isStateChange: true, displayed: false] ); break 349 | case 4: sendEvent( [ name: "threeAxis", value: "0,1000,0", isStateChange: true, displayed: false] ); break 350 | case 5: sendEvent( [ name: "threeAxis", value: "0,0,-1000", isStateChange: true, displayed: false] ); break 351 | } 352 | } 353 | 354 | def Map slideEvents(Integer targetFace) { 355 | if ( targetFace != device.currentValue("face") as Integer ) { log.info "Stale face data, updating."; setFace(targetFace) } 356 | if (!settings.cubeMode || settings.cubeMode in ['0','2'] ) { 357 | sendEvent( [ 358 | name: "button", 359 | value: "pushed", 360 | data: [buttonNumber: 4, face: targetFace], 361 | descriptionText: (settings.cubeMode == '0') ? "$device.displayName detected slide motion." : null, 362 | isStateChange: true, 363 | displayed: (settings.cubeMode == '0') ? true : false 364 | ] ) 365 | } 366 | 367 | if ( settings.cubeMode in ['1','2'] ) { 368 | sendEvent( [ 369 | name: "button", 370 | value: "pushed", 371 | data: [buttonNumber: targetFace+((settings.cubeMode == '1') ? 7 : 14), face: targetFace], 372 | descriptionText: "$device.displayName was slid with face # $targetFace up.", 373 | isStateChange: true 374 | ] ) } 375 | } 376 | 377 | def knockEvents(Integer targetFace) { 378 | if ( targetFace != device.currentValue("face") as Integer ) { log.info "Stale face data, updating."; setFace(targetFace) } 379 | if (!settings.cubeMode || settings.cubeMode in ['0','2'] ) { 380 | sendEvent( [ 381 | name: "button", 382 | value: "pushed", 383 | data: [buttonNumber: 5, face: targetFace], 384 | descriptionText: (settings.cubeMode == '0') ? "$device.displayName detected knock motion." : null, 385 | isStateChange: true, 386 | displayed: (settings.cubeMode == '0') ? true : false 387 | ] ) 388 | } 389 | if ( settings.cubeMode in ['1','2'] ) { 390 | sendEvent( [ 391 | name: "button", 392 | value: "pushed", 393 | data: [buttonNumber: targetFace+((settings.cubeMode == '1') ? 13 : 20), face: targetFace], 394 | descriptionText: "$device.displayName was knocked with face # $targetFace up", 395 | isStateChange: true 396 | ] ) 397 | } 398 | } 399 | 400 | def rotateEvents(Integer angle) { 401 | sendEvent( [ name: "angle", value: angle, isStateChange: true, displayed: false] ) 402 | if ( angle > 0 ) { 403 | if (!settings.cubeMode || settings.cubeMode in ['0','2'] ) { 404 | sendEvent( [ 405 | name: "button", 406 | value: "pushed", 407 | data: [buttonNumber: 6, face: device.currentValue("face"), angle: angle], 408 | descriptionText: (settings.cubeMode == '0') ? "$device.displayName was rotated right." : null, 409 | isStateChange: true, 410 | displayed: (settings.cubeMode == '0') ? true : false 411 | ] ) 412 | } 413 | if ( settings.cubeMode in ['1','2'] ) { 414 | sendEvent( [ 415 | name: "button", 416 | value: "pushed", 417 | data: [buttonNumber: (device.currentValue("face") as Integer) + ((settings.cubeMode == '1') ? 19 : 26), face: device.currentValue("face")], 418 | descriptionText: "$device.displayName was rotated right (Face # ${device.currentValue("face")}).", 419 | isStateChange: true 420 | ] ) 421 | } 422 | } else { 423 | if (!settings.cubeMode || settings.cubeMode in ['0','2'] ) { 424 | sendEvent( [ 425 | name: "button", 426 | value: "pushed", 427 | data: [buttonNumber: 7, face: device.currentValue("face"), angle: angle], 428 | descriptionText: (settings.cubeMode == '0') ? "$device.displayName was rotated left." : null, 429 | isStateChange: true, 430 | displayed: (settings.cubeMode == '0') ? true : false 431 | ] ) 432 | } 433 | if ( settings.cubeMode in ['1','2'] ) { 434 | sendEvent( [ 435 | name: "button", 436 | value: "pushed", 437 | data: [buttonNumber: (device.currentValue("face") as Integer) + ((settings.cubeMode == '1') ? 25 : 32), face: device.currentValue("face")], 438 | descriptionText: "$device.displayName was rotated left (Face # ${device.currentValue("face")}).", 439 | isStateChange: true 440 | ] ) 441 | } 442 | } 443 | } 444 | 445 | def configure() { 446 | String zigbeeEui = swapEndianHex(device.hub.zigbeeEui) 447 | log.debug "Configuring Reporting, IAS CIE, and Bindings." 448 | def configCmds = [] 449 | return configCmds + refresh() // send refresh cmds as part of config 450 | } 451 | 452 | def enrollResponse() { 453 | log.debug "Sending enroll response" 454 | } 455 | 456 | def reset() { 457 | 458 | } 459 | 460 | def initialize() { 461 | sendState() 462 | } 463 | 464 | def poll() { 465 | //sendState() 466 | } 467 | 468 | def sendState() { 469 | sendEvent(name: "numberOfButtons", value: 7) 470 | } 471 | 472 | def updated() { 473 | if ( state.lastUpdated && (now() - state.lastUpdated) < 500 ) return 474 | switch(settings.cubeMode) { 475 | case "1": sendEvent(name: "numberOfButtons", value: 36); break 476 | case "2": sendEvent(name: "numberOfButtons", value: 43); break 477 | default: sendEvent(name: "numberOfButtons", value: 7); break 478 | } 479 | sendEvent(name: "batteryType", value: "CR2450") 480 | state.lastUpdated = now() 481 | } 482 | -------------------------------------------------------------------------------- /devicetypes/paulsheldon/hue-dimmer-switch-zha.src/hue-dimmer-switch-zha.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Hue Dimmer Switch 3 | * 4 | * Copyright 2016 Stephen McLaughlin 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | * Updated to allow buttons to return 1,2,3,4 instead of on/off/up/down 16 | */ 17 | 18 | metadata { 19 | definition (name: "Hue Dimmer Switch ZHA", namespace: "paulsheldon", author: "Paul Sheldon") { 20 | capability "Configuration" 21 | capability "Battery" 22 | capability "Refresh" 23 | capability "Button" 24 | capability "Sensor" 25 | 26 | fingerprint profileId: "0104", endpointId: "02", application:"02", outClusters: "0019", inClusters: "0000,0001,0003,000F,FC00", manufacturer: "Philips", model: "RWL020", deviceJoinName: "Hue Dimmer Switch (ZHA)" 27 | fingerprint profileId: "0104", endpointId: "02", application:"02", outClusters: "0019", inClusters: "0000,0001,0003,000F,FC00", manufacturer: "Philips", model: "RWL021", deviceJoinName: "Hue Dimmer Switch" 28 | 29 | attribute "lastAction", "string" 30 | attribute "useButtonNames", "boolean" 31 | } 32 | 33 | simulator { 34 | // TODO: define status and reply messages here 35 | } 36 | 37 | tiles(scale: 2) { 38 | 39 | multiAttributeTile(name:"lastAction", type: "generic", width: 6, height: 4){ 40 | tileAttribute ("device.battery", key: "SECONDARY_CONTROL") { 41 | attributeState "battery", label: '${currentValue}%',icon: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/develop/resources/devicetype-icons/battery050.png" 42 | } 43 | tileAttribute ("device.lastAction", key: "PRIMARY_CONTROL") { 44 | attributeState "active", label:'${currentValue}', icon:"st.Home.home30" 45 | } 46 | } 47 | 48 | valueTile("battery", "device.battery", decoration: "flat", inactiveLabel: false, width: 5, height: 1) { 49 | state("battery", label:'${currentValue}% battery', unit:"") 50 | } 51 | standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 1, height: 1) { 52 | state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" 53 | } 54 | 55 | main "lastAction" 56 | details(["lastAction","battery","refresh","configure"]) 57 | } 58 | 59 | preferences { 60 | input description: "The settings below allow the button to be returned as 1,2,3,4 as required for Smart Apps or 'on','up','down','off' as per original device handler.", type: "paragraph", element: "paragraph", title: "BUTTON NAMES" 61 | input "buttonNames", "bool", title:"Button Names - Use 1,2,3,4", description:"Use Button Numbers for Smart Apps" 62 | } 63 | } 64 | 65 | // parse events into attributes 66 | def parse(String description) { 67 | def msg = zigbee.parse(description) 68 | 69 | //log.warn msg 70 | /// Actual code down here 71 | List map = [] 72 | if (description?.startsWith('catchall:')) { 73 | map = parseCatchAllMessage(description) 74 | } 75 | 76 | def result = map ? map : null 77 | 78 | if (description?.startsWith('enroll request')) { 79 | List cmds = enrollResponse() 80 | result = cmds?.collect { new physicalgraph.device.HubAction(it) } 81 | } 82 | else if (description?.startsWith('read attr -')) { 83 | result = parseReportAttributeMessage(description).each { createEvent(it) } 84 | } 85 | return result 86 | } 87 | 88 | private List parseReportAttributeMessage(String description) { 89 | Map descMap = (description - "read attr - ").split(",").inject([:]) { map, param -> 90 | def nameAndValue = param.split(":") 91 | map += [(nameAndValue[0].trim()):nameAndValue[1].trim()] 92 | } 93 | 94 | List result = [] 95 | 96 | // Battery 97 | if (descMap.cluster == "0001" && descMap.attrId == "0020") { 98 | // log.warn descMap 99 | result << getBatteryResult(Integer.parseInt(descMap.value, 16)) 100 | } 101 | 102 | return result 103 | } 104 | 105 | private boolean shouldProcessMessage(cluster) { 106 | // 0x0B is default response indicating message got through 107 | boolean ignoredMessage = cluster.profileId != 0x0104 || 108 | cluster.command == 0x0B || 109 | (cluster.data.size() > 0 && cluster.data.first() == 0x3e) 110 | return !ignoredMessage 111 | } 112 | 113 | /* 114 | getBatteryResult 115 | */ 116 | //TODO: needs calibration 117 | private Map getBatteryResult(rawValue) { 118 | //log.debug "Battery rawValue = ${rawValue}" 119 | 120 | def result = [ 121 | name: 'battery', 122 | value: '--', 123 | translatable: true 124 | ] 125 | 126 | def volts = rawValue / 10 127 | 128 | if (rawValue == 0 || rawValue == 255) {} 129 | else { 130 | if (volts > 3.5) { 131 | result.descriptionText = "{{ device.displayName }} battery has too much power: (> 3.5) volts." 132 | } 133 | else { 134 | if (device.getDataValue("manufacturer") == "SmartThings") { 135 | volts = rawValue // For the batteryMap to work the key needs to be an int 136 | def batteryMap = [28:100, 27:100, 26:100, 25:90, 24:90, 23:70, 137 | 22:70, 21:50, 20:50, 19:30, 18:30, 17:15, 16:1, 15:0] 138 | def minVolts = 15 139 | def maxVolts = 28 140 | 141 | if (volts < minVolts) 142 | volts = minVolts 143 | else if (volts > maxVolts) 144 | volts = maxVolts 145 | def pct = batteryMap[volts] 146 | if (pct != null) { 147 | result.value = pct 148 | result.descriptionText = "{{ device.displayName }} battery was {{ value }}%" 149 | } 150 | } 151 | else { 152 | def minVolts = 2.1 153 | def maxVolts = 3.0 154 | def pct = (volts - minVolts) / (maxVolts - minVolts) 155 | def roundedPct = Math.round(pct * 100) 156 | if (roundedPct <= 0) 157 | roundedPct = 1 158 | result.value = Math.min(100, roundedPct) 159 | result.descriptionText = "{{ device.displayName }} battery was {{ value }}%" 160 | } 161 | } 162 | } 163 | 164 | return result 165 | } 166 | 167 | private List getButtonResult(rawValue) { 168 | def result 169 | def button = rawValue[0] 170 | def buttonState = rawValue[4] 171 | def buttonHoldTime = rawValue[6] 172 | def hueStatus = (button as String) + "00" + (buttonState as String) // This is the state in the HUE api 173 | log.info "Button: " + button + " Hue Code: " + hueStatus + " Hold Time: " + buttonHoldTime + " Button State: " + buttonState 174 | // result.data = ['buttonNumber': button] 175 | 176 | def buttonValue=["on","up","down", "off"] 177 | sendEvent(name: "buttonNames", value: buttonNames) 178 | def buttonName= (buttonNames)? "$button" : buttonValue[button-1] 179 | def buttonTitle= buttonValue[button-1] 180 | log.info "Button Names: $buttonNames : $buttonName" 181 | 182 | // The button is pressed, aka: pushed + released, with 0 hold time 183 | if ( buttonState == 0 ) { 184 | result = [createEvent(name: "button", value: "pressed" , data: [buttonNumber: buttonName], descriptionText: "$device.displayName button $button was pushed", isStateChange: true)] 185 | sendEvent(name: "lastAction", value: buttonTitle + " pressed") 186 | } 187 | // The button is pressed, aka: pushed + released, with at least 1s hold time 188 | else if ( buttonState == 2 ) { 189 | result = [ 190 | createEvent(name: "button", value: "pushed" , data: [buttonNumber: buttonName], descriptionText: "$device.displayName button $button was pushed", isStateChange: true), 191 | createEvent(name: "button", value: "released" , data: [buttonNumber: buttonName], descriptionText: "$device.displayName button $button was pushed", isStateChange: true) 192 | ] 193 | sendEvent(name: "lastAction", value: buttonTitle + " pushed") 194 | sendEvent(name: "lastAction", value: buttonTitle + " released") 195 | } 196 | // The button is released, with at least 1s hold time. This code happens after the button is held 197 | else if ( buttonState == 3 ) { 198 | result = [ 199 | createEvent(name: "button", value: "released", data: [buttonNumber: buttonName], descriptionText: "$device.displayName button $button was pushed", isStateChange: true) 200 | ] 201 | sendEvent(name: "lastAction", value: buttonTitle + " released") 202 | } 203 | // The button is held 204 | else if ( buttonHoldTime == 8 ) { 205 | result = [createEvent(name: "button", value: "held", data: [buttonNumber: buttonName], descriptionText: "$device.displayName button $button was held", isStateChange: true)] 206 | sendEvent(name: "lastAction", value: buttonTitle + " held") 207 | } 208 | else { 209 | return 210 | } 211 | return result 212 | 213 | } 214 | 215 | /* 216 | parseCatchAllMessage 217 | */ 218 | private List parseCatchAllMessage(String description) { 219 | List resultMap = [] 220 | def cluster = zigbee.parse(description) 221 | if (shouldProcessMessage(cluster)) { 222 | switch(cluster.clusterId) { 223 | case 0x0001: 224 | // 0x07 - configure reporting 225 | if (cluster.command != 0x07) { 226 | resultMap = [getBatteryResult(cluster.data.last())] 227 | } 228 | break 229 | 230 | case 0xFC00: 231 | if ( cluster.command == 0x00 ) { 232 | resultMap = getButtonResult( cluster.data ); 233 | } 234 | break 235 | 236 | } 237 | } 238 | 239 | return resultMap 240 | } 241 | 242 | 243 | def refresh() { 244 | //log.debug "Refresh" 245 | 246 | def refreshCmds = [] 247 | 248 | refreshCmds += "st rattr 0x${device.deviceNetworkId} 0x02 0x0001 0x0020"; // WORKS! - Fetches battery from 0x02 249 | 250 | 251 | // configCmds += zigbee.configureReporting(0x406,0x0000, 0x18, 30, 600, null) // motion // confirmed 252 | 253 | //refreshCmds += zigbee.configureReporting(0x000F, 0x0055, 0x10, 30, 30, null); 254 | // refreshCmds += "zdo bind 0xDAD6 0x01 0x02 0x000F {00178801103317AA} {}" 255 | // refreshCmds += "delay 2000" 256 | // refreshCmds += "st cr 0xDAD6 0x02 0x000F 0x0055 0x10 0x001E 0x001E {}" 257 | // refreshCmds += "delay 2000" 258 | 259 | //refreshCmds += zigbee.configureReporting(0x000F, 0x006F, 0x18, 0x30, 0x30); 260 | // refreshCmds += "zdo bind 0x${device.deviceNetworkId} 0x02 0x02 0xFC00 {${device.zigbeeId}} {}" 261 | // refreshCmds += "delay 2000" 262 | // refreshCmds += "st cr 0x${device.deviceNetworkId} 0x02 0xFC00 0x0000 0x18 0x001E 0x001E {}" 263 | // refreshCmds += "delay 2000" 264 | //log.debug refreshCmds 265 | 266 | return refreshCmds 267 | } 268 | 269 | def configure() { 270 | // String zigbeeId = swapEndianHex(device.hub.zigbeeId) 271 | //log.debug "Configuring Reporting and Bindings." 272 | def configCmds = [] 273 | 274 | // Configure Button Count 275 | sendEvent(name: "numberOfButtons", value: 4, displayed: false) 276 | 277 | // Monitor Buttons 278 | //TODO: This could be zigbee.configureReporting(0xFC00, 0x0000, 0x18, 0x001e, 0x001e); but no idea how to point it at a different endpoint 279 | configCmds += "zdo bind 0x${device.deviceNetworkId} 0x02 0x02 0xFC00 {${device.zigbeeId}} {}" 280 | configCmds += "delay 2000" 281 | configCmds += "st cr 0x${device.deviceNetworkId} 0x02 0xFC00 0x0000 0x18 0x001E 0x001E {}" 282 | configCmds += "delay 2000" 283 | 284 | // Monitor Battery 285 | //TODO: This could be zigbee.batteryConfig(); but no idea how to point it at a different endpoint 286 | configCmds += "zdo bind 0x${device.deviceNetworkId} 0x02 0x02 0x0001 {${device.zigbeeId}} {}" 287 | configCmds += "delay 2000" 288 | configCmds += "st cr 0x${device.deviceNetworkId} 0x02 0x0001 0x0020 0x20 0x001E 0x0258 {}" 289 | // configCmds += "st cr 0x${device.deviceNetworkId} 0x02 0x0001 0x0020 0x20 0x001E 0x001e {}" 290 | 291 | configCmds += "delay 2000" 292 | return configCmds + refresh() 293 | } 294 | 295 | def configureHealthCheck() { 296 | Integer hcIntervalMinutes = 12 297 | refresh() 298 | sendEvent(name: "checkInterval", value: hcIntervalMinutes * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) 299 | } 300 | 301 | def updated() { 302 | configureHealthCheck() 303 | } -------------------------------------------------------------------------------- /devicetypes/paulsheldon/lightify-bulb.src/lightify-bulb.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Osram Lightify Bulb (Color Temp Adjustable) 3 | * 4 | * Copyright 2014 SmartThings 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | * Original Code by Scott Gibson 16 | * 17 | * == Changes - ABC Version Maintained by Paul Sheldon == 18 | * 2020-05-05 Renamed to Lightify Bulb - ABC Version v1.20200505 19 | * Added Color Temperature Capability 20 | * Renamed ColorTemp Attribute to ColorTemperature 21 | * Renamed Command to setColorTemperature as per SmartThings Docs 22 | * Altered Temp Colours to match ABC Controller 23 | */ 24 | 25 | metadata { 26 | definition (name: "Lightify-Bulb", namespace: "paulsheldon", author: "Paul Sheldon") { 27 | 28 | capability "Actuator" 29 | capability "Configuration" 30 | capability "Refresh" 31 | capability "Switch" 32 | capability "Switch Level" 33 | capability "Color Temperature" 34 | 35 | command "setColorTemperature" 36 | 37 | attribute "colorTemperature", "string" 38 | attribute "kelvin", "string" 39 | attribute "bulbTemp", "string" 40 | 41 | fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019" 42 | } 43 | 44 | // simulator metadata 45 | simulator { 46 | // status messages 47 | status "on": "on/off: 1" 48 | status "off": "on/off: 0" 49 | 50 | // reply messages 51 | reply "zcl on-off on": "on/off: 1" 52 | reply "zcl on-off off": "on/off: 0" 53 | } 54 | 55 | // UI tile definitions 56 | tiles { 57 | standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) { 58 | state "off", label: '${name}', action: "switch.on", icon: "st.switches.light.off", backgroundColor: "#ffffff" 59 | state "on", label: '${name}', action: "switch.off", icon: "st.switches.light.on", backgroundColor: "#79b821" 60 | } 61 | standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") { 62 | state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" 63 | } 64 | controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false) { 65 | state "level", action:"switch level.setLevel" 66 | } 67 | controlTile("colorSliderControl", "device.colorTemperature", "slider", height: 1, width: 2, inactiveLabel: false, range: "(2700..6500)") { 68 | state "colorTemperature", action:"setColorTemperature" 69 | } 70 | valueTile("kelvin", "device.kelvin", inactiveLabel: false, decoration: "flat") { 71 | state "kelvin", label: 'Temp ${currentValue}K' 72 | } 73 | valueTile("bulbTemp", "device.bulbTemp", inactiveLabel: false, decoration: "flat") { 74 | state "bulbTemp", label: '${currentValue}' 75 | } 76 | valueTile("level", "device.level", inactiveLabel: false, decoration: "flat") { 77 | state "level", label: 'Level ${currentValue}%' 78 | } 79 | valueTile("level", "device.level", inactiveLabel: false, decoration: "flat") { 80 | state "level", label: 'Level ${currentValue}%' 81 | } 82 | 83 | 84 | main(["switch"]) 85 | details(["switch", "bulbTemp", "refresh", "levelSliderControl", "level", "colorSliderControl", "kelvin"]) 86 | } 87 | } 88 | 89 | // Parse incoming device messages to generate events 90 | 91 | def parse(String description) { 92 | log.trace description 93 | def msg = zigbee.parse(description) 94 | 95 | if (description?.startsWith("catchall:")) { 96 | 97 | log.trace msg 98 | log.trace "data: $msg.data" 99 | 100 | if(description?.endsWith("0100") ||description?.endsWith("1001")) 101 | { 102 | def result = createEvent(name: "switch", value: "on") 103 | log.debug "Parse returned ${result?.descriptionText}" 104 | return result 105 | } 106 | 107 | if(description?.endsWith("0000") || description?.endsWith("1000")) 108 | { 109 | def result = createEvent(name: "switch", value: "off") 110 | log.debug "Parse returned ${result?.descriptionText}" 111 | return result 112 | } 113 | } 114 | 115 | 116 | if (description?.startsWith("read attr")) { 117 | 118 | Map descMap = (description - "read attr - ").split(",").inject([:]) { map, param -> 119 | def nameAndValue = param.split(":") 120 | map += [(nameAndValue[0].trim()):nameAndValue[1].trim()] 121 | } 122 | 123 | log.debug "Desc Map: $descMap" 124 | 125 | switch (descMap.cluster) { 126 | 127 | case "0008": 128 | 129 | log.debug description[-2..-1] 130 | def i = Math.round(convertHexToInt(descMap.value) / 256 * 100 ) 131 | sendEvent( name: "level", value: i ) 132 | sendEvent( name: "switch.setLevel", value: i) //added to help subscribers 133 | break 134 | 135 | case "0300": 136 | 137 | log.debug descMap.value 138 | def i = Math.round( 1000000 / convertHexToInt(descMap.value)) 139 | def j = i 140 | def bTemp = getBulbTemp(j) 141 | sendEvent( name: "colorTemp", value: j) 142 | sendEvent( name: "kelvin", value: i) 143 | sendEvent( name: "bulbTemp", value: bTemp) 144 | break 145 | } 146 | 147 | } 148 | 149 | 150 | } 151 | 152 | def on() { 153 | log.debug "on()" 154 | sendEvent(name: "switch", value: "on") 155 | 156 | "st cmd 0x${device.deviceNetworkId} ${endpointId} 6 1 {}" 157 | } 158 | 159 | def off() { 160 | log.debug "off()" 161 | sendEvent(name: "switch", value: "off") 162 | sendEvent(name: "level", value: 99) 163 | "st cmd 0x${device.deviceNetworkId} ${endpointId} 6 0 {}" 164 | 165 | } 166 | 167 | def refresh() { 168 | 169 | [ 170 | "st rattr 0x${device.deviceNetworkId} ${endpointId} 6 0", "delay 500", 171 | "st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0", "delay 500", 172 | "st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0300 7" 173 | ] 174 | } 175 | 176 | def setLevel(value) { 177 | log.trace "setLevel($value)" 178 | def cmds = [] 179 | 180 | if (value == 0) { 181 | sendEvent(name: "switch", value: "off") 182 | sendEvent(name: "level", value: 99) 183 | cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 6 0 {}" 184 | } 185 | else if (device.latestValue("switch") == "off") { 186 | sendEvent(name: "switch", value: "on") 187 | } 188 | 189 | sendEvent(name: "level", value: value) 190 | def level = hex(value * 255 / 100) 191 | cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 8 4 {${level} 1500}" 192 | 193 | //log.debug cmds 194 | cmds 195 | } 196 | 197 | def setColorTemperature(value) { 198 | 199 | log.trace "setColorTemperature($value)" 200 | if (value < 2700) { value = 2700 } 201 | if (value > 6500) { value = 6500 } 202 | log.trace "Color Temperature($value)" 203 | 204 | def degrees = Math.round(value) 205 | log.trace degrees 206 | 207 | def bulbTemp = getBulbTemp(degrees) 208 | log.trace bulbTemp 209 | 210 | 211 | 212 | def cmds = [] 213 | sendEvent(name: "colorTemperature", value: value) 214 | sendEvent(name: "kelvin", value: degrees) 215 | sendEvent( name: "bulbTemp", value: bulbTemp) 216 | 217 | def levelC = swapEndianHex(hexSixteen(1000000/degrees)) 218 | 219 | log.trace levelC 220 | 221 | cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x0300 0x0a {${levelC} 2000}" 222 | 223 | //log.debug cmds 224 | cmds 225 | } 226 | 227 | def updated() { 228 | 229 | /* 230 | [ 231 | "st wattr 0x${device.deviceNetworkId} ${endpointId} 8 0x10 0x21 {0015}", "delay 500", 232 | "st wattr 0x${device.deviceNetworkId} ${endpointId} 8 0x11 0x20 {fe}" 233 | ] 234 | */ 235 | 236 | } 237 | 238 | def configure() { 239 | 240 | String zigbeeId = swapEndianHex(device.hub.zigbeeId) 241 | log.debug "Configuration Reporting and Bindings." 242 | def configCmds = [ 243 | 244 | //Switch Reporting 245 | "zcl global send-me-a-report 6 0 0x10 0 3600 {01}", "delay 500", 246 | "send 0x${device.deviceNetworkId} ${endpointId} 1", "delay 1000", 247 | 248 | //Level Control Reporting 249 | "zcl global send-me-a-report 8 0 0x20 5 3600 {0010}", "delay 200", 250 | "send 0x${device.deviceNetworkId} ${endpointId} 1", "delay 1500", 251 | 252 | //Color Temp Reporting 253 | "zcl global send-me-a-report 0x0300 7 0x21 5 3600 {0010}", "delay 200", 254 | "send 0x${device.deviceNetworkId} ${endpointId} 1", "delay 1500", 255 | 256 | "zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 6 {${device.zigbeeId}} {}", "delay 1000", 257 | "zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 8 {${device.zigbeeId}} {}", "delay 1000", 258 | "zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 0x0300 {${device.zigbeeId}} {}", "delay 500", 259 | ] 260 | return configCmds + refresh() // send refresh cmds as part of config 261 | } 262 | 263 | def uninstalled() { 264 | 265 | log.debug "uninstalled()" 266 | 267 | response("zcl rftd") 268 | 269 | } 270 | 271 | private getBulbTemp(value) { 272 | if (value != null) { 273 | if (value <2500) return "Warm Glow" 274 | else if (value <3000) return "Warm White" 275 | else if (value < 5000) return "Cool White" 276 | else if (value < 6000) return "Daylight" 277 | else return "Cool Daylight" 278 | } 279 | return "White" 280 | } 281 | 282 | private getEndpointId() { 283 | new BigInteger(device.endpointId, 16).toString() 284 | } 285 | 286 | 287 | 288 | private hex(value, width=2) { 289 | def s = new BigInteger(Math.round(value).toString()).toString(16) 290 | while (s.size() < width) { 291 | s = "0" + s 292 | } 293 | s 294 | } 295 | 296 | private hexSixteen(value, width=4) { 297 | def s = new BigInteger(Math.round(value).toString()).toString(16) 298 | while (s.size() < width) { 299 | s = "0" + s 300 | } 301 | s 302 | } 303 | 304 | private Integer convertHexToInt(hex) { 305 | Integer.parseInt(hex,16) 306 | } 307 | 308 | private String swapEndianHex(String hex) { 309 | reverseArray(hex.decodeHex()).encodeHex() 310 | } 311 | 312 | private byte[] reverseArray(byte[] array) { 313 | int i = 0; 314 | int j = array.length - 1; 315 | byte tmp; 316 | while (j > i) { 317 | tmp = array[j]; 318 | array[j] = array[i]; 319 | array[i] = tmp; 320 | j--; 321 | i++; 322 | } 323 | return array 324 | } 325 | -------------------------------------------------------------------------------- /devicetypes/paulsheldon/zigbee-switch-power.src/zigbee-switch-power.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 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 | * Updated to add Salus SP600 Smart Plug 14 | */ 15 | 16 | metadata { 17 | definition (name: "ZigBee Switch Power", namespace: "paulsheldon", author: "SmartThings", ocfDeviceType: "oic.d.switch", runLocally: false, minHubCoreVersion: '000.019.00012', executeCommandsLocally: true) { 18 | capability "Actuator" 19 | capability "Configuration" 20 | capability "Refresh" 21 | capability "Power Meter" 22 | capability "Sensor" 23 | capability "Switch" 24 | 25 | fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0B04" 26 | fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702" 27 | fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702, 0B05", outClusters: "0003, 000A, 0019", manufacturer: "Jasco Products", model: "45853", deviceJoinName: "GE ZigBee Plug-In Switch" 28 | fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702, 0B05", outClusters: "000A, 0019", manufacturer: "Jasco Products", model: "45856", deviceJoinName: "GE ZigBee In-Wall Switch" 29 | fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 000F, 0B04", outClusters: "0019", manufacturer: "SmartThings", model: "outletv4", deviceJoinName: "Outlet" 30 | fingerprint profileId: "0104", inClusters: "0000, 0001, 0003, 0004, 0005, 0006, 0402, 0702, FC01", outClusters: "0019", manufacturer: "Computime", model: "SP600", deviceJoinName: "Salus SP600 Smart Plug" 31 | 32 | } 33 | 34 | tiles(scale: 2) { 35 | multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){ 36 | tileAttribute ("device.switch", key: "PRIMARY_CONTROL") { 37 | attributeState "on", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"turningOff" 38 | attributeState "off", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn" 39 | attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"turningOff" 40 | attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn" 41 | } 42 | tileAttribute ("power", key: "SECONDARY_CONTROL") { 43 | attributeState "power", label:'${currentValue} W' 44 | } 45 | } 46 | standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) { 47 | state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" 48 | } 49 | main "switch" 50 | details(["switch", "refresh"]) 51 | } 52 | } 53 | 54 | // Parse incoming device messages to generate events 55 | def parse(String description) { 56 | log.debug "description is $description" 57 | 58 | def resultMap = zigbee.getKnownDescription(description) 59 | if (resultMap) { 60 | log.info resultMap 61 | if (resultMap.type == "update") { 62 | log.info "$device updates: ${resultMap.value}" 63 | } 64 | else if (resultMap.type == "power") { 65 | def powerValue 66 | if (device.getDataValue("manufacturer") != "OSRAM") { //OSRAM devices do not reliably update power 67 | powerValue = (resultMap.value as Integer)/10 //TODO: The divisor value needs to be set as part of configuration 68 | sendEvent(name: "power", value: powerValue) 69 | } 70 | } 71 | else { 72 | sendEvent(name: resultMap.type, value: resultMap.value) 73 | } 74 | } 75 | else { 76 | log.warn "DID NOT PARSE MESSAGE for description : $description" 77 | log.debug zigbee.parseDescriptionAsMap(description) 78 | } 79 | } 80 | 81 | def off() { 82 | zigbee.off() 83 | } 84 | 85 | def on() { 86 | zigbee.on() 87 | } 88 | 89 | def refresh() { 90 | zigbee.onOffRefresh() + zigbee.simpleMeteringPowerRefresh() + zigbee.electricMeasurementPowerRefresh() + zigbee.onOffConfig() + zigbee.simpleMeteringPowerConfig() + zigbee.electricMeasurementPowerConfig() 91 | } 92 | 93 | def configure() { 94 | log.debug "Configuring Reporting and Bindings." 95 | zigbee.onOffConfig() + zigbee.simpleMeteringPowerConfig() + zigbee.electricMeasurementPowerConfig() + zigbee.onOffRefresh() + zigbee.simpleMeteringPowerRefresh() + zigbee.electricMeasurementPowerRefresh() 96 | } 97 | -------------------------------------------------------------------------------- /devicetypes/scottgibson/lightify-bulb.src/lightify-bulb.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Osram Lightify Bulb (Color Temp Adjustable) 3 | * 4 | * Copyright 2014 SmartThings 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 7 | * in compliance with the License. You may obtain a copy of the License at: 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 12 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 13 | * for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | metadata { 18 | definition (name: "Lightify Bulb", namespace: "scottgibson", author: "Scott Gibson / Paul Sheldon") { 19 | 20 | capability "Actuator" 21 | capability "Configuration" 22 | capability "Refresh" 23 | capability "Switch" 24 | capability "Switch Level" 25 | 26 | command "setColorTemp" 27 | 28 | attribute "colorTemp", "string" 29 | attribute "kelvin", "string" 30 | attribute "bulbTemp", "string" 31 | 32 | fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019" 33 | } 34 | 35 | // simulator metadata 36 | simulator { 37 | // status messages 38 | status "on": "on/off: 1" 39 | status "off": "on/off: 0" 40 | 41 | // reply messages 42 | reply "zcl on-off on": "on/off: 1" 43 | reply "zcl on-off off": "on/off: 0" 44 | } 45 | 46 | // UI tile definitions 47 | tiles { 48 | standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) { 49 | state "off", label: '${name}', action: "switch.on", icon: "st.switches.light.off", backgroundColor: "#ffffff" 50 | state "on", label: '${name}', action: "switch.off", icon: "st.switches.light.on", backgroundColor: "#79b821" 51 | } 52 | standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") { 53 | state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" 54 | } 55 | controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false) { 56 | state "level", action:"switch level.setLevel" 57 | } 58 | controlTile("colorSliderControl", "device.colorTemp", "slider", height: 1, width: 2, inactiveLabel: false, range: "(2700..6500)") { 59 | state "colorTemp", action:"setColorTemp" 60 | } 61 | valueTile("kelvin", "device.kelvin", inactiveLabel: false, decoration: "flat") { 62 | state "kelvin", label: 'Temp ${currentValue}K' 63 | } 64 | valueTile("bulbTemp", "device.bulbTemp", inactiveLabel: false, decoration: "flat") { 65 | state "bulbTemp", label: '${currentValue}' 66 | } 67 | valueTile("level", "device.level", inactiveLabel: false, decoration: "flat") { 68 | state "level", label: 'Level ${currentValue}%' 69 | } 70 | 71 | 72 | main(["switch"]) 73 | details(["switch", "bulbTemp", "refresh", "levelSliderControl", "level", "colorSliderControl", "kelvin"]) 74 | } 75 | } 76 | 77 | // Parse incoming device messages to generate events 78 | 79 | def parse(String description) { 80 | log.trace description 81 | def msg = zigbee.parse(description) 82 | 83 | if (description?.startsWith("catchall:")) { 84 | 85 | log.trace msg 86 | log.trace "data: $msg.data" 87 | 88 | if(description?.endsWith("0100") ||description?.endsWith("1001")) 89 | { 90 | def result = createEvent(name: "switch", value: "on") 91 | log.debug "Parse returned ${result?.descriptionText}" 92 | return result 93 | } 94 | 95 | if(description?.endsWith("0000") || description?.endsWith("1000")) 96 | { 97 | def result = createEvent(name: "switch", value: "off") 98 | log.debug "Parse returned ${result?.descriptionText}" 99 | return result 100 | } 101 | } 102 | 103 | 104 | if (description?.startsWith("read attr")) { 105 | 106 | Map descMap = (description - "read attr - ").split(",").inject([:]) { map, param -> 107 | def nameAndValue = param.split(":") 108 | map += [(nameAndValue[0].trim()):nameAndValue[1].trim()] 109 | } 110 | 111 | log.debug "Desc Map: $descMap" 112 | 113 | switch (descMap.cluster) { 114 | 115 | case "0008": 116 | 117 | log.debug description[-2..-1] 118 | def i = Math.round(convertHexToInt(descMap.value) / 256 * 100 ) 119 | sendEvent( name: "level", value: i ) 120 | sendEvent( name: "switch.setLevel", value: i) //added to help subscribers 121 | break 122 | 123 | case "0300": 124 | 125 | log.debug descMap.value 126 | def i = Math.round( 1000000 / convertHexToInt(descMap.value)) 127 | def j = i 128 | def bTemp = getBulbTemp(j) 129 | sendEvent( name: "colorTemp", value: j) 130 | sendEvent( name: "kelvin", value: i) 131 | sendEvent( name: "bulbTemp", value: bTemp) 132 | break 133 | } 134 | 135 | } 136 | 137 | 138 | } 139 | 140 | def on() { 141 | log.debug "on()" 142 | sendEvent(name: "switch", value: "on") 143 | 144 | "st cmd 0x${device.deviceNetworkId} ${endpointId} 6 1 {}" 145 | } 146 | 147 | def off() { 148 | log.debug "off()" 149 | sendEvent(name: "switch", value: "off") 150 | sendEvent(name: "level", value: 99) 151 | "st cmd 0x${device.deviceNetworkId} ${endpointId} 6 0 {}" 152 | 153 | } 154 | 155 | def refresh() { 156 | 157 | [ 158 | "st rattr 0x${device.deviceNetworkId} ${endpointId} 6 0", "delay 500", 159 | "st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0", "delay 500", 160 | "st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0300 7" 161 | ] 162 | } 163 | 164 | def setLevel(value) { 165 | log.trace "setLevel($value)" 166 | def cmds = [] 167 | 168 | if (value == 0) { 169 | sendEvent(name: "switch", value: "off") 170 | sendEvent(name: "level", value: 99) 171 | cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 6 0 {}" 172 | } 173 | else if (device.latestValue("switch") == "off") { 174 | sendEvent(name: "switch", value: "on") 175 | } 176 | 177 | sendEvent(name: "level", value: value) 178 | def level = hex(value * 255 / 100) 179 | cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 8 4 {${level} 1500}" 180 | 181 | //log.debug cmds 182 | cmds 183 | } 184 | 185 | def setColorTemp(value) { 186 | 187 | log.trace "setColorTemp($value)" 188 | 189 | 190 | 191 | def degrees = Math.round(value) 192 | if (degrees < 2700) { degrees = 2700 } 193 | if (degrees > 6500) { degrees = 6500 } 194 | 195 | def bTemp = getBulbTemp(degrees) 196 | 197 | log.trace degrees 198 | 199 | def cmds = [] 200 | 201 | sendEvent(name: "colorTemp", value: value) 202 | sendEvent(name: "kelvin", value: degrees) 203 | sendEvent( name: "bulbTemp", value: bTemp) 204 | 205 | def levelC = swapEndianHex(hexSixteen(1000000/degrees)) 206 | 207 | log.trace levelC 208 | 209 | cmds << "st cmd 0x${device.deviceNetworkId} ${endpointId} 0x0300 0x0a {${levelC} 2000}" 210 | 211 | //log.debug cmds 212 | cmds 213 | } 214 | 215 | def updated() { 216 | 217 | /* 218 | [ 219 | "st wattr 0x${device.deviceNetworkId} ${endpointId} 8 0x10 0x21 {0015}", "delay 500", 220 | "st wattr 0x${device.deviceNetworkId} ${endpointId} 8 0x11 0x20 {fe}" 221 | ] 222 | */ 223 | 224 | } 225 | 226 | def configure() { 227 | 228 | String zigbeeId = swapEndianHex(device.hub.zigbeeId) 229 | log.debug "Confuguring Reporting and Bindings." 230 | def configCmds = [ 231 | 232 | //Switch Reporting 233 | "zcl global send-me-a-report 6 0 0x10 0 3600 {01}", "delay 500", 234 | "send 0x${device.deviceNetworkId} ${endpointId} 1", "delay 1000", 235 | 236 | //Level Control Reporting 237 | "zcl global send-me-a-report 8 0 0x20 5 3600 {0010}", "delay 200", 238 | "send 0x${device.deviceNetworkId} ${endpointId} 1", "delay 1500", 239 | 240 | //Color Temp Reporting 241 | "zcl global send-me-a-report 0x0300 7 0x21 5 3600 {0010}", "delay 200", 242 | "send 0x${device.deviceNetworkId} ${endpointId} 1", "delay 1500", 243 | 244 | "zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 6 {${device.zigbeeId}} {}", "delay 1000", 245 | "zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 8 {${device.zigbeeId}} {}", "delay 1000", 246 | "zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 0x0300 {${device.zigbeeId}} {}", "delay 500", 247 | ] 248 | return configCmds + refresh() // send refresh cmds as part of config 249 | } 250 | 251 | def uninstalled() { 252 | 253 | log.debug "uninstalled()" 254 | 255 | response("zcl rftd") 256 | 257 | } 258 | 259 | private getBulbTemp(value) { 260 | 261 | def s = "Soft White" 262 | 263 | if (value < 2901) { 264 | return s 265 | } 266 | else if (value < 3376) { 267 | s = "Warm White" 268 | return s 269 | } 270 | else if (value < 3916) { 271 | s = "Cool White" 272 | return s 273 | } 274 | else if (value < 4601) { 275 | s = "Bright White" 276 | return s 277 | } 278 | else if (value < 5751) { 279 | s = "Natural" 280 | return s 281 | } 282 | else { 283 | s = "Daylight" 284 | return s 285 | } 286 | 287 | } 288 | 289 | private getEndpointId() { 290 | new BigInteger(device.endpointId, 16).toString() 291 | } 292 | 293 | 294 | 295 | private hex(value, width=2) { 296 | def s = new BigInteger(Math.round(value).toString()).toString(16) 297 | while (s.size() < width) { 298 | s = "0" + s 299 | } 300 | s 301 | } 302 | 303 | private hexSixteen(value, width=4) { 304 | def s = new BigInteger(Math.round(value).toString()).toString(16) 305 | while (s.size() < width) { 306 | s = "0" + s 307 | } 308 | s 309 | } 310 | 311 | private Integer convertHexToInt(hex) { 312 | Integer.parseInt(hex,16) 313 | } 314 | 315 | private String swapEndianHex(String hex) { 316 | reverseArray(hex.decodeHex()).encodeHex() 317 | } 318 | 319 | private byte[] reverseArray(byte[] array) { 320 | int i = 0; 321 | int j = array.length - 1; 322 | byte tmp; 323 | while (j > i) { 324 | tmp = array[j]; 325 | array[j] = array[i]; 326 | array[i] = tmp; 327 | j--; 328 | i++; 329 | } 330 | return array 331 | } 332 | -------------------------------------------------------------------------------- /devicetypes/smartthings/zigbee-switch-power.src/zigbee-switch-power.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 SmartThings 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 | */ 14 | 15 | metadata { 16 | definition (name: "ZigBee Switch Power", namespace: "smartthings", author: "SmartThings", ocfDeviceType: "oic.d.switch", runLocally: false, minHubCoreVersion: '000.019.00012', executeCommandsLocally: true) { 17 | capability "Actuator" 18 | capability "Configuration" 19 | capability "Refresh" 20 | capability "Power Meter" 21 | capability "Sensor" 22 | capability "Switch" 23 | 24 | fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0B04" 25 | fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702" 26 | fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702, 0B05", outClusters: "0003, 000A, 0019", manufacturer: "Jasco Products", model: "45853", deviceJoinName: "GE ZigBee Plug-In Switch" 27 | fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0702, 0B05", outClusters: "000A, 0019", manufacturer: "Jasco Products", model: "45856", deviceJoinName: "GE ZigBee In-Wall Switch" 28 | fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 000F, 0B04", outClusters: "0019", manufacturer: "SmartThings", model: "outletv4", deviceJoinName: "Outlet" 29 | fingerprint profileId: "0104", inClusters: "0000, 0001, 0003, 0004, 0005, 0006, 0402, 0702, FC01", outClusters: "0019", manufacturer: "Computime", model: "SP600", deviceJoinName: "Salus SP600 Smart Plug" 30 | 31 | } 32 | 33 | tiles(scale: 2) { 34 | multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){ 35 | tileAttribute ("device.switch", key: "PRIMARY_CONTROL") { 36 | attributeState "on", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"turningOff" 37 | attributeState "off", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn" 38 | attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"turningOff" 39 | attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn" 40 | } 41 | tileAttribute ("power", key: "SECONDARY_CONTROL") { 42 | attributeState "power", label:'${currentValue} W' 43 | } 44 | } 45 | standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) { 46 | state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" 47 | } 48 | main "switch" 49 | details(["switch", "refresh"]) 50 | } 51 | } 52 | 53 | // Parse incoming device messages to generate events 54 | def parse(String description) { 55 | log.debug "description is $description" 56 | 57 | def resultMap = zigbee.getKnownDescription(description) 58 | if (resultMap) { 59 | log.info resultMap 60 | if (resultMap.type == "update") { 61 | log.info "$device updates: ${resultMap.value}" 62 | } 63 | else if (resultMap.type == "power") { 64 | def powerValue 65 | if (device.getDataValue("manufacturer") != "OSRAM") { //OSRAM devices do not reliably update power 66 | powerValue = (resultMap.value as Integer)/10 //TODO: The divisor value needs to be set as part of configuration 67 | sendEvent(name: "power", value: powerValue) 68 | } 69 | } 70 | else { 71 | sendEvent(name: resultMap.type, value: resultMap.value) 72 | } 73 | } 74 | else { 75 | log.warn "DID NOT PARSE MESSAGE for description : $description" 76 | log.debug zigbee.parseDescriptionAsMap(description) 77 | } 78 | } 79 | 80 | def off() { 81 | zigbee.off() 82 | } 83 | 84 | def on() { 85 | zigbee.on() 86 | } 87 | 88 | def refresh() { 89 | zigbee.onOffRefresh() + zigbee.simpleMeteringPowerRefresh() + zigbee.electricMeasurementPowerRefresh() + zigbee.onOffConfig() + zigbee.simpleMeteringPowerConfig() + zigbee.electricMeasurementPowerConfig() 90 | } 91 | 92 | def configure() { 93 | log.debug "Configuring Reporting and Bindings." 94 | zigbee.onOffConfig() + zigbee.simpleMeteringPowerConfig() + zigbee.electricMeasurementPowerConfig() + zigbee.onOffRefresh() + zigbee.simpleMeteringPowerRefresh() + zigbee.electricMeasurementPowerRefresh() 95 | } 96 | -------------------------------------------------------------------------------- /resources/abc/images/AeonMinimote1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/AeonMinimote1.png -------------------------------------------------------------------------------- /resources/abc/images/AeonMinimote2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/AeonMinimote2.png -------------------------------------------------------------------------------- /resources/abc/images/AeonMinimote3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/AeonMinimote3.png -------------------------------------------------------------------------------- /resources/abc/images/AeonMinimote4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/AeonMinimote4.png -------------------------------------------------------------------------------- /resources/abc/images/CubeController1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/CubeController1.png -------------------------------------------------------------------------------- /resources/abc/images/CubeController2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/CubeController2.png -------------------------------------------------------------------------------- /resources/abc/images/CubeController3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/CubeController3.png -------------------------------------------------------------------------------- /resources/abc/images/CubeController4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/CubeController4.png -------------------------------------------------------------------------------- /resources/abc/images/CubeController5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/CubeController5.png -------------------------------------------------------------------------------- /resources/abc/images/CubeController6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/CubeController6.png -------------------------------------------------------------------------------- /resources/abc/images/CubeController7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/CubeController7.png -------------------------------------------------------------------------------- /resources/abc/images/HueDimmer1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/HueDimmer1.png -------------------------------------------------------------------------------- /resources/abc/images/HueDimmer2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/HueDimmer2.png -------------------------------------------------------------------------------- /resources/abc/images/HueDimmer3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/HueDimmer3.png -------------------------------------------------------------------------------- /resources/abc/images/HueDimmer4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/HueDimmer4.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliDimmerNZW31wScene1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliDimmerNZW31wScene1.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliDimmerNZW31wScene2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliDimmerNZW31wScene2.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliDimmerNZW31wScene3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliDimmerNZW31wScene3.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliDimmerNZW31wScene4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliDimmerNZW31wScene4.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliDimmerNZW31wScene5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliDimmerNZW31wScene5.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliDimmerNZW31wScene6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliDimmerNZW31wScene6.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliRed1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliRed1.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliRed2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliRed2.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliRed3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliRed3.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliRed4 .png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliRed4 .png -------------------------------------------------------------------------------- /resources/abc/images/InovelliRed5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliRed5.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliRed6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliRed6.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliRed7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliRed7.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliSwitchNZW30wScene1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliSwitchNZW30wScene1.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliSwitchNZW30wScene2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliSwitchNZW30wScene2.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliSwitchNZW30wScene3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliSwitchNZW30wScene3.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliSwitchNZW30wScene4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliSwitchNZW30wScene4.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliSwitchNZW30wScene5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliSwitchNZW30wScene5.png -------------------------------------------------------------------------------- /resources/abc/images/InovelliSwitchNZW30wScene6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/InovelliSwitchNZW30wScene6.png -------------------------------------------------------------------------------- /resources/abc/images/LutronPico1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/LutronPico1.png -------------------------------------------------------------------------------- /resources/abc/images/LutronPico2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/LutronPico2.png -------------------------------------------------------------------------------- /resources/abc/images/LutronPico3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/LutronPico3.png -------------------------------------------------------------------------------- /resources/abc/images/LutronPico4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/LutronPico4.png -------------------------------------------------------------------------------- /resources/abc/images/LutronPico5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/LutronPico5.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster1.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster10.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster11.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster12.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster13.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster14.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster15.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster16.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster2.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster3.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster4.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster5.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster6.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster7.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster8.png -------------------------------------------------------------------------------- /resources/abc/images/RemotecZRC90SceneMaster9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/RemotecZRC90SceneMaster9.png -------------------------------------------------------------------------------- /resources/abc/images/WD100+Dimmer1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WD100+Dimmer1.png -------------------------------------------------------------------------------- /resources/abc/images/WD100+Dimmer2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WD100+Dimmer2.png -------------------------------------------------------------------------------- /resources/abc/images/WD100+Dimmer3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WD100+Dimmer3.png -------------------------------------------------------------------------------- /resources/abc/images/WD100+Dimmer4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WD100+Dimmer4.png -------------------------------------------------------------------------------- /resources/abc/images/WD100+Dimmer5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WD100+Dimmer5.png -------------------------------------------------------------------------------- /resources/abc/images/WD100+Dimmer6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WD100+Dimmer6.png -------------------------------------------------------------------------------- /resources/abc/images/WD100+Dimmer7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WD100+Dimmer7.png -------------------------------------------------------------------------------- /resources/abc/images/WD100+Dimmer8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WD100+Dimmer8.png -------------------------------------------------------------------------------- /resources/abc/images/WS100+Switch1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WS100+Switch1.png -------------------------------------------------------------------------------- /resources/abc/images/WS100+Switch2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WS100+Switch2.png -------------------------------------------------------------------------------- /resources/abc/images/WS100+Switch3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WS100+Switch3.png -------------------------------------------------------------------------------- /resources/abc/images/WS100+Switch4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WS100+Switch4.png -------------------------------------------------------------------------------- /resources/abc/images/WS100+Switch5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WS100+Switch5.png -------------------------------------------------------------------------------- /resources/abc/images/WS100+Switch6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WS100+Switch6.png -------------------------------------------------------------------------------- /resources/abc/images/WS100+Switch7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WS100+Switch7.png -------------------------------------------------------------------------------- /resources/abc/images/WS100+Switch8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/WS100+Switch8.png -------------------------------------------------------------------------------- /resources/abc/images/abcNew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abcNew.png -------------------------------------------------------------------------------- /resources/abc/images/abc_InitialSetup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_InitialSetup.png -------------------------------------------------------------------------------- /resources/abc/images/abc_v0.1.170620.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_v0.1.170620.png -------------------------------------------------------------------------------- /resources/abc/images/abc_v0.2.180212.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_v0.2.180212.png -------------------------------------------------------------------------------- /resources/abc/images/abc_v0.2.190205.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_v0.2.190205.png -------------------------------------------------------------------------------- /resources/abc/images/abc_v0.2.190925.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_v0.2.190925.png -------------------------------------------------------------------------------- /resources/abc/images/abc_v0.3.200201.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_v0.3.200201.png -------------------------------------------------------------------------------- /resources/abc/images/abc_v1.200505.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_v1.200505.png -------------------------------------------------------------------------------- /resources/abc/images/abc_v1.200512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_v1.200512.png -------------------------------------------------------------------------------- /resources/abc/images/abc_v1.200709.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_v1.200709.png -------------------------------------------------------------------------------- /resources/abc/images/abc_v1.210602.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_v1.210602.png -------------------------------------------------------------------------------- /resources/abc/images/abc_v1.210707.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/abc_v1.210707.png -------------------------------------------------------------------------------- /resources/abc/images/update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/update.png -------------------------------------------------------------------------------- /resources/abc/images/updatea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/abc/images/updatea.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/180.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/90.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/bat_face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/bat_face.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/button_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/button_icon.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/cube_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/cube_icon.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/def_face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/def_face.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/knock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/knock.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/mi_face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/mi_face.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/mi_face_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/mi_face_s.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/rotate_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/rotate_left.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/rotate_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/rotate_right.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/shake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/shake.png -------------------------------------------------------------------------------- /resources/aquara-cube-controller/images/slide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/aquara-cube-controller/images/slide.png -------------------------------------------------------------------------------- /resources/devicetype-icons/battery000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/devicetype-icons/battery000.png -------------------------------------------------------------------------------- /resources/devicetype-icons/battery025.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/devicetype-icons/battery025.png -------------------------------------------------------------------------------- /resources/devicetype-icons/battery050.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/devicetype-icons/battery050.png -------------------------------------------------------------------------------- /resources/devicetype-icons/battery075.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/devicetype-icons/battery075.png -------------------------------------------------------------------------------- /resources/devicetype-icons/battery100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/resources/devicetype-icons/battery100.png -------------------------------------------------------------------------------- /smartapps/paulsheldon/abc-child-creator.src/abc-child-creator.groovy: -------------------------------------------------------------------------------- 1 | /* DO NOT PUBLISH !!!! 2 | * 3 | * Child Creator - Advanced Button Controller 4 | * 5 | * Author: Paul Sheldon (Original by Stephan Hackett) 6 | * 7 | * 8 | * 6/20/17 - fixed missing subs for notifications 9 | * 1/14/18 - updated Version check code 10 | * 1/15/18 - added icon support for Inovelli Switches (NZW30S and NZW31S) 11 | * - small adjustments to "Configure Button" page layout 12 | * 1/28/18 - Added Icons and details for Remote ZRC-90US Button Controller. 13 | * 2/08/18 - reformatted Button Config Preview 14 | * 2/12/18 - re-did getDescription() to only display Pushed/Held preview if it exists 15 | * restructured detailsMap and button config build for easy editing 16 | * made subValue inputs "hidden" and "required" when appropriate 17 | * 18 | * == Code now maintained by Paul Sheldon == 19 | * 2019-02-05 Added images and code for Hue Dimmer Switches & Colour Temp options 20 | * 2019-09-25 Updated volume control, play/pause, next/previous track and mute/unmute for Sonos speakers, code provided by Gabor Szabados 21 | * 2020-01-02 Added support (beta) for fan control, Inovelli Red Series Switch & Dimmer (inc config button 7) 22 | * 2020-05-05 Added support WS200 Dimmer & Switch, Ikea Buttons provided by hyvamiesh, Dimming lights does not switch light off provided by hyvamiesh 23 | * 2020-05-12 Added option to see button function in device list 24 | * 25 | * DO NOT PUBLISH !!!! 26 | */ 27 | 28 | /********************************************************************** 29 | * Define App 30 | **********************************************************************/ 31 | 32 | def version() { 33 | "v1.210707" 34 | } 35 | 36 | definition( 37 | name: "ABC Child Creator", 38 | namespace: "paulsheldon", 39 | author: "Paul Sheldon (Original by Stephan Hackett)", 40 | description: "DO NOT PUBLISH", 41 | category: "My Apps", 42 | parent: "paulsheldon:ABC Manager", 43 | iconUrl: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/abc/images/abcNew.png", 44 | iconX2Url: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/abc/images/abcNew.png", 45 | iconX3Url: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/abc/images/abcNew.png", 46 | ) 47 | 48 | preferences { 49 | page(name: "pageChooseButton",) 50 | page(name: "pageConfigButtons") 51 | page(name: "pageTimeInterval", title: "Only during a certain time") { 52 | section { 53 | input "starting", "time", title: "Starting", required: false 54 | input "ending", "time", title: "Ending", required: false 55 | } 56 | } 57 | } 58 | 59 | /********************************************************************** 60 | * Setup and Configuration Commands: 61 | **********************************************************************/ 62 | 63 | def installed() { 64 | log.info "${app.label}: Installed with settings: ${settings}" 65 | initialize() 66 | } 67 | 68 | def updated() { 69 | log.info "${app.label}: Updated with settings: ${settings}" 70 | unsubscribe() 71 | initialize() 72 | } 73 | 74 | def initialize() { 75 | log.info "${app.label}: Initialize" 76 | app.label == app.name ? app.updateLabel(defaultLabel()) : app.updateLabel(app.label) 77 | subscribe(buttonDevice, "button", buttonEvent) 78 | state.lastshadesUp = true 79 | } 80 | 81 | /********************************************************************** 82 | * Page Definitions 83 | **********************************************************************/ 84 | def pageChooseButton() { 85 | dynamicPage(name: "pageChooseButton", install: true, uninstall: true) { 86 | section("Step 1: Select Button Device") { 87 | // icon(title: "Choose an Icon", required = false) 88 | input "buttonDevice", "capability.button", title: "Button Device", multiple: false, required: true, submitOnChange: true 89 | } 90 | if (buttonDevice) { 91 | state.buttonType = getButtonType(buttonDevice.typeName) 92 | log.debug "Device Type is now set to: ${state.buttonType}" 93 | state.buttonCount = manualCount ?: buttonDevice.currentValue('numberOfButtons') 94 | 95 | log.debug "Device has ${state.buttonCount} Buttons" 96 | section("Step 2: Configure Buttons for Selected Device") { 97 | if (state.buttonCount < 1) { 98 | paragraph "The selected button device did not report the number of buttons it has. Please specify in the Advanced Config section below." 99 | } 100 | else { 101 | log.debug("Show Hardware Specs: ${showHWSpecs == true ? 'Yes' : 'No'}") 102 | for (i in 1..state.buttonCount) { 103 | href "pageConfigButtons", title: "Button ${i}" + ((showHWSpecs == true && getSpecText(i) != null) ? "\n ${getSpecText(i)}" : ""), state: getDescription(i) != "Tap to configure" ? "complete" : null, description: getDescription(i), params: [pbutton: i] 104 | } 105 | } 106 | } 107 | } 108 | section("Set Custom Name (Optional)") { 109 | label title: "Assign a name:", required: false 110 | } 111 | section("Advanced Config:", hideable: true, hidden: hideOptionsSection()) { 112 | input "manualCount", "number", title: "Set/Override # of Buttons?", required: false, description: "Only set if DTH does not report", submitOnChange: true 113 | input "collapseAll", "bool", title: "Collapse Unconfigured Sections?", defaultValue: true 114 | input "showButtonImage", "bool", title: "Show Image on Button Setup?", defaultValue: true 115 | input "showHWSpecs", "bool", title: "Show H/W Specific Details?", defaultValue: true 116 | input "fanIgnoreOff", "bool", title: "Ignore Fan Off?", defaultValue: false 117 | input "sonos", "bool", title: "Using a Sonos?", defaultValue: false 118 | } 119 | section(title: "Only Execute When:", hideable: true, hidden: hideOptionsSection()) { 120 | def timeLabel = timeIntervalLabel() 121 | href "timeIntervalInput", title: "Only during a certain time", description: timeLabel ?: "Tap to set", state: timeLabel ? "complete" : null 122 | input "days", "enum", title: "Only on certain days of the week", multiple: true, required: false, 123 | options: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] 124 | input "modes", "mode", title: "Only when mode is", multiple: true, required: false 125 | } 126 | } 127 | } 128 | 129 | def pageConfigButtons(params) { 130 | if (params.pbutton != null) state.currentButton = params.pbutton.toInteger() 131 | dynamicPage(name: "pageConfigButtons", title: "CONFIGURE BUTTON ${state.currentButton}:\n${state.buttonType}", getButtonSections(state.currentButton)) 132 | } 133 | 134 | def getButtonSections(buttonNumber) { 135 | return { 136 | def imageName = "${state.buttonType}${state.currentButton}.png" - " " - " " - " " - "/" - "-" 137 | log.debug("Button Image Name: $imageName") 138 | log.debug("Show Button Image: ${showButtonImage == true ? 'Yes' : 'No'}") 139 | if (showButtonImage == true) { 140 | section() { //"Hardware specific info on button selection:") { 141 | paragraph image: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/abc/images/${imageName}", "${getSpecText()}" 142 | } 143 | } 144 | def myDetail 145 | for (i in 1..23) {//Build 1st 23 Button Config Options 146 | myDetail = getPrefDetails().find { 147 | it.sOrder == i 148 | } 149 | section(hideable: true, hidden: !(shallHide("${myDetail.id}${buttonNumber}") || shallHide("${myDetail.sub}${buttonNumber}")), myDetail.secLabel) { 150 | input "${myDetail.id}${buttonNumber}_pushed", myDetail.cap, title: "When Pushed", multiple: true, required: false, submitOnChange: collapseAll 151 | if (myDetail.sub && isReq("${myDetail.id}${buttonNumber}_pushed")) input "${myDetail.sub}${buttonNumber}_pushed", "number", title: myDetail.sTitle, multiple: false, required: isReq("${myDetail.id}${buttonNumber}_pushed"), description: myDetail.sDesc 152 | if (showHeld()) input "${myDetail.id}${buttonNumber}_held", myDetail.cap, title: "When Held", multiple: true, required: false, submitOnChange: collapseAll 153 | if (myDetail.sub && isReq("${myDetail.id}${buttonNumber}_held")) input "${myDetail.sub}${buttonNumber}_held", "number", title: myDetail.sTitle, multiple: false, required: isReq("${myDetail.id}${buttonNumber}_held"), description: myDetail.sDesc 154 | } 155 | if ([3, 8, 10, 15, 18].contains(i)) section("") {} 156 | } 157 | section("Set Mode ", hideable: true, hidden: !shallHide("mode_${buttonNumber}")) { 158 | input "mode_${buttonNumber}_pushed", "mode", title: "When Pushed", required: false, submitOnChange: collapseAll 159 | if (showHeld()) input "mode_${buttonNumber}_held", "mode", title: "When Held", required: false, submitOnChange: collapseAll 160 | } 161 | def phrases = location.helloHome?.getPhrases()*.label 162 | if (phrases) { 163 | section("Run Routine", hideable: true, hidden: !shallHide("phrase_${buttonNumber}")) { 164 | log.trace phrases 165 | input "phrase_${buttonNumber}_pushed", "enum", title: "When Pushed", required: false, options: phrases, submitOnChange: collapseAll 166 | if (showHeld()) input "phrase_${buttonNumber}_held", "enum", title: "When Held", required: false, options: phrases, submitOnChange: collapseAll 167 | } 168 | section("Notifications: SMS, In App or Both", hideable: true, hidden: !shallHide("sms_${buttonNumber}")) { 169 | paragraph "****************\nWHEN PUSHED\n****************" 170 | input "sms_${buttonNumber}_pushed", "text", title: "Message", description: "Enter message to send", required: false, submitOnChange: collapseAll 171 | input "phoneNum_${buttonNumber}_pushed", "phone", title: "Send Text To", description: "Enter phone number", required: false, submitOnChange: collapseAll 172 | input "notify_${buttonNumber}_pushed", "bool", title: "Notify In App?", required: false, defaultValue: false, submitOnChange: collapseAll 173 | if (showHeld()) { 174 | paragraph "*************\nWHEN HELD\n*************" 175 | input "message_${buttonNumber}_held", "text", title: "Message", description: "Enter message to send", required: false, submitOnChange: collapseAll 176 | input "phoneNum_${buttonNumber}_held", "phone", title: "Send Text To", description: "Enter phone number", required: false, submitOnChange: collapseAll 177 | input "notify_${buttonNumber}_held", "bool", title: "Notify In App?", required: false, defaultValue: false, submitOnChange: collapseAll 178 | } 179 | } 180 | if (enableSpec()) { 181 | section(" ") {} 182 | section("Special", hideable: true, hidden: !shallHide("container_${buttonNumber}")) { 183 | input "container_${buttonNumber}_pushed", "device.VirtualContainer", title: "When Pushed", required: false, submitOnChange: collapseAll 184 | if (showHeld()) input "container_${buttonNumber}_held", "device.VirtualContainer", title: "When Held", required: false, submitOnChange: collapseAll 185 | } 186 | } 187 | } 188 | } 189 | } 190 | 191 | /********************************************************************** 192 | * Misc Functions 193 | **********************************************************************/ 194 | 195 | def enableSpec() { // Enable Special 196 | return false 197 | } 198 | 199 | def showHeld() { // Hides Held for certain device types 200 | if (state.buttonType.contains("100+ ") || state.buttonType == "Cube Controller") { 201 | return false 202 | } 203 | else { 204 | return true 205 | } 206 | } 207 | 208 | def shallHide(myFeature) { // Hide section if not configured 209 | if (collapseAll) return (settings["${myFeature}_pushed"] || settings["${myFeature}_held"] || settings["${myFeature}"]) 210 | return true 211 | } 212 | 213 | def isReq(myFeature) { // feature required? 214 | (settings[myFeature]) ? true : false 215 | } 216 | 217 | /********************************************************************** 218 | * Device description and details 219 | **********************************************************************/ 220 | def getDescription(dNumber) { 221 | def description = "" 222 | if (!(settings.find { 223 | it.key.contains("_${dNumber}_") 224 | })) { 225 | return "Tap to configure" 226 | } 227 | if (settings.find { 228 | it.key.contains("_${dNumber}_pushed") 229 | }) { 230 | description = "\nPUSHED: ${getDescDetails(dNumber, "_pushed")}\n" 231 | } 232 | if (settings.find { 233 | it.key.contains("_${dNumber}_held") 234 | }) { 235 | description = description + "\nHELD: ${getDescDetails(dNumber, "_held")}\n" 236 | } 237 | //if(anySettings) description = "PUSHED:"+getDescDetails(dNumber,"_pushed")+"\n\nHELD:"+getDescDetails(dNumber,"_held")//"CONFIGURED : Tap to edit" 238 | return description 239 | } 240 | 241 | def getDescDetails(bNum, type) { 242 | def numType = bNum + type 243 | log.info "$numType" 244 | def preferenceNames = settings.findAll { 245 | it.key.contains("_${numType}") 246 | }.sort() 247 | //get all configured settings that: match button# and type, AND are not false 248 | if (!preferenceNames) { 249 | return " **Not Configured** " 250 | } 251 | else { 252 | def formattedPage = "" 253 | preferenceNames.each { eachPref -> 254 | def prefDetail = getPrefDetails().find { 255 | eachPref.key.contains(it.id) 256 | } //gets description of action being performed(eg Turn On) 257 | def prefDevice = " : ${eachPref.value}" - "[" - "]" //name of device the action is being performed on (eg Bedroom Fan) 258 | try { 259 | def prefSubValue = settings[prefDetail.sub + numType] ?: "(!Missing!)" 260 | if (prefDetail.type == "normal") formattedPage += "\n- ${prefDetail.desc}${prefDevice}" 261 | if (prefDetail.type == "hasSub") formattedPage += "\n- ${prefDetail.desc}${prefSubValue}${prefDevice}" 262 | if (prefDetail.type == "bool") formattedPage += "\n- ${prefDetail.desc}" 263 | } 264 | catch (e) { 265 | log.error "Sub Value failed" 266 | } 267 | } 268 | return formattedPage 269 | } 270 | } 271 | 272 | 273 | def defaultLabel() { 274 | return "${buttonDevice} Mapping" 275 | } 276 | 277 | /********************************************************************** 278 | * Set details for all actions 279 | **********************************************************************/ 280 | 281 | def getPrefDetails() { 282 | def capPlayPause = 'capability.musicPlayer' 283 | def capVolume = 'capability.musicPlayer' 284 | def capTrack = 'capability.musicPlayer' 285 | def capMute = 'capability.musicPlayer' 286 | if (sonos == true) { 287 | capPlayPause = 'capability.mediaPlayback' 288 | capVolume = 'capability.audioVolume' 289 | capTrack = 'capability.mediaTrackControl' 290 | capMute = 'capability.audioMute' 291 | } 292 | def detailMappings = 293 | [ 294 | // Lights 295 | [id: 'lightOn_', sOrder: 1, desc: 'Turn On ', comm: lightOn, type: 'normal', secLabel: 'Switches (Turn On)', cap: 'capability.switch'], 296 | [id: 'lightOff_', sOrder: 2, desc: 'Turn Off', comm: lightOff, type: 'normal', secLabel: 'Switches (Turn Off)', cap: 'capability.switch'], 297 | [id: 'lights_', sOrder: 3, desc: 'Toggle On/Off', comm: lightToggle, type: 'normal', secLabel: 'Switches (Toggle On/Off)', cap: 'capability.switch'], 298 | [id: 'lightDim_', sOrder: 4, desc: 'Dim to ', comm: lightDim, sub: 'valLight', type: 'hasSub', secLabel: 'Dimmers (On to Level - Grp 1)', cap: 'capability.switchLevel', sTitle: 'Bright Level', sDesc: '0 to 100%'], 299 | [id: 'lightD2m_', sOrder: 5, desc: 'Dim to ', comm: lightDim, sub: 'valLight2', type: 'hasSub', secLabel: 'Dimmers (On to Level - Grp 2)', cap: 'capability.switchLevel', sTitle: 'Bright Level', sDesc: '0 to 100%'], 300 | [id: 'dimPlus_', sOrder: 6, desc: 'Brightness +', comm: lightDimUp, sub: 'valDimUp', type: 'hasSub', secLabel: 'Dimmers (Increase Level By)', cap: 'capability.switchLevel', sTitle: 'Increase by', sDesc: '0 to 15'], 301 | [id: 'dimMinus_', sOrder: 7, desc: 'Brightness -', comm: lightDimDown, sub: 'valDimDown', type: 'hasSub', secLabel: 'Dimmers (Decrease Level By)', cap: 'capability.switchLevel', sTitle: 'Decrease by', sDesc: '0 to 15'], 302 | [id: 'lightsDT_', sOrder: 8, desc: 'Turn Off/Dim', comm: lightDimOff, sub: 'valDimOff', type: 'hasSub', secLabel: 'Dimmers (Turn Off/Dim to)', cap: 'capability.switchLevel', sTitle: 'Bright Level', sDesc: '0 to 100%'], 303 | // Colour Temperatures 304 | [id: 'colourTempUp_', sOrder: 9, desc: 'Colour Temp Up ', comm: colourTempUp, sub: 'valColourTempUp', type: 'hasSub', secLabel: 'Light Colour Temp (Inc By)', cap: 'capability.colorTemperature', sTitle: 'Increase by', sDesc: '100 to 1000'], 305 | [id: 'colourTempDown_', sOrder: 10, desc: 'Colour Temp Down ', comm: colourTempDown, sub: 'valColourTempDown', type: 'hasSub', secLabel: 'Light Colour Temp (Dec By)', cap: 'capability.colorTemperature', sTitle: 'Decrease by', sDesc: '100 to 1000'], 306 | // Speakers 307 | [id: 'speakerpp_', sOrder: 11, desc: 'Play/Pause', comm: speakerPlayPause, type: 'normal', secLabel: 'Speakers (Toggle Play-Pause)', cap: capPlayPause], 308 | [id: 'speakervu_', sOrder: 12, desc: 'Volume +', comm: speakerVolumeUp, sub: 'valSpeakerVolumeUp', type: 'hasSub', secLabel: 'Speakers (Increase Vol By)', cap: capVolume, sTitle: 'Increase by', sDesc: '0 to 15'], 309 | [id: 'speakervd_', sOrder: 13, desc: 'Volume -', comm: speakerVolumeDown, sub: 'valSpeakerVolumeDown', type: 'hasSub', secLabel: 'Speakers (Decrease Vol By)', cap: capVolume, sTitle: 'Decrease by', sDesc: '0 to 15'], 310 | [id: 'speakernt_', sOrder: 14, desc: 'Next Track', comm: speakerNextTrack, type: 'normal', secLabel: 'Speakers (Go to Next Track)', cap: capTrack], 311 | [id: 'speakerpt_', sOrder: 15, desc: 'Previous Track', comm: speakerPrevTrack, type: "normal", secLabel: 'Speakers (Go to Prev Track)', cap: capTrack], 312 | [id: 'speakermu_', sOrder: 16, desc: 'Mute/Unmute', comm: speakerMuteUnmute, type: 'normal', secLabel: 'Speakers (Toggle Mute-Unmute)', cap: capMute], 313 | // Sirens 314 | [id: 'sirens_', sOrder: 17, desc: 'SIren Toggle', comm: sirenToggle, type: 'normal', secLabel: 'Sirens (Toggle)', cap: 'capability.alarm'], 315 | // Locks 316 | [id: 'locks_', sOrder: 18, desc: 'Lock', comm: lock, type: 'normal', secLabel: 'Locks (Lock)', cap: 'capability.lock'], 317 | [id: 'locksUnlock_', sOrder: 19, desc: 'Unlock', comm: unlock, type: 'normal', secLabel: 'Locks (Unlock)', cap: 'capability.lock'], 318 | [id: 'locksToggle_', sOrder: 20, desc: 'Toggle Lock', comm: lockToggle, type: 'normal', secLabel: 'Locks (Toggle)', cap: 'capability.lock'], 319 | // Fans 320 | [id: 'fanAdjust_', sOrder: 21, desc: 'Adjust', comm: fanAdjust, type: 'normal', secLabel: 'Fans (Low, Medium, High, Off)', cap: 'capability.switchLevel'], 321 | // Shades 322 | [id: 'shadeAdjust_', sOrder: 22, desc: 'Adjust', comm: shadeAdjust, type: 'normal', secLabel: 'Shades (Up, Down, Stop)', cap: 'capability.doorControl'], 323 | // Switches 324 | [id: 'offOnReset_', sOrder: 23, desc: 'Reset->On', comm: switchOffOnReset, type: 'normal', secLabel: 'Switches (Reset->On)', cap: 'capability.switch'], 325 | // Misc Functions 326 | [id: 'mode_', desc: 'Set Mode', comm: changeMode, type: 'normal'], 327 | [id: 'phrase_', desc: 'Run Routine', comm: runRout, type: 'normal'], 328 | [id: 'notifications_', desc: 'Push Notification', comm: messageHandle, sub: 'valNotify', type: 'bool'], 329 | [id: 'phone_', desc: 'Send SMS to', comm: smsHandle, sub: 'notifications_', type: 'normal'], 330 | [id: 'container_', desc: 'Cycle Playlist', comm: cyclePL, type: 'normal'], 331 | ] 332 | return detailMappings 333 | } 334 | 335 | /********************************************************************** 336 | * Button Event Handler 337 | **********************************************************************/ 338 | def buttonEvent(evt) { 339 | if (allOk) { 340 | def buttonNumber = evt.jsonData.buttonNumber 341 | def pressType = evt.value 342 | log.debug "$buttonDevice: Button $buttonNumber was $pressType" 343 | def preferenceNames = settings.findAll { 344 | it.key.contains("_${buttonNumber}_${pressType}") 345 | } 346 | preferenceNames.each { eachPref -> 347 | def prefDetail = getPrefDetails()?.find { 348 | eachPref.key.contains(it.id) 349 | } //returns the detail map of id,desc,comm,sub 350 | try { 351 | def PrefSubValue = settings["${prefDetail.sub}${buttonNumber}_${pressType}"] 352 | //value of sub-setting (eg 100) 353 | if (prefDetail.sub) { 354 | "$prefDetail.comm"(eachPref.value, PrefSubValue) 355 | } 356 | else { 357 | "$prefDetail.comm"(eachPref.value) 358 | } 359 | } 360 | catch (e) { 361 | log.trace e 362 | } 363 | } 364 | } 365 | } 366 | 367 | /********************************************************************** 368 | * Light / Switch Functions 369 | **********************************************************************/ 370 | def lightOn(devices) { 371 | log.info "Turning On: $devices" 372 | devices.on() 373 | } 374 | 375 | def lightOff(devices) { 376 | log.info "Turning Off: $devices" 377 | devices.off() 378 | } 379 | 380 | def lightToggle(devices) { 381 | log.info "Toggling Lights: $devices" 382 | if (devices*.currentValue('switch').contains('on')) { 383 | devices.off() 384 | } 385 | else { 386 | if (devices*.currentValue('switch').contains('off')) devices.on() 387 | } 388 | } 389 | 390 | def lightDim(devices, level) { 391 | log.info "Dimming to $level: $devices" 392 | devices.setLevel(level) 393 | } 394 | 395 | def lightDimUp(device, incLevel) { 396 | log.info "Incrementing Light by +$incLevel: $device" 397 | def currentLevel = device.currentValue('level')[0] //currentLevel return a list...[0] is first item in list ie volume level 398 | def newLevel = currentLevel.toInteger() + incLevel 399 | if (newLevel > 100) newLevel = 100 400 | device.setLevel(newLevel) 401 | } 402 | 403 | def lightDimDown(device, decLevel) { 404 | log.info "Decrementing Light by -$decLevel: $device" 405 | def currentLevel = device.currentValue('level')[0] 406 | def newLevel = currentLevel.toInteger() - decLevel 407 | if (newLevel < 1) newLevel = 1 //Disable turning off light by dimming too low. 408 | device.setLevel(newLevel) 409 | } 410 | 411 | def lightDimOff(devices, dimLevel) { 412 | log.info "Toggling On/Off | Dimming (to $dimLevel): $devices" 413 | if (devices*.currentValue('switch').contains('on')) { 414 | devices.off() 415 | } 416 | else { 417 | devices*.setLevel(dimLevel) 418 | } 419 | } 420 | 421 | def switchOffOnReset(devices) { 422 | log.info "Off/On Reset: $devices" 423 | if (devices*.currentValue('switch').contains('on')) { 424 | devices.off() 425 | devices.on() 426 | } 427 | else { 428 | devices.on() 429 | devices.off() 430 | devices.on() 431 | } 432 | } 433 | 434 | /********************************************************************** 435 | * Colour Temp Functions 436 | **********************************************************************/ 437 | def colourTempUp(device, value) { 438 | if (value) { 439 | log.info "$value Incrementing Colour Temp: $device by $value" 440 | def currentTemp = device.currentValue('colorTemperature')[0] 441 | int newTemp = currentTemp + value > 6500 ? 6500 : currentTemp + value 442 | device.setColorTemperature(newTemp) 443 | def newName = colourTempName(newTemp) 444 | sendEvent(name: "colorName", value: newName) 445 | log.info "Colour Temp Changed to $newName" 446 | } 447 | } 448 | 449 | def colourTempDown(device, value) { 450 | if (value) { 451 | log.info "Decrementing Colour Temp: $device by $value" 452 | def currentTemp = device.currentValue('colorTemperature')[0] 453 | def newTemp = currentTemp - value < 2200 ? 2200 : currentTemp - value 454 | device.setColorTemperature(newTemp) 455 | def newName = colourTempName(newTemp) 456 | sendEvent(name: "colorName", value: newName) 457 | log.info "Colour Temp Changed to $newName" 458 | } 459 | } 460 | 461 | private colourTempName(value) { 462 | if (value != null) { 463 | if (value < 2500) { 464 | return "Warm Glow" 465 | } 466 | else { 467 | if (value < 3000) { 468 | return "Warm White" 469 | } 470 | else { 471 | if (value < 5000) { 472 | return "Cool White" 473 | } 474 | else { 475 | if (value < 6000) { 476 | return "Daylight" 477 | } 478 | else { 479 | return "Cool Daylight" 480 | } 481 | } 482 | } 483 | } 484 | } 485 | return "White" 486 | } 487 | 488 | /********************************************************************** 489 | * Sound/Music Functions 490 | **********************************************************************/ 491 | def speakerPlayPause(device) { 492 | log.info "Toggling Play/Pause: $device" 493 | if (sonos == true) { 494 | device.currentValue('playbackStatus').contains('playing') ? device.pause() : device.play() 495 | } 496 | else { 497 | device.currentValue('status').contains('playing') ? device.pause() : device.play() 498 | } 499 | } 500 | 501 | def speakerVolumeUp(device, incLevel) { 502 | log.info "Incrementing Volume by +$incLevel: $device" 503 | def currentVolume = (sonos == true) ? device.currentValue('volume')[0] : device.currentValue('level')[0] 504 | def newVolume = currentVolume.toInteger() + incLevel 505 | if (newVolume > 100) newVolume = 100 506 | if (sonos == true) { 507 | device.setVolume(newVolume) 508 | } 509 | else { 510 | device.setLevel(newVolume) 511 | } 512 | log.info "Volume increased by $incLevel to $newVolume" 513 | } 514 | 515 | def speakerVolumeDown(device, decLevel) { 516 | log.info "Decrementing Volume by -$decLevel: $device" 517 | def currentVolume = (sonos == true) ? device.currentValue('volume')[0] : device.currentValue('level')[0] 518 | def newVolume = currentVolume.toInteger() - decLevel 519 | if (newVolume < 0) newVolume = 0 520 | if (sonos == true) { 521 | device.setVolume(newVolume) 522 | } 523 | else { 524 | device.setLevel(newVolume) 525 | } 526 | log.info "Volume decreased by $decLevel to $newVolume" 527 | } 528 | 529 | def speakerNextTrack(device) { 530 | log.info "Next Track Sent to: $device" 531 | device.nextTrack() 532 | } 533 | 534 | def speakerPrevTrack(device) { 535 | log.info "Previous Track Sent to: $device" 536 | device.previousTrack() 537 | } 538 | 539 | def speakerMuteUnmute(device) { 540 | log.info "Toggling Mute/Unmute: $device" 541 | device.currentValue('mute').contains('unmuted') ? device.mute() : device.unmute() 542 | } 543 | 544 | def playlistCycle(device) { 545 | device.cycleChild() 546 | } 547 | 548 | /********************************************************************** 549 | * Siren Functions 550 | **********************************************************************/ 551 | def sirenToggle(devices) { 552 | log.info "Toggling Sirens: $devices" 553 | if (devices*.currentValue('switch').contains('on')) { 554 | devices.off() 555 | } 556 | else { 557 | if (devices*.currentValue('switch').contains('off')) devices.on() 558 | } 559 | } 560 | 561 | /********************************************************************** 562 | * Lock Functions 563 | **********************************************************************/ 564 | def lock(devices) { 565 | log.info "Locking: $devices" 566 | devices.lock() 567 | } 568 | 569 | def unlock(devices) { 570 | log.info "Unlocking: $devices" 571 | devices.unlock() 572 | } 573 | 574 | def lockToggle(devices) { 575 | log.info "Toggling: $devices" 576 | if (devices*.currentValue("lock").contains('locked')) { 577 | devices.unlock() 578 | } 579 | else { 580 | devices.lock() 581 | } 582 | } 583 | 584 | /********************************************************************** 585 | * Fan Functions 586 | **********************************************************************/ 587 | def fanAdjust(device) { 588 | log.info "Adjusting: $device" 589 | def currentLevel = device.currentLevel 590 | if (device.currentSwitch == 'off') { 591 | device.setLevel(15) 592 | } 593 | else { 594 | if (currentLevel < 34) { 595 | device.setLevel(50) 596 | } 597 | else { 598 | if (currentLevel < 67) { 599 | device.setLevel(90) 600 | } 601 | else { 602 | if (fanIgnoreOff) { 603 | device.off() 604 | } 605 | else { 606 | device.SetLevel(15) 607 | } 608 | } 609 | } 610 | } 611 | } 612 | 613 | /********************************************************************** 614 | * Shade Functions 615 | **********************************************************************/ 616 | def shadeAdjust(device) { 617 | log.info "Shades: $device = ${device.currentMotor} state.lastUP = $state.lastshadesUp" 618 | if (device.currentMotor in ["up", "down"]) { 619 | state.lastshadesUp = device.currentMotor == "up" 620 | device.stop() 621 | } 622 | else { 623 | state.lastshadesUp ? device.down() : device.up() 624 | state.lastshadesUp = !state.lastshadesUp 625 | } 626 | } 627 | 628 | /********************************************************************** 629 | * Misc Functions 630 | **********************************************************************/ 631 | def modeSet(mode) { 632 | log.info "Changing Mode to: $mode" 633 | if (location.mode != mode && location.modes?.find { 634 | it.name == mode 635 | }) { 636 | setLocationMode(mode) 637 | } 638 | } 639 | 640 | def routineRun(rout) { 641 | log.info "Running: $rout" 642 | location.helloHome.execute(rout) 643 | } 644 | 645 | def notificationHandle(msg, inApp) { 646 | if (inApp == true) { 647 | log.info "Push notification sent" 648 | sendPush(msg) 649 | } 650 | } 651 | 652 | def smsHandle(phone, msg) { 653 | log.info "SMS sent" 654 | sendSms(phone, msg ?: "No custom text entered on: $app.label") 655 | } 656 | 657 | // execution filter methods 658 | private getAllOk() { 659 | modeOk && daysOk && timeOk 660 | } 661 | 662 | private getModeOk() { 663 | def result = !modes || modes.contains(location.mode) 664 | result 665 | } 666 | 667 | private getDaysOk() { 668 | def result = true 669 | if (days) { 670 | def df = new java.text.SimpleDateFormat("EEEE") 671 | if (location.timeZone) { 672 | df.setTimeZone(location.timeZone) 673 | } 674 | else { 675 | df.setTimeZone(TimeZone.getTimeZone("America/New_York")) 676 | } 677 | def day = df.format(new Date()) 678 | result = days.contains(day) 679 | } 680 | result 681 | } 682 | 683 | private getTimeOk() { 684 | def result = true 685 | if (starting && ending) { 686 | def currTime = now() 687 | def start = timeToday(starting).time 688 | def stop = timeToday(ending).time 689 | result = start < stop ? currTime >= start && currTime <= stop : currTime <= stop || currTime >= start 690 | } 691 | result 692 | } 693 | 694 | private hhmm(time, fmt = "h:mm a") { 695 | def t = timeToday(time, location.timeZone) 696 | def f = new java.text.SimpleDateFormat(fmt) 697 | f.setTimeZone(location.timeZone ?: timeZone(time)) 698 | f.format(t) 699 | } 700 | 701 | private hideOptionsSection() { 702 | (starting || ending || days || modes || manualCount || fanIgnoreOff || sonos) ? false : true 703 | } 704 | 705 | private timeIntervalLabel() { 706 | (starting && ending) ? hhmm(starting) + "-" + hhmm(ending, "h:mm a z") : "" 707 | } 708 | 709 | /********************************************************************** 710 | * Functions to group devices / provide device descriptions 711 | **********************************************************************/ 712 | 713 | def getButtonType(buttonName) { 714 | if (buttonName.contains("Aeon Minimote")) return "Aeon Minimote" 715 | if (buttonName.contains("Hue Dimmer")) return "Hue Dimmer" 716 | if (buttonName.contains("Cube Controller")) return "Cube Controller" 717 | if (buttonName.contains("Inovelli") && buttonName.contains("Red Series")) return "Inovelli Red" 718 | return buttonName 719 | } 720 | 721 | def getSpecText(currentButton) { 722 | currentButton = (currentButton == null ? state.currentButton : currentButton) 723 | log.info state.buttonType 724 | if (state.buttonType == "Lutron Pico") { 725 | switch (state.currentButton) { 726 | case 1: return "Top Button"; break 727 | case 2: return "Bottom Button"; break 728 | case 3: return "Middle Button"; break 729 | case 4: return "Up Button"; break 730 | case 5: return "Down Button"; break 731 | } 732 | } 733 | 734 | if (state.buttonType == "Hue Dimmer") { 735 | switch (state.currentButton) { 736 | case 1: return "On Button"; break 737 | case 2: return "Up Button"; break 738 | case 3: return "Down Button"; break 739 | case 4: return "Off Button"; break 740 | } 741 | } 742 | 743 | if (state.buttonType == "Cube Controller") { 744 | switch (state.currentButton) { 745 | case 1: return "Shake Cube"; break 746 | case 2: return "Flip Cube 90 Degrees"; break 747 | case 3: return "Flip Cube 180 Degrees"; break 748 | case 4: return "Slide Cube"; break 749 | case 5: return "Knock Cube"; break 750 | case 6: return "Rotate Cube Right"; break 751 | case 7: return "Rotate Cube Left"; break 752 | } 753 | } 754 | 755 | if (state.buttonType == "Aeon Minimote") { 756 | switch (state.currentButton) { 757 | case 1: return "Top Left Button"; break 758 | case 2: return "Top Right Button"; break 759 | case 3: return "Lower Left Button"; break 760 | case 4: return "Lower Right"; break 761 | } 762 | } 763 | 764 | if (state.buttonType.contains("WD100+ Dimmer")) { 765 | switch (state.currentButton) { 766 | case 1: return "Double-Tap Upper Paddle"; break 767 | case 2: return "Double-Tap Lower Paddle"; break 768 | case 3: return "Triple-Tap Upper Paddle"; break 769 | case 4: return "Triple-Tap Lower Paddle"; break 770 | case 5: return "Press & Hold Upper Paddle\n(See user guide for quirks)"; break 771 | case 6: return "Press & Hold Lower Paddle\n(See user guide for quirks)"; break 772 | case 7: return "Single Tap Upper Paddle\n(See user guide for quirks)"; break 773 | case 8: return "Single Tap Lower Paddle\n(See user guide for quirks)"; break 774 | } 775 | } 776 | 777 | if (state.buttonType.contains("WS100+ Switch")) { 778 | switch (state.currentButton) { 779 | case 1: return "Double-Tap Upper Paddle"; break 780 | case 2: return "Double-Tap Lower Paddle"; break 781 | case 3: return "Triple-Tap Upper Paddle"; break 782 | case 4: return "Triple-Tap Lower Paddle"; break 783 | case 5: return "Press & Hold Upper Paddle"; break 784 | case 6: return "Press & Hold Lower Paddle"; break 785 | case 7: return "Single Tap Upper Paddle"; break 786 | case 8: return "Single Tap Lower Paddle"; break 787 | } 788 | } 789 | 790 | if (state.buttonType.contains("WD200+ Dimmer")) { 791 | switch (state.currentButton) { 792 | case 1: return "Double-Tap Upper Paddle"; break 793 | case 2: return "Double-Tap Lower Paddle"; break 794 | case 3: return "Triple-Tap Upper Paddle"; break 795 | case 4: return "Triple-Tap Lower Paddle"; break 796 | case 5: return "Press & Hold Upper Paddle\n(See user guide for quirks)"; break 797 | case 6: return "Press & Hold Lower Paddle\n(See user guide for quirks)"; break 798 | case 7: return "Single Tap Upper Paddle\n(See user guide for quirks)"; break 799 | case 8: return "Single Tap Lower Paddle\n(See user guide for quirks)"; break 800 | case 9: return "4X-Tap Upper Paddle"; break 801 | case 10: return "4X-Tap Lower Paddle"; break 802 | case 11: return "5X-Tap Upper Paddle"; break 803 | case 12: return "5X-Tap Lower Paddle"; break 804 | } 805 | } 806 | 807 | if (state.buttonType.contains("WS200+ Switch")) { 808 | switch (state.currentButton) { 809 | case 1: return "Double-Tap Upper Paddle"; break 810 | case 2: return "Double-Tap Lower Paddle"; break 811 | case 3: return "Triple-Tap Upper Paddle"; break 812 | case 4: return "Triple-Tap Lower Paddle"; break 813 | case 5: return "Press & Hold Upper Paddle"; break 814 | case 6: return "Press & Hold Lower Paddle"; break 815 | case 7: return "Single Tap Upper Paddle"; break 816 | case 8: return "Single Tap Lower Paddle"; break 817 | case 9: return "4X-Tap Upper Paddle"; break 818 | case 10: return "4X-Tap Lower Paddle"; break 819 | case 11: return "5X-Tap Upper Paddle"; break 820 | case 12: return "5X-Tap Lower Paddle"; break 821 | } 822 | } 823 | 824 | if (state.buttonType.contains("Inovelli")) { 825 | switch (state.currentButton) { 826 | case 1: return "NOT OPERATIONAL - DO NOT USE"; break 827 | case 2: return "2X Tap Upper Paddle = Pushed\n2X Tap Lower Paddle = Held"; break 828 | case 3: return "3X Tap Upper Paddle = Pushed\n3X Tap Lower Paddle = Held"; break 829 | case 4: return "4X Tap Upper Paddle = Pushed\n4X Tap Lower Paddle = Held"; break 830 | case 5: return "5X Tap Upper Paddle = Pushed\n5X Tap Lower Paddle = Held"; break 831 | case 6: return "Hold Upper Paddle = Pushed\nHold Lower Paddle = Held"; break 832 | case 7: if (state.buttonType.contains("Red")) { 833 | return "1x Tap Config Button"; break; 834 | } 835 | } 836 | } 837 | 838 | if (state.buttonType.contains("ZRC-90")) { 839 | switch (state.currentButton) { 840 | case 1: return "Tap or Hold Button 1"; break 841 | case 2: return "Tap or Hold Button 2"; break 842 | case 3: return "Tap or Hold Button 3"; break 843 | case 4: return "Tap or Hold Button 4"; break 844 | case 5: return "Tap or Hold Button 5"; break 845 | case 6: return "Tap or Hold Button 6"; break 846 | case 7: return "Tap or Hold Button 7"; break 847 | case 8: return "Tap or Hold Button 8"; break 848 | case 9: return "2X Tap Button 1\nHold Not Available"; break 849 | case 10: return "2X Tap Button 2\nHold Not Available"; break 850 | case 11: return "2X Tap Button 3\nHold Not Available"; break 851 | case 12: return "2X Tap Button 4\nHold Not Available"; break 852 | case 13: return "2X Tap Button 5\nHold Not Available"; break 853 | case 14: return "2X Tap Button 6\nHold Not Available"; break 854 | case 15: return "2X Tap Button 7\nHold Not Available"; break 855 | case 16: return "2X Tap Button 8\nHold Not Available"; break 856 | } 857 | } 858 | 859 | if (state.buttonType.contains("Zen27")) { 860 | switch (currentButton) { 861 | case 1: return "1 x up"; break 862 | case 2: return "1 x down"; break 863 | case 3: return "2 x up"; break 864 | case 4: return "2 x down"; break 865 | case 5: return "3 x up"; break 866 | case 6: return "3 x down"; break 867 | case 7: return "4 x up"; break 868 | case 8: return "4 x down"; break 869 | case 9: return "5 x up"; break 870 | case 10: return "5 x down"; break 871 | } 872 | } 873 | 874 | if (state.buttonType == "Ikea Button") { 875 | if (state.buttonCount == 5) { 876 | switch (state.currentButton) { 877 | case 1: return "Up Button"; break 878 | case 2: return "Right Button"; break 879 | case 3: return "Down Button"; break 880 | case 4: return "Left Button"; break 881 | case 5: return "Middle Button"; break 882 | } 883 | } 884 | if (state.buttonCount == 2) { 885 | switch (state.currentButton) { 886 | case 1: return "Up Button"; break 887 | case 2: return "Down Button"; break 888 | } 889 | } 890 | } 891 | return "" 892 | } -------------------------------------------------------------------------------- /smartapps/paulsheldon/abc-manager.src/abc-manager.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * Child Creator - Advanced Button Controller 4 | * 5 | * Author: Paul Sheldon (Original by Stephan Hackett) 6 | * 7 | * 6/20/17 - fixed missing subs for notifications 8 | * 1/07/18 - split smartApp into Parent/Child (IOS hanging on initial startup) - requires complete uninstall and reinstall of Parent and child SmartApps 9 | * 1/14/18a - updated version check code 10 | * 11 | * Code now maintained by Paul Sheldon * 12 | * 2019-02-05 - added support for Hue Dimmer & color temperature 13 | * 2019-09-25 - updated volume control, play/pause, next/previous track and mute/unmute for Sonos speakers - code provided by Gabor Szabados 14 | * 2020-01-02 - added support (beta) for fan control, Inovelli Red Series Switch & Dimmer (inc config button 7) 15 | * 2020-05-05 - added support WS200 Dimmer & Switch 16 | * 2021-07-02 - Tidy up code 17 | * 18 | **/ 19 | 20 | /********************************************************************** 21 | * Define App Parameters 22 | *********************************************************************/ 23 | definition( 24 | name: "ABC Manager", 25 | namespace: "paulsheldon", 26 | author: "Paul Sheldon (Original by Stephan Hackett)", 27 | description: "Advanced Button Controller", 28 | category: "My Apps", 29 | iconUrl: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/abc/images/abcNew.png", 30 | iconX2Url: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/abc/images/abcNew.png", 31 | iconX3Url: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/abc/images/abcNew.png", 32 | singleInstance: true, 33 | ) 34 | 35 | preferences { 36 | page(name: "pageMain", title: "ABC Mappings", install: true, uninstall: true) 37 | page(name: "pageAbout", title: "About ABC Manager") 38 | } 39 | 40 | /********************************************************************** 41 | * Setup and Configuration Commands: 42 | *********************************************************************/ 43 | def installed() { 44 | log.debug "${app.label}: Installed" 45 | } 46 | 47 | def uninstalled() { 48 | log.debug "${app.label}: Uninstalled" 49 | } 50 | 51 | def updated() { 52 | log.debug "${app.label}: Updated" 53 | unsubscribe() 54 | } 55 | 56 | /********************************************************************** 57 | * Page Definitions 58 | *********************************************************************/ 59 | def pageMain() { 60 | dynamicPage(name: "pageMain") { 61 | def childApps = getAllChildApps() 62 | def childVersion = "InitialSetup" 63 | if (childApps.size() > 0) { 64 | childVersion = childApps.first().version() 65 | log.debug "Using Child Version ${childApps.first().version()}" 66 | } 67 | section("Create a new button device mapping.") { 68 | app(name: "childApps", appName: "ABC Child Creator", namespace: "paulsheldon", title: "Create New Button Device Mapping", multiple: true) 69 | } 70 | section("Version Info, User's Guide") { 71 | href(name: "pageAbout", 72 | title: "Advanced Button Controller \n" + childVersion, 73 | description: "Tap to get Smart App Info and User's Guide.", 74 | image: versionCheck(childVersion), 75 | page: "pageAbout" 76 | ) 77 | } 78 | remove("Uninstall ABC Controller", "WARNING!!", "This will remove the ENTIRE SmartApp, including all configs listed above.") 79 | } 80 | } 81 | 82 | def pageAbout() { 83 | dynamicPage(name: "pageAbout") { 84 | section("User's Guide - Advanced Button Controller") { 85 | paragraph "This smart app allows you to use a device with buttons including, but not limited to:\n\n" + 86 | " Aeon Labs Minimotes\n" + 87 | " HomeSeer HS-WD100+ switches**\n" + 88 | " HomeSeer HS-WS100+ switches\n" + 89 | " Lutron Picos***\n" + 90 | " Philips Hue Dimmer Switches****\n\n" + 91 | " Inovelli Switch/Dimmer Red Series\n\n" + 92 | "It is a heavily modified version of @dalec's 'Button Controller Plus' which is in turn a version of @bravenel's 'Button Controller+'." 93 | } 94 | section("Latest changes:") { 95 | paragraph "Added Inovelli Red Series.\n\n" 96 | paragraph "Added Sonos Device ##.\n\n" + 97 | "You can now use a Sonos device as the music player." + 98 | "Incorporates Gabor Szabados @gszabados code." 99 | paragraph "Added Color Temperature ##.\n\n" + 100 | "Updated to include Philips Hue Dimmers\nA device handler can be found at @paulsheldon " + 101 | "https://github.com/paulsheldon/SmartThings-PS to allow dimmer to work in Smart Apps" 102 | paragraph "A complete revamp of the configuration flow. You can now tell at a glance, what has been configured for each button. " + 103 | "The button configuration page has been collapsed by default for easier navigation." 104 | paragraph "The original apps were hardcoded to allow configuring 4 or 6 button devices. " + 105 | "This app will automatically detect the number of buttons on your device or allow you to manually " + 106 | "specify (only needed if device does not report correct number of buttons)." 107 | paragraph "Allows you to give your button device full speaker control including: Play/Pause, NextTrack, Mute, VolumeUp/Down. " + 108 | "(***Standard Pico remotes can be converted to Audio Picos)\n\nThe additional control options have been highlighted below #." 109 | } 110 | section("Available Control Options:") { 111 | paragraph " Switches - Toggle \n" + 112 | " Switches - Turn On \n" + 113 | " Switches - Turn Off \n" + 114 | " Dimmers - Toggle \n" + 115 | " Dimmers - Set Level (Group 1) \n" + 116 | " Dimmers - Set Level (Group 2) \n" + 117 | " Dimmers - Inc Level \n" + 118 | " Dimmers - Dec Level \n" + 119 | " Color Temperature - Inc Level \n" + 120 | " Color Temperature - Dec Level \n" + 121 | " Fans - Low, Medium, High, Off \n" + 122 | " Shades - Up, Down, or Stop \n" + 123 | " Locks - Unlock Only \n" + 124 | " Speaker - Play/Pause \n" + 125 | " Speaker - Next Track \n" + 126 | " Speaker - Previous Track \n" + 127 | " Speaker - Mute/Unmute \n" + 128 | " Speaker - Volume Up \n" + 129 | " Speaker - Volume Down \n" + 130 | " Set Modes \n" + 131 | " Run Routines \n" + 132 | " Sirens - Toggle \n" + 133 | " Push Notifications \n" + 134 | " SMS Notifications" 135 | } 136 | section("** Quirk for HS-WD100+ on Button 5 & 6:") { 137 | paragraph "Because a dimmer switch already uses Press&Hold to manually set the dimming level " + 138 | "please be aware of this operational behavior. If you only want to manually change " + 139 | "the dim level to the lights that are wired to the switch, you will automatically " + 140 | "trigger the 5/6 button event as well. And the same is true in reverse. If you " + 141 | "only want to trigger a 5/6 button event action with Press&Hold, you will be manually " + 142 | "changing the dim level of the switch simultaneously as well.\n" + 143 | "This quirk doesn't exist of course with the HS-HS100+ since it is not a dimmer." 144 | } 145 | section("*** Lutron Pico Requirements:") { 146 | paragraph "Lutron Picos are not natively supported by SmartThings. A Lutron SmartBridge Pro, a device running @njschwartz's python script (or node.js) and the Lutron Caseta Service Manager " + 147 | "SmartApp are also required for this functionality!\nSearch the forums for details." 148 | } 149 | section("**** Philips Hue Dimmer:") { 150 | paragraph "Philips Hue Dimmers are not natively supported by SmartThings.\n" + 151 | "A device handler that works with Smart Apps can be found on @paulsheldon\n https://github.com/paulsheldon/SmartThings-PS" 152 | } 153 | } 154 | } 155 | 156 | /********************************************************************** 157 | * Image Check - used to check for new app versions 158 | *********************************************************************/ 159 | def versionCheck(childVersion) { 160 | log.debug "Looking for Version ${childVersion}" 161 | def params = [ 162 | uri: "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/abc/images/abc_${childVersion}.png", 163 | ] 164 | try { 165 | httpGet(params) { resp -> 166 | resp.headers.each { 167 | //log.debug "${it.name} : ${it.value}" 168 | } 169 | log.debug "ABC appears to be running the latest Version" 170 | return params.uri 171 | } 172 | } catch (e) { 173 | log.error "ABC does not appear to be the latest version: Please update from IDE ${childVersion}" 174 | return "https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/master/resources/abc/images/update.png" 175 | } 176 | } -------------------------------------------------------------------------------- /webCoRe/Security Lights/SecurityLights.piston.groovy: -------------------------------------------------------------------------------- 1 | 2 | /**************************************************************/ 3 | /* Security Lights - Front of House */ 4 | /**************************************************************/ 5 | /* Author : Paul Sheldon */ 6 | /* Created : 30/12/2018, 12:11:29 */ 7 | /* Modified : 02/01/2019, 21:26:50 */ 8 | /* Build : 13 */ 9 | /* UI version : v0.3.109.20181207 */ 10 | /**************************************************************/ 11 | 12 | settings 13 | disable command optimization; 14 | end settings; 15 | 16 | define 17 | device deviceSensors = Porch Motion; 18 | device deviceLights = Porch Light; 19 | string speechText; /* Front Lights Turned OFF */ 20 | boolean speechForce = false; 21 | const integer plus30Mins = 30; 22 | const integer minus30Mins = -30; 23 | const integer timeDelay = 1; 24 | const time timeOff = 23:59:00; 25 | const integer maxLight = 100; 26 | const integer minLight = 0; 27 | const integer midLight = {(maxLight-minLight)/2}; 28 | end define; 29 | 30 | execute 31 | on events from 32 | {deviceSensors}'s motion 33 | do 34 | switch ({deviceSensors}'s motion) 35 | case 'inactive': 36 | if 37 | Time is between {plus30Mins} minutes past sunrise and {minus30Mins} minutes past sunset, but only in January, February, October, November, or December 38 | and 39 | Time is any, but only in March, April, May, June, July, August, or September 40 | and 41 | {deviceLights}'s level is different than {minLight}% 42 | then 43 | /* Turn off all Lights */ 44 | with 45 | {deviceLights} 46 | do 47 | Cancel all pending tasks; 48 | Set level to {minLight}%; 49 | Turn off; 50 | Set variable {speechText} = Front Lights Turned Off; 51 | Execute piston "Home \ webCoRE \ Speech Controller" with arguments {speechText,speechForce}; 52 | end with; 53 | end if; 54 | case 'active': 55 | if 56 | Time is between {timeOff} and sunrise, but only in January, February, October, November, or December 57 | and 58 | {deviceLights}'s level is different than {midLight}% 59 | then 60 | with 61 | {deviceLights} 62 | do 63 | Cancel all pending tasks; 64 | Set level to {midLight}%; 65 | Turn on; 66 | Set variable {speechText} = Front Lights Turned ON; 67 | Execute piston "Home \ webCoRE \ Speech Controller" with arguments {speechText,speechForce}; 68 | Wait 2 minutes; 69 | Set level to {minLight}%; 70 | Turn off; 71 | Set variable {speechText} = Front Lights Turned OFF; 72 | Execute piston "Home \ webCoRE \ Speech Controller" with arguments {speechText,speechForce}; 73 | end with; 74 | else if 75 | Time is between {minus30Mins} minutes past sunset and {timeOff}, but only in January, February, October, November, or December 76 | and 77 | {deviceLights}'s level is outside of range {maxLight}% and {midLight}% 78 | then 79 | /* Turn lights to 100%, wait 5 mins then turn to 50% */ 80 | with 81 | {deviceLights} 82 | do 83 | Log info "Max then half"; 84 | Cancel all pending tasks; 85 | Log info "Tasks Cancelled"; 86 | Turn on; 87 | Set level to {maxLight}%; 88 | Set variable {speechText} = Front Lights Turned to MAX; 89 | Execute piston "Home \ webCoRE \ Speech Controller" with arguments {speechText,speechForce}; 90 | Log info "Wait 5 mins"; 91 | Wait 2 minutes; 92 | Set level to {midLight}%; 93 | Set variable {speechText} = Front Lights Turned to HALF; 94 | Execute piston "Home \ webCoRE \ Speech Controller" with arguments {speechText,speechForce}; 95 | end with; 96 | else 97 | with 98 | {deviceLights} 99 | do 100 | Cancel all pending tasks; 101 | Set level to {midLight}%; 102 | Turn on; 103 | Set variable {speechText} = Front Lights Turned ON to Half; 104 | Execute piston "Home \ webCoRE \ Speech Controller" with arguments {speechText,speechForce}; 105 | Wait 2 minutes; 106 | Set level to {minLight}%; 107 | Turn off; 108 | Set variable {speechText} = Front Lights Turned OFF; 109 | Execute piston "Home \ webCoRE \ Speech Controller" with arguments {speechText,speechForce}; 110 | end with; 111 | end if; 112 | end switch; 113 | end on; 114 | async if 115 | Date & Time is between sunset and {timeOff} 116 | and 117 | {deviceLights}'s switch is off 118 | then 119 | with 120 | {deviceLights} 121 | do 122 | Turn on; 123 | end with; 124 | end if; 125 | end execute; 126 | -------------------------------------------------------------------------------- /webCoRe/Speech Controller/SpeechController.piston.groovy: -------------------------------------------------------------------------------- 1 | 2 | /**************************************************************/ 3 | /* Speech Controller */ 4 | /**************************************************************/ 5 | /* Author : Paul Sheldon */ 6 | /* Created : 06/01/2019, 21:26:31 */ 7 | /* Modified : 07/01/2019, 13:00:37 */ 8 | /* Build : 27 */ 9 | /* UI version : v0.3.109.20181207 */ 10 | /**************************************************************/ 11 | 12 | define 13 | device speakerList = Office Speaker; 14 | device speaker; /* Office Speaker */ 15 | string speechText = {if($args.speechText,$args.speechTest,"")}; 16 | boolean speechOverride = {if($args.speechOverride,$args.speechOverride,false)}; 17 | end define; 18 | 19 | execute 20 | if 21 | ( 22 | System Speech Toggle's switch is on 23 | or 24 | {speechOverride} is true 25 | ) 26 | and 27 | {speechText} is not {text(null)} 28 | then 29 | switch ({speechOverride}) 30 | case 'true': 31 | for each (speaker in {speakerList}) 32 | do 33 | with 34 | {speaker} 35 | do 36 | Speak text "{speechText}"; 37 | end with; 38 | end for each; 39 | case 'false': 40 | with 41 | {speaker} 42 | do 43 | Speak text "{speechText}"; 44 | end with; 45 | end switch; 46 | end if; 47 | on events from 48 | System Speech Toggle's switch 49 | do 50 | with 51 | Office Speaker 52 | do 53 | Speak text "{concat("Speech is now ",[$currentEventDevice:switch]=="on"? "enabled":"disabled")}"; 54 | end with; 55 | end on; 56 | end execute; 57 | -------------------------------------------------------------------------------- /webCoRe/Speech Controller/speechController.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paulsheldon/SmartThings-PS/13436236e18cf0b9b4d221d0887fea8e863b33e6/webCoRe/Speech Controller/speechController.png --------------------------------------------------------------------------------