├── .editorconfig ├── .gitignore ├── LICENSE ├── README.md ├── packageManifest.json └── src ├── apps └── unofficial-ring-connect.groovy └── drivers ├── ring-api-virtual-device.groovy ├── ring-virtual-alarm-hub.groovy ├── ring-virtual-alarm-range-extender.groovy ├── ring-virtual-alarm-smoke-co-listener.groovy ├── ring-virtual-beams-bridge.groovy ├── ring-virtual-beams-group.groovy ├── ring-virtual-beams-light.groovy ├── ring-virtual-beams-motion-sensor.groovy ├── ring-virtual-camera-with-siren.groovy ├── ring-virtual-camera.groovy ├── ring-virtual-chime.groovy ├── ring-virtual-co-alarm.groovy ├── ring-virtual-contact-sensor.groovy ├── ring-virtual-flood-freeze-sensor.groovy ├── ring-virtual-glass-break-sensor.groovy ├── ring-virtual-keypad.groovy ├── ring-virtual-light-with-siren.groovy ├── ring-virtual-light.groovy ├── ring-virtual-lock.groovy ├── ring-virtual-motion-sensor.groovy ├── ring-virtual-panic-button.groovy ├── ring-virtual-retrofit-alarm-kit.groovy ├── ring-virtual-siren.groovy ├── ring-virtual-smoke-alarm.groovy └── ring-virtual-switch.groovy /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | charset = utf-8 3 | end_of_line = lf 4 | indent_size = 2 5 | indent_style = space 6 | insert_final_newline = false 7 | max_line_length = 120 8 | tab_width = 2 9 | ij_continuation_indent_size = 8 10 | ij_formatter_off_tag = @formatter:off 11 | ij_formatter_on_tag = @formatter:on 12 | ij_formatter_tags_enabled = true 13 | ij_smart_tabs = false 14 | ij_visual_guides = none 15 | ij_wrap_on_typing = false 16 | 17 | [*.properties] 18 | ij_properties_align_group_field_declarations = false 19 | ij_properties_keep_blank_lines = false 20 | ij_properties_key_value_delimiter = equals 21 | ij_properties_spaces_around_key_value_delimiter = false 22 | 23 | [.editorconfig] 24 | ij_editorconfig_align_group_field_declarations = false 25 | ij_editorconfig_space_after_colon = false 26 | ij_editorconfig_space_after_comma = true 27 | ij_editorconfig_space_before_colon = false 28 | ij_editorconfig_space_before_comma = false 29 | ij_editorconfig_spaces_around_assignment_operators = true 30 | 31 | [{*.gant,*.gradle,*.groovy,*.gy}] 32 | ij_continuation_indent_size = 2 33 | ij_groovy_align_group_field_declarations = false 34 | ij_groovy_align_multiline_array_initializer_expression = false 35 | ij_groovy_align_multiline_assignment = false 36 | ij_groovy_align_multiline_binary_operation = false 37 | ij_groovy_align_multiline_chained_methods = false 38 | ij_groovy_align_multiline_extends_list = false 39 | ij_groovy_align_multiline_for = true 40 | ij_groovy_align_multiline_list_or_map = true 41 | ij_groovy_align_multiline_method_parentheses = false 42 | ij_groovy_align_multiline_parameters = true 43 | ij_groovy_align_multiline_parameters_in_calls = false 44 | ij_groovy_align_multiline_resources = true 45 | ij_groovy_align_multiline_ternary_operation = false 46 | ij_groovy_align_multiline_throws_list = false 47 | ij_groovy_align_named_args_in_map = true 48 | ij_groovy_align_throws_keyword = false 49 | ij_groovy_array_initializer_new_line_after_left_brace = false 50 | ij_groovy_array_initializer_right_brace_on_new_line = false 51 | ij_groovy_array_initializer_wrap = off 52 | ij_groovy_assert_statement_wrap = off 53 | ij_groovy_assignment_wrap = off 54 | ij_groovy_binary_operation_wrap = off 55 | ij_groovy_blank_lines_after_class_header = 0 56 | ij_groovy_blank_lines_after_imports = 1 57 | ij_groovy_blank_lines_after_package = 1 58 | ij_groovy_blank_lines_around_class = 1 59 | ij_groovy_blank_lines_around_field = 0 60 | ij_groovy_blank_lines_around_field_in_interface = 0 61 | ij_groovy_blank_lines_around_method = 1 62 | ij_groovy_blank_lines_around_method_in_interface = 1 63 | ij_groovy_blank_lines_before_imports = 1 64 | ij_groovy_blank_lines_before_method_body = 0 65 | ij_groovy_blank_lines_before_package = 0 66 | ij_groovy_block_brace_style = end_of_line 67 | ij_groovy_block_comment_at_first_column = true 68 | ij_groovy_call_parameters_new_line_after_left_paren = false 69 | ij_groovy_call_parameters_right_paren_on_new_line = false 70 | ij_groovy_call_parameters_wrap = off 71 | ij_groovy_catch_on_new_line = false 72 | ij_groovy_class_annotation_wrap = split_into_lines 73 | ij_groovy_class_brace_style = end_of_line 74 | ij_groovy_class_count_to_use_import_on_demand = 5 75 | ij_groovy_do_while_brace_force = always 76 | ij_groovy_else_on_new_line = true 77 | ij_groovy_enum_constants_wrap = off 78 | ij_groovy_extends_keyword_wrap = off 79 | ij_groovy_extends_list_wrap = off 80 | ij_groovy_field_annotation_wrap = split_into_lines 81 | ij_groovy_finally_on_new_line = false 82 | ij_groovy_for_brace_force = always 83 | ij_groovy_for_statement_new_line_after_left_paren = false 84 | ij_groovy_for_statement_right_paren_on_new_line = false 85 | ij_groovy_for_statement_wrap = off 86 | ij_groovy_if_brace_force = always 87 | ij_groovy_import_annotation_wrap = 2 88 | ij_groovy_imports_layout = *,|,javax.**,java.**,|,$* 89 | ij_groovy_indent_case_from_switch = true 90 | ij_groovy_indent_label_blocks = true 91 | ij_groovy_insert_inner_class_imports = false 92 | ij_groovy_keep_blank_lines_before_right_brace = 2 93 | ij_groovy_keep_blank_lines_in_code = 2 94 | ij_groovy_keep_blank_lines_in_declarations = 2 95 | ij_groovy_keep_control_statement_in_one_line = true 96 | ij_groovy_keep_first_column_comment = true 97 | ij_groovy_keep_indents_on_empty_lines = false 98 | ij_groovy_keep_line_breaks = true 99 | ij_groovy_keep_multiple_expressions_in_one_line = false 100 | ij_groovy_keep_simple_blocks_in_one_line = false 101 | ij_groovy_keep_simple_classes_in_one_line = true 102 | ij_groovy_keep_simple_lambdas_in_one_line = true 103 | ij_groovy_keep_simple_methods_in_one_line = true 104 | ij_groovy_label_indent_absolute = false 105 | ij_groovy_label_indent_size = 2 106 | ij_groovy_lambda_brace_style = end_of_line 107 | ij_groovy_layout_static_imports_separately = true 108 | ij_groovy_line_comment_add_space = false 109 | ij_groovy_line_comment_at_first_column = true 110 | ij_groovy_method_annotation_wrap = split_into_lines 111 | ij_groovy_method_brace_style = end_of_line 112 | ij_groovy_method_call_chain_wrap = off 113 | ij_groovy_method_parameters_new_line_after_left_paren = false 114 | ij_groovy_method_parameters_right_paren_on_new_line = false 115 | ij_groovy_method_parameters_wrap = off 116 | ij_groovy_modifier_list_wrap = false 117 | ij_groovy_names_count_to_use_import_on_demand = 3 118 | ij_groovy_parameter_annotation_wrap = off 119 | ij_groovy_parentheses_expression_new_line_after_left_paren = false 120 | ij_groovy_parentheses_expression_right_paren_on_new_line = false 121 | ij_groovy_prefer_parameters_wrap = false 122 | ij_groovy_resource_list_new_line_after_left_paren = false 123 | ij_groovy_resource_list_right_paren_on_new_line = false 124 | ij_groovy_resource_list_wrap = off 125 | ij_groovy_space_after_assert_separator = true 126 | ij_groovy_space_after_colon = true 127 | ij_groovy_space_after_comma = true 128 | ij_groovy_space_after_comma_in_type_arguments = true 129 | ij_groovy_space_after_for_semicolon = true 130 | ij_groovy_space_after_quest = true 131 | ij_groovy_space_after_type_cast = true 132 | ij_groovy_space_before_annotation_parameter_list = false 133 | ij_groovy_space_before_array_initializer_left_brace = false 134 | ij_groovy_space_before_assert_separator = false 135 | ij_groovy_space_before_catch_keyword = true 136 | ij_groovy_space_before_catch_left_brace = true 137 | ij_groovy_space_before_catch_parentheses = true 138 | ij_groovy_space_before_class_left_brace = true 139 | ij_groovy_space_before_closure_left_brace = true 140 | ij_groovy_space_before_colon = true 141 | ij_groovy_space_before_comma = false 142 | ij_groovy_space_before_do_left_brace = true 143 | ij_groovy_space_before_else_keyword = true 144 | ij_groovy_space_before_else_left_brace = true 145 | ij_groovy_space_before_finally_keyword = true 146 | ij_groovy_space_before_finally_left_brace = true 147 | ij_groovy_space_before_for_left_brace = true 148 | ij_groovy_space_before_for_parentheses = true 149 | ij_groovy_space_before_for_semicolon = false 150 | ij_groovy_space_before_if_left_brace = true 151 | ij_groovy_space_before_if_parentheses = true 152 | ij_groovy_space_before_method_call_parentheses = false 153 | ij_groovy_space_before_method_left_brace = true 154 | ij_groovy_space_before_method_parentheses = false 155 | ij_groovy_space_before_quest = true 156 | ij_groovy_space_before_switch_left_brace = true 157 | ij_groovy_space_before_switch_parentheses = true 158 | ij_groovy_space_before_synchronized_left_brace = true 159 | ij_groovy_space_before_synchronized_parentheses = true 160 | ij_groovy_space_before_try_left_brace = true 161 | ij_groovy_space_before_try_parentheses = true 162 | ij_groovy_space_before_while_keyword = true 163 | ij_groovy_space_before_while_left_brace = true 164 | ij_groovy_space_before_while_parentheses = true 165 | ij_groovy_space_in_named_argument = true 166 | ij_groovy_space_in_named_argument_before_colon = false 167 | ij_groovy_space_within_empty_array_initializer_braces = false 168 | ij_groovy_space_within_empty_method_call_parentheses = false 169 | ij_groovy_spaces_around_additive_operators = true 170 | ij_groovy_spaces_around_assignment_operators = true 171 | ij_groovy_spaces_around_bitwise_operators = true 172 | ij_groovy_spaces_around_equality_operators = true 173 | ij_groovy_spaces_around_lambda_arrow = true 174 | ij_groovy_spaces_around_logical_operators = true 175 | ij_groovy_spaces_around_multiplicative_operators = true 176 | ij_groovy_spaces_around_regex_operators = true 177 | ij_groovy_spaces_around_relational_operators = true 178 | ij_groovy_spaces_around_shift_operators = true 179 | ij_groovy_spaces_within_annotation_parentheses = false 180 | ij_groovy_spaces_within_array_initializer_braces = false 181 | ij_groovy_spaces_within_braces = true 182 | ij_groovy_spaces_within_brackets = false 183 | ij_groovy_spaces_within_cast_parentheses = false 184 | ij_groovy_spaces_within_catch_parentheses = false 185 | ij_groovy_spaces_within_for_parentheses = false 186 | ij_groovy_spaces_within_gstring_injection_braces = false 187 | ij_groovy_spaces_within_if_parentheses = false 188 | ij_groovy_spaces_within_list_or_map = false 189 | ij_groovy_spaces_within_method_call_parentheses = false 190 | ij_groovy_spaces_within_method_parentheses = false 191 | ij_groovy_spaces_within_parentheses = false 192 | ij_groovy_spaces_within_switch_parentheses = false 193 | ij_groovy_spaces_within_synchronized_parentheses = false 194 | ij_groovy_spaces_within_try_parentheses = false 195 | ij_groovy_spaces_within_tuple_expression = false 196 | ij_groovy_spaces_within_while_parentheses = false 197 | ij_groovy_special_else_if_treatment = true 198 | ij_groovy_ternary_operation_wrap = off 199 | ij_groovy_throws_keyword_wrap = off 200 | ij_groovy_throws_list_wrap = off 201 | ij_groovy_use_flying_geese_braces = false 202 | ij_groovy_use_fq_class_names = false 203 | ij_groovy_use_fq_class_names_in_javadoc = true 204 | ij_groovy_use_relative_indents = false 205 | ij_groovy_use_single_class_imports = true 206 | ij_groovy_variable_annotation_wrap = off 207 | ij_groovy_while_brace_force = always 208 | ij_groovy_while_on_new_line = true 209 | ij_groovy_wrap_chain_calls_after_dot = false 210 | ij_groovy_wrap_long_lines = false 211 | 212 | [{*.har,*.json}] 213 | ij_json_keep_blank_lines_in_code = 0 214 | ij_json_keep_indents_on_empty_lines = false 215 | ij_json_keep_line_breaks = true 216 | ij_json_space_after_colon = true 217 | ij_json_space_after_comma = true 218 | ij_json_space_before_colon = true 219 | ij_json_space_before_comma = false 220 | ij_json_spaces_within_braces = false 221 | ij_json_spaces_within_brackets = false 222 | ij_json_wrap_long_lines = false 223 | 224 | [{*.markdown,*.md}] 225 | ij_markdown_force_one_space_after_blockquote_symbol = true 226 | ij_markdown_force_one_space_after_header_symbol = true 227 | ij_markdown_force_one_space_after_list_bullet = true 228 | ij_markdown_force_one_space_between_words = true 229 | ij_markdown_keep_indents_on_empty_lines = false 230 | ij_markdown_max_lines_around_block_elements = 1 231 | ij_markdown_max_lines_around_header = 1 232 | ij_markdown_max_lines_between_paragraphs = 1 233 | ij_markdown_min_lines_around_block_elements = 1 234 | ij_markdown_min_lines_around_header = 1 235 | ij_markdown_min_lines_between_paragraphs = 1 236 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/codeStyles/codeStyleConfig.xml 2 | /.idea/misc.xml 3 | /.idea/modules.xml 4 | /.idea/vcs.xml 5 | /.idea/workspace.xml 6 | /ring_hubitat_codahq.iml 7 | 8 | # Vim temp files 9 | *.swo 10 | *.swp 11 | 12 | src/apps/tmp/tmp-*.groovy 13 | src/drivers/tmp/tmp-*.groovy 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hubitat Ring Integration (Unofficial) # 2 | 3 | **Notice!!!** 4 | 5 | First and foremost I need to warn any who venture to use this integration. This integration is provided for fun without hope of warranty or safety or stable or permanent use. Ring are not official partners with Hubitat or myself and all of the interactions between the Hubitat hub and Ring's cloud servers in this integration are via the private API calls that Ring does not publish or give permission to use for this purpose. I wrote this integration for fun and I do not trust it with my safety. It's a hobby project. (That said, it is well built and mostly stable. On the hubitat side the hub slows down sometimes and drops the websocket connection but there is a watchdog that starts it back up.) 6 | 7 | If some part of this integration does not work now or stops working in the future I make no gaurantees and this is provided "AS IS" without hope of service or warranty. If you use this integration you agree to hold me unresponsible for what may happen to your Ring account in the event that Ring deems this type of usage of the API unreasonable. You agree to hold me unresponsible for what may happen to your home, personal property, self, family, etc. You agree to hold me unresponsible. End of story. 8 | 9 | If that sounds okay then continue onwards... 10 | 11 | I don't expect this to be a perfect experience because I'm not providing a lot of direction and I don't have documented very well which drivers go to which devices beyond the names of the drivers and files. And they have A LOT of devices. 12 | 13 | Everyone should start by installing the app. From there, there are two types of devices; devices that communicate via classic HTTP calls and devices that communicate via websockets. It roughly breaks down like this: 14 | 15 | - Security cameras, doorbells and chimes (classic HTTP devices) 16 | - Beams devices (websocket devices) 17 | - Security devices (websocket devices) 18 | 19 | The app can interact directly with the non-websocket devices. The driver for the API device is required for all of the websocket devices. The dependency heirarchy will look like this a little: 20 | 21 | App 22 | / \ 23 | websocket cameras/chimes/doorbells 24 | device 25 | / \ 26 | security beams 27 | devices devices 28 | 29 | Before you install any classic HTTP devices know that since we are not Ring partners we cannot get motion and ring notifications pushed to us. Because of this you have three options. One option is to poll for them. Yes, this is horrible and for that reason I do not poll myself. However, I added this functionality because it seems to work for the home bridge project. AND... I know that I will spend forever explaining why I didn't add it if I don't. Now I will probably just spend forever explaining why you can't poll more often for dings or dings are missed... Option two is to setup IFTTT applets for each motion type (ring or motion) for each device. There is fairly robust documentation for how to do this within the app so I will only cover it briefly here. You must enable OAuth on the app and authorize Ring to IFTTT. Then you create applets on Ring events that call into the "Unofficial Ring Connect" app using an OAuth token by way of web service calls from the "Webhooks" IFTTT service. If it sounds complicated, don't worry. After you install the app you can navigate through to the IFTTT page and learn more. Finally, the third option is to use SmartThings and the hublink app and have separate devices for status. (I have separate devices and I use the SmartThings integration with hublink). 30 | 31 | I also added the ability for each light device to poll for its light status. I don't use this either. I use these devices for control. I do not use them for status. I don't ever need to know their light status therefore I don't care what it is and I don't poll for light status. 32 | 33 | You do NOT need to install all of the device drivers in this repository. You should be able to get away with installing the drivers for just the devices you own and have registered. Here are the device to driver mappings roughly: 34 | 35 | ## The app ## 36 | 37 | - [unofficial-ring-connect.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/apps/unofficial-ring-connect.groovy) - Required for all. (does authentication and communication) 38 | 39 | ## Children of the app ## 40 | 41 | - [ring-api-virtual-device.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-api-virtual-device.groovy) - This is the "Ring API Virtual Device" or websocket device. Required if you have a Ring Alarm hub or a Ring Beams (Smart Lighting) bridge 42 | - [ring-virtual-chime.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-chime.groovy) - Chime or Chime Pro 43 | - [ring-virtual-light-with-siren.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-light-with-siren.groovy) - Floodlight Cam, Spotlight Cam 44 | - [ring-virtual-light.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-light.groovy) - Spotlight Cam Battery (A few devices where the siren call is different and I haven't reverse engineered it yet.) 45 | - [ring-virtual-camera-with-siren.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-camera-with-siren.groovy) - Indoor Cam, Stick Up Cam 46 | - [ring-virtual-camera.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-camera.groovy) - Doorbells 47 | 48 | ## Children of the Ring API Virtual Device (websocket device) ## 49 | 50 | ### Ring Alarm ### 51 | 52 | - [ring-virtual-alarm-hub.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-alarm-hub.groovy) - Ring Alarm Hub. Required to create alarm devices 53 | - [ring-virtual-alarm-range-extender.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-alarm-range-extender.groovy) - Range Extender (1st and 2nd Gen) 54 | - [ring-virtual-alarm-smoke-co-listener.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-alarm-smoke-co-listener.groovy) - Smoke/CO2 Listener 55 | - [ring-virtual-contact-sensor.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-contact-sensor.groovy) - Ring Alarm Contact Sensor (1st and 2nd Gen) and any Z-Wave (Ecolink) tilt sensor that connect to Ring Alarm. Additionally used for contact sensors connected to the Retrofit Alarm Kit 56 | - [ring-virtual-motion-sensor.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-motion-sensor.groovy) - Ring Alarm Motion Sensor (1st or 2nd Gen) 57 | - [ring-virtual-flood-freeze-sensor.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-flood-freeze-sensor.groovy) Ring Flood & Freeze Sensor 58 | - [ring-virtual-keypad.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-keypad.groovy) - Ring Alarm Keypad (1st or 2nd Gen) 59 | - [ring-virtual-lock.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-lock.groovy) - Any Z-Wave lock that connects to Ring Alarm 60 | - [ring-virtual-siren.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-siren.groovy) - Any Z-wave (Dome) siren that conects to Ring Alarm 61 | - [ring-virtual-switch.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-switch.groovy) - Any Z-Wave switch that connects to Ring Alarm 62 | - [ring-virtual-smoke-alarm.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-smoke-alarm.groovy) Any Z-Wave (First-Alert) smoke detector that connects to Ring Alarm (First Alert) 63 | - [ring-virtual-co-alarm.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-co-alarm.groovy) Any Z-Wave (First Alert) CO detector that connects to Ring Alarm. Note that these devices typically show as different devices on the Ring side so they show as different devices on the Hubitat side as well 64 | - [ring-virtual-retrofit-alarm-kit.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-keypad.groovy) - Ring Retrofit Alarm Kit 65 | 66 | ### Ring Security Lighting (Ring Bridge/Beams) ### 67 | 68 | - [ring-virtual-beams-bridge.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-beams-bridge.groovy) - Smart Lighting (Beams) bridge. Required to create security lighting devices 69 | - [ring-virtual-beams-group.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-beams-group.groovy) - Smart Lighting Group 70 | - [ring-virtual-beams-light.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-beams-light.groovy) - Smart Lighting Light with Motion Sensor 71 | - [ring-virtual-beams-motion-sensor.groovy](https://github.com/HubitatCommunity/hubitat_ring_integration/blob/master/src/drivers/ring-virtual-beams-motion-sensor.groovy) - Smart Lighting Motion Sensor 72 | 73 | The app will create the camera, chime and doorbell devices automatically. However, because it was far easier the security and beams devices are NOT created automatically via the app's discover devices functionality. Once you add the "Ring API Virtual Device" from the app you must go and click "Create Devices" on your respective device to get its websocket children device(s) to create. For example, if you have alarm devices go to the alarm hub device's edit page and click the "Create Devices" command. 74 | 75 | ## Brief Installation Instructions (**IF YOU ONLY READ ONE THING LET IT BE THIS SECTION**) ## 76 | 77 | The packages can be installed either manually or through the Hubitat Package Manager. 78 | 79 | ### Using Hubitat Package Manager ### 80 | 81 | - Make sure Hubitat Package Manager is installed and working. See [hubitat-packagemanager](https://github.com/dcmeglio/hubitat-packagemanager) 82 | - This package can be found in the Integrations section, or you can install by URL using this link: [packageManifest.json](https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/master/packageManifest.json) 83 | - Make sure to select the optional device drivers that you will need when prompted 84 | 85 | ### Manual Install ### 86 | 87 | - Go to github.com via the links above and install the custom app code. (Install custom apps using the "Apps Code" link in the left navigation of the Hubitat hub.) 88 | - Also on github.com get the code for all of the devices you need using the list above. If you have alarm or security lighting devices you also need the "Ring API Virtual Device" driver. (Install custom drivers using the "Drivers Code" link in the left navigation of the Hubitat hub.) 89 | 90 | ### Configuration ### 91 | 92 | - Create an instance of the app. (Create instances of custom apps using the "Apps" link in the left navigation of the Hubitat hub.) 93 | - Authenticate to Ring in the app by giving it your Ring credentials and choose your location. 94 | - Click the "Discover Devices" link in the app. If you have alarm or security devices be sure to also pick to install the "Ring Virtual API Device". The app will create any devices you select here for you. 95 | - **You won't get motion or ring notifications or events on cameras and doorbells until you configure them.** There are instructions in the app to set them up under the "Configure the way that Hubitat will get motion alert and ring events" link. **It is highly recommended to use IFTTT for notifications.** You can poll for events but it is often unreliable. 96 | - You are done if you do not have alarm or security lighting devices. 97 | - If you have alarm or security lighting devices you will need to go to the "Ring Virtual API Device" and make sure it is connected by looking at its current state for websocket. 98 | - If it isn't connected, hit the "Initialize" command button 99 | - If it is connected, the API device should have up to two children devices already created. If you have alarm devices, the alarm hub should be created. If you have security lighting devices the beams bridge should be created. Go to each of these devices and click its "Create Devices" command button. This will automatically create the alarm and security devices. 100 | - At no point should you create a device yourself. The only thing you need to create is the app instance. The app and API device create everything else. 101 | -------------------------------------------------------------------------------- /packageManifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "packageName": "Hubitat Ring Integration (Unofficial)", 3 | "author": "codahq", 4 | "version": "0.5.9", 5 | "betaVersion": "0.6.0.4", 6 | "minimumHEVersion": "0.0", 7 | "dateReleased": "2024-06-18", 8 | "releaseNotes": "Fix apiRequestTickets 500 error.\nAdd support for stickup_cam_longfin, stickup_cam_medusa, and stickup_cam_mini_v2", 9 | "apps": [ 10 | { 11 | "id": "981fa0e5-b7c7-4459-a9ba-7ccdc51faa55", 12 | "name": "Unofficial Ring Connect", 13 | "namespace": "ring-hubitat-codahq", 14 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/apps/unofficial-ring-connect.groovy", 15 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/apps/unofficial-ring-connect.groovy", 16 | "required": true, 17 | "oauth": true 18 | } 19 | ], 20 | "drivers": [ 21 | { 22 | "id": "8f216a41-8eed-4246-8c83-f45e45d36967", 23 | "name": "Ring API Virtual Device", 24 | "namespace": "ring-hubitat-codahq", 25 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-api-virtual-device.groovy", 26 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-api-virtual-device.groovy", 27 | "required": true 28 | }, 29 | { 30 | "id": "5bcdd988-ccec-4f4b-9fc1-90d820fda1af", 31 | "name": "Ring Virtual Alarm Hub", 32 | "namespace": "ring-hubitat-codahq", 33 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-alarm-hub.groovy", 34 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-alarm-hub.groovy", 35 | "required": false 36 | }, 37 | { 38 | "id": "70efa457-42eb-46ac-99f7-095a5e313149", 39 | "name": "Ring Virtual Alarm Range Extender", 40 | "namespace": "ring-hubitat-codahq", 41 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-alarm-range-extender.groovy", 42 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-alarm-range-extender.groovy", 43 | "required": false 44 | }, 45 | { 46 | "id": "aead008c-f3f5-4ffd-b936-a5803213768f", 47 | "name": "Ring Virtual Alarm Smoke & CO Listener", 48 | "namespace": "ring-hubitat-codahq", 49 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-alarm-smoke-co-listener.groovy", 50 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-alarm-smoke-co-listener.groovy", 51 | "required": false 52 | }, 53 | { 54 | "id": "d8892a22-34a9-47d8-893d-a69bb24c756d", 55 | "name": "Ring Virtual Beams Bridge", 56 | "namespace": "ring-hubitat-codahq", 57 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-beams-bridge.groovy", 58 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-beams-bridge.groovy", 59 | "required": false 60 | }, 61 | { 62 | "id": "79d7248b-7db9-4b05-8f67-6c53e22662ee", 63 | "name": "Ring Virtual Beams Group", 64 | "namespace": "ring-hubitat-codahq", 65 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-beams-group.groovy", 66 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-beams-group.groovy", 67 | "required": false 68 | }, 69 | { 70 | "id": "e27d6c9b-7442-4828-9d24-ca019939f524", 71 | "name": "Ring Virtual Beams Light", 72 | "namespace": "ring-hubitat-codahq", 73 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-beams-light.groovy", 74 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-beams-light.groovy", 75 | "required": false 76 | }, 77 | { 78 | "id": "02be7aac-42b4-4ae8-b08e-89148dea5565", 79 | "name": "Ring Virtual Beams Motion Sensor", 80 | "namespace": "ring-hubitat-codahq", 81 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-beams-motion-sensor.groovy", 82 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-beams-motion-sensor.groovy", 83 | "required": false 84 | }, 85 | { 86 | "id": "69752fc9-099d-4cb9-a7ae-af50a4e9f238", 87 | "name": "Ring Virtual Camera", 88 | "namespace": "ring-hubitat-codahq", 89 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-camera.groovy", 90 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-camera.groovy", 91 | "required": false 92 | }, 93 | { 94 | "id": "0971b13a-e3e3-43e6-b02f-b5d384db5a46", 95 | "name": "Ring Virtual Camera with Siren", 96 | "namespace": "ring-hubitat-codahq", 97 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-camera-with-siren.groovy", 98 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-camera-with-siren.groovy", 99 | "required": false 100 | }, 101 | { 102 | "id": "2bbff10b-0231-47d3-bb80-25d86d1a2317", 103 | "name": "Ring Virtual Chime", 104 | "namespace": "ring-hubitat-codahq", 105 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-chime.groovy", 106 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-chime.groovy", 107 | "required": false 108 | }, 109 | { 110 | "id": "bca84b7f-a3ee-4464-bee7-47313fdc06de", 111 | "name": "Ring Virtual CO Alarm", 112 | "namespace": "ring-hubitat-codahq", 113 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-co-alarm.groovy", 114 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-co-alarm.groovy", 115 | "required": false 116 | }, 117 | { 118 | "id": "a64d3760-5873-4f65-8dc8-a67d23fc835c", 119 | "name": "Ring Virtual Contact Sensor", 120 | "namespace": "ring-hubitat-codahq", 121 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-contact-sensor.groovy", 122 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-contact-sensor.groovy", 123 | "required": false 124 | }, 125 | { 126 | "id": "32b9f95d-1d97-4ae9-a59c-69bbb5d806a2", 127 | "name": "Ring Virtual Alarm Flood & Freeze Sensor", 128 | "namespace": "ring-hubitat-codahq", 129 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-flood-freeze-sensor.groovy", 130 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-flood-freeze-sensor.groovy", 131 | "required": false 132 | }, 133 | { 134 | "id": "fbbc678d-19a1-47d0-bb2d-2cd5c428c950", 135 | "name": "Ring Virtual Glass Break Sensor", 136 | "namespace": "ring-hubitat-codahq", 137 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-glass-break-sensor.groovy", 138 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-glass-break-sensor.groovy", 139 | "required": false 140 | }, 141 | { 142 | "id": "9d755c96-7282-4650-9eb0-a18fb918af2a", 143 | "name": "Ring Virtual Keypad", 144 | "namespace": "ring-hubitat-codahq", 145 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-keypad.groovy", 146 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-keypad.groovy", 147 | "required": false 148 | }, 149 | { 150 | "id": "0535ca0b-f816-411d-ace1-0febf3da27b6", 151 | "name": "Ring Virtual Light", 152 | "namespace": "ring-hubitat-codahq", 153 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-light.groovy", 154 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-light.groovy", 155 | "required": false 156 | }, 157 | { 158 | "id": "daea57e4-1600-404b-b58c-223ea870760b", 159 | "name": "Ring Virtual Light with Siren", 160 | "namespace": "ring-hubitat-codahq", 161 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-light-with-siren.groovy", 162 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-light-with-siren.groovy", 163 | "required": false 164 | }, 165 | { 166 | "id": "9e38ce3c-a7ea-4db0-b82b-bf9d1772248d", 167 | "name": "Ring Virtual Lock", 168 | "namespace": "ring-hubitat-codahq", 169 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-lock.groovy", 170 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-lock.groovy", 171 | "required": false 172 | }, 173 | { 174 | "id": "0d140155-f66a-49b1-86f4-695877a744d6", 175 | "name": "Ring Virtual Motion Sensor", 176 | "namespace": "ring-hubitat-codahq", 177 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-motion-sensor.groovy", 178 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-motion-sensor.groovy", 179 | "required": false 180 | }, 181 | { 182 | "id": "bdb8b6e7-de9c-45e9-a286-6493fcebe4e5", 183 | "name": "Ring Virtual Retrofit Alarm Kit", 184 | "namespace": "ring-hubitat-codahq", 185 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-retrofit-alarm-kit.groovy", 186 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-retrofit-alarm-kit.groovy", 187 | "required": false 188 | }, 189 | { 190 | "id": "f65782ac-e70b-42dc-b6b6-90f75fd903ae", 191 | "name": "Ring Virtual Siren", 192 | "namespace": "ring-hubitat-codahq", 193 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-siren.groovy", 194 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-siren.groovy", 195 | "required": false 196 | }, 197 | { 198 | "id": "a023f88d-63df-46f4-8c3c-6aee94b7dce2", 199 | "name": "Ring Virtual Smoke Alarm", 200 | "namespace": "ring-hubitat-codahq", 201 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-smoke-alarm.groovy", 202 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-smoke-alarm.groovy", 203 | "required": false 204 | }, 205 | { 206 | "id": "b7fa1b23-96d9-4407-8896-3b4af7372fc4", 207 | "name": "Ring Virtual Switch", 208 | "namespace": "ring-hubitat-codahq", 209 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-switch.groovy", 210 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-switch.groovy", 211 | "required": false 212 | }, 213 | { 214 | "id": "d010d9fa-653d-4c48-aa0e-dad26d65d7ee", 215 | "name": "Ring Virtual Panic Button", 216 | "namespace": "ring-hubitat-codahq", 217 | "location": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/v0.5.9/src/drivers/ring-virtual-panic-button.groovy", 218 | "betaLocation": "https://raw.githubusercontent.com/HubitatCommunity/hubitat_ring_integration/develop/src/drivers/ring-virtual-panic-button.groovy", 219 | "required": false 220 | } 221 | ], 222 | "documentationLink": "https://github.com/HubitatCommunity/hubitat_ring_integration/blob/v0.5.9/README.md" 223 | } 224 | -------------------------------------------------------------------------------- /src/drivers/ring-virtual-alarm-hub.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Alarm Hub Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | import groovy.transform.Field 18 | 19 | metadata { 20 | definition(name: "Ring Virtual Alarm Hub", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 21 | capability "Actuator" 22 | capability "AudioVolume" 23 | capability "Alarm" 24 | capability "Refresh" 25 | capability "PowerSource" 26 | capability "TamperAlert" 27 | 28 | attribute "acStatus", "enum", ["brownout", "connected", "disconnected"] 29 | attribute "batteryBackup", "string" 30 | attribute "batteryStatus", "enum", ["charged", "charging", "failed", "full", "low", "malfunction", "none", "ok", "warn"] 31 | attribute "brightness", "number" 32 | attribute "coAlarm", "enum", ["active", "inactive"] 33 | attribute "cellular", "string" 34 | attribute "connectionStatus", "enum", ["asset-cell-backup", "backing-up", "connected", "connecting", "extended-cell-backup", 35 | "restoring", "updating"] 36 | attribute "countdownTimeLeft", "number" 37 | attribute "countdownTotal", "number" 38 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 39 | attribute "ethernet", "string" 40 | attribute "entryDelay", "enum", ["active", "inactive"] 41 | attribute "exitDelay", "enum", ["active", "inactive"] 42 | attribute "fireAlarm", "enum", ["active", "inactive"] 43 | attribute "firmware", "string" 44 | attribute "mode", "enum", ["off", "home", "away"] 45 | attribute "networkConnection", "enum", ["cellular", "ethernet", "unknown", "wifi"] 46 | attribute "wifi", "string" 47 | 48 | command "setBrightness", [[name: "Set LED Brightness*", type: "NUMBER", range: "0..100", description: "Choose a value between 0 and 100"]] 49 | command "setMode", [[name: "Set Mode*", type: "ENUM", description: "Set the Ring Alarm's mode", constraints: ["Disarmed", "Home", "Away"]]] 50 | command "sirenTest" 51 | command "sirenTestCancel" 52 | command "createDevices" 53 | } 54 | 55 | preferences { 56 | input name: "syncRingToHsm", type: "bool", title: "Sync Ring Alarm mode to HSM mode?", description: "When the Ring mode changes would you like the HSM mode to follow it?", defaultValue: false 57 | input name: "cancelAlertsOnDisarm", type: "bool", title: "Cancel HSM Alerts on Ring Alarm Disarm?", defaultValue: true 58 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 59 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 60 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 61 | } 62 | } 63 | 64 | void logInfo(msg) { 65 | if (descriptionTextEnable) { log.info msg } 66 | } 67 | 68 | void logDebug(msg) { 69 | if (logEnable) { log.debug msg } 70 | } 71 | 72 | void logTrace(msg) { 73 | if (traceLogEnable) { log.trace msg } 74 | } 75 | 76 | void createDevices() { parent.createDevices() } 77 | 78 | void refresh() { 79 | parent.refresh(device.getDataValue("src")) 80 | } 81 | 82 | def setMode(mode) { 83 | logDebug "setMode(${mode})" 84 | Map data 85 | if (mode == "Disarmed" && device.currentValue("mode") != "off") { 86 | data = ["mode": "none"] 87 | } 88 | else if (mode == "Home" && device.currentValue("mode") != "home") { 89 | data = ["mode": "some"] 90 | } 91 | else if (mode == "Away" && device.currentValue("mode") != "away") { 92 | data = ["mode": "all"] 93 | } 94 | else { 95 | logInfo "${device.label} already set to ${mode}. No change necessary" 96 | return 97 | } 98 | 99 | parent.apiWebsocketRequestSetCommand("security-panel.switch-mode", device.getDataValue("src"), device.getDataValue("security-panel-zid"), data) 100 | } 101 | 102 | def off() { 103 | logTrace "previous value alarm: ${device.currentValue("alarm")}" 104 | parent.apiWebsocketRequestSetCommand("security-panel.silence-siren", device.getDataValue("src"), device.getDataValue("security-panel-zid")) 105 | } 106 | 107 | def siren() { 108 | parent.apiWebsocketRequestSetCommand("security-panel.sound-siren", device.getDataValue("src"), device.getDataValue("security-panel-zid")) 109 | } 110 | 111 | def strobe() { 112 | log.error "The device ${device.getDisplayName()} does not support the strobe functionality" 113 | } 114 | 115 | def both() { 116 | strobe() 117 | siren() 118 | } 119 | 120 | def sirenTest() { 121 | if (device.currentValue("mode") != "off") { 122 | log.warn "Please disarm the alarm before testing the siren." 123 | return 124 | } 125 | parent.apiWebsocketRequestSetCommand("siren-test.start", null, device.getDataValue("security-panel-zid")) 126 | } 127 | 128 | def sirenTestCancel() { 129 | parent.apiWebsocketRequestSetCommand("siren-test.stop", device.getDataValue("src"), device.getDataValue("security-panel-zid")) 130 | } 131 | 132 | void setVolume(volumelevel) { 133 | // Value must be in [0, 100] 134 | volumelevel = Math.min(Math.max(volumelevel == null ? 50 : volumelevel.toInteger(), 0), 100) 135 | 136 | Integer currentVolume = device.currentValue("volume") 137 | 138 | if (currentVolume != volumelevel) { 139 | logTrace "requesting volume change to ${volumelevel}" 140 | parent.apiWebsocketRequestSetDevice(null, getHubZid(), [volume: volumelevel.toDouble() / 100]) 141 | } 142 | else { 143 | logInfo "Already at volume." 144 | sendEvent(name: "volume", value: currentVolume) 145 | } 146 | } 147 | 148 | void volumeUp() { 149 | Integer currentVolume = device.currentValue("volume") 150 | Integer nextVol = currentVolume + VOLUME_INC 151 | if (nextVol <= 100) { 152 | setVolume(nextVol) 153 | } 154 | else { 155 | logInfo "Already max volume." 156 | sendEvent(name: "volume", value: currentVolume) 157 | } 158 | } 159 | 160 | void volumeDown() { 161 | Integer currentVolume = device.currentValue("volume") 162 | Integer nextVol = currentVolume - VOLUME_INC 163 | if (nextVol >= 0) { 164 | setVolume(nextVol) 165 | } 166 | else { 167 | logInfo "Already min volume." 168 | sendEvent(name: "volume", value: currentVolume) 169 | } 170 | } 171 | 172 | void mute() { 173 | setVolume(0) 174 | } 175 | 176 | void unmute() { 177 | setVolume(state.prevVolume) 178 | } 179 | 180 | def setBrightness(brightness) { 181 | // Value must be in [0, 100] 182 | brightness = Math.min(Math.max(brightness == null ? 100 : brightness.toInteger(), 0), 100) 183 | 184 | parent.apiWebsocketRequestSetDevice(device.getDataValue("src"), getHubZid(), [brightness: brightness.toDouble() / 100]) 185 | } 186 | 187 | String getHubZid() { 188 | return device.getDataValue("hub.redsky-zid") ?: device.getDataValue("hub.kili-zid") 189 | } 190 | 191 | void setValues(final Map deviceInfo) { 192 | logDebug "setValues(${deviceInfo})" 193 | 194 | // Save some special zids 195 | for (final entry in deviceInfo.subMap(['hub.kili-zid', 'hub.redsky-zid', 'security-panel-zid'])) { 196 | checkChangedDataValue(entry.key, entry.value) 197 | } 198 | 199 | if (deviceInfo.mode != null) { 200 | final String mappedMode = MODES.get(deviceInfo.mode) 201 | 202 | if (checkChanged("mode", mappedMode)) { 203 | parent.updateMode(mappedMode) 204 | 205 | if (mappedMode == "off") { 206 | sendEvent(name: "countdownTimeLeft", value: 0) 207 | sendEvent(name: "countdownTotal", value: 0) 208 | checkChanged("entryDelay", "inactive") 209 | checkChanged("exitDelay", "inactive") 210 | } 211 | 212 | if (syncRingToHsm) { 213 | final Map hsmMode = RING_TO_HSM_MODE_MAP[mappedMode] 214 | 215 | if (location.hsmStatus != hsmMode.status) { 216 | logInfo "Setting HSM to ${hsmMode.set}" 217 | logTrace "mode: ${mappedMode} hsmStatus: ${location.hsmStatus}" 218 | sendLocationEvent(name: "hsmSetArm", value: hsmMode.set) 219 | } 220 | 221 | if (mappedMode == "off" && cancelAlertsOnDisarm) { 222 | sendLocationEvent(name: "hsmSetArm", value: "cancelAlerts") 223 | } 224 | } 225 | } 226 | } 227 | 228 | if (deviceInfo.siren != null) { 229 | final String alarm = deviceInfo.siren.state == "on" ? "siren" : "off" 230 | 231 | if (checkChanged("alarm", alarm)) { 232 | if (alarm != "off") { 233 | sendEvent(name: "countdownTimeLeft", value: 0) 234 | sendEvent(name: "countdownTotal", value: 0) 235 | checkChanged("entryDelay", "inactive") 236 | } 237 | } 238 | } 239 | 240 | // Use containsKey instead of null chuck because alarmInfo == null means an alarm was cleared 241 | if (deviceInfo.containsKey('alarmInfo')) { 242 | // @note Other possible values of alarmInfo.state: 'panic' 243 | 244 | final alarmInfo = deviceInfo.alarmInfo?.state 245 | checkChanged("entryDelay", alarmInfo == "entry-delay" ? "active" : "inactive") 246 | 247 | // These duplicate what the co/smoke alarm devices already display 248 | checkChanged("coAlarm", alarmInfo == "co-alarm" ? "active" : "inactive") 249 | checkChanged("fireAlarm", alarmInfo == "fire-alarm" ? "active" : "inactive") 250 | } 251 | 252 | // Use containsKey instead of null chuck because lastConnectivityCheckError == null means an connectivity error was resolved 253 | if (deviceInfo.containsKey('lastConnectivityCheckError')) { 254 | if (deviceInfo.lastConnectivityCheckError) { 255 | log.error "Ring connectivity error: ${deviceInfo.lastConnectivityCheckError}" 256 | } else { 257 | log.info "Ring connectivity error resolved." 258 | } 259 | } 260 | 261 | // Use containsKey instead of null chuck because transitionDelayEndTimestamp == null means the exit delay ended 262 | if (deviceInfo.containsKey('transitionDelayEndTimestamp')) { 263 | checkChanged("exitDelay", deviceInfo.transitionDelayEndTimestamp != null ? "active" : "inactive") 264 | } 265 | 266 | if (deviceInfo.networks != null) { 267 | final Map networks = deviceInfo.networks 268 | 269 | if (deviceInfo.containsKey('networkConnection')) { 270 | final networkConnection = deviceInfo.networkConnection 271 | 272 | checkChanged("networkConnection", networks.getOrDefault(networkConnection, [type: "unknown"]).type) 273 | } 274 | 275 | for (final entry in networks.subMap(['eth0', 'ppp0', 'wlan0'])) { 276 | final Map network = entry.value 277 | final String networkKey = entry.key 278 | final String networkType = network.type 279 | 280 | // Sometimes the type isn't included. Just skip updating things for now 281 | if (!networkType) { 282 | logDebug "Could not get network.type for ${networkKey}: ${networks}" 283 | continue 284 | } 285 | 286 | checkChangedDataValue(networkKey + "Type", networkType) 287 | 288 | String fullNetworkStr 289 | 290 | if (networkKey == 'eth0') { 291 | fullNetworkStr = 'connected' 292 | } 293 | else { 294 | String name = "" 295 | 296 | if (networkKey == 'ppp0') { 297 | name = network.name ?: device.getDataValue(networkKey + "Name") 298 | checkChangedDataValue(networkKey + "Name", name) 299 | } 300 | else if (networkKey == 'wlan0') { 301 | name = network.ssid ?: device.getDataValue(networkKey + "Ssid") 302 | checkChangedDataValue(networkKey + "Ssid", name) 303 | } 304 | 305 | String networkRssi = network.rssi ?: device.getDataValue(networkKey + "Rssi") 306 | checkChangedDataValue(networkKey + "Rssi", networkRssi) 307 | 308 | fullNetworkStr = name + " RSSI " + networkRssi 309 | } 310 | 311 | logInfo "${networkKey} ${networkType} ${fullNetworkStr}" 312 | checkChanged(networkType, fullNetworkStr) 313 | state[networkKey] = fullNetworkStr 314 | } 315 | } 316 | 317 | if (deviceInfo.acStatus != null) { 318 | final acStatus = deviceInfo.acStatus 319 | checkChanged("acStatus", AC_STATUS.getOrDefault(acStatus, "brownout")) 320 | checkChanged("powerSource", POWER_SOURCE.getOrDefault(acStatus, "unknown")) 321 | } 322 | 323 | if (deviceInfo.volume != null) { 324 | final Integer volume = deviceInfo.volume 325 | 326 | Integer prevVolume = device.currentValue("volume") 327 | 328 | if (checkChanged("volume", volume)) { 329 | state.prevVolume == prevVolume 330 | if (volume == 0) { 331 | checkChanged("mute", "muted") 332 | } else { 333 | checkChanged("mute", "unmuted") 334 | } 335 | } 336 | } 337 | 338 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 339 | for (final entry in deviceInfo.subMap(["batteryBackup", "batteryStatus", "brightness", "commStatus", "connectionStatus", "firmware", "tamper"])) { 340 | checkChanged(entry.key, entry.value) 341 | } 342 | 343 | // Update state values 344 | Map stateValues = deviceInfo.subMap(['lastNetworkLatencyEvent', 'lastUpdate', 'impulseType']) 345 | if (stateValues) { 346 | state << stateValues 347 | } 348 | } 349 | 350 | void setPassthruValues(final Map deviceInfo) { 351 | logDebug "setPassthruValues(${deviceInfo})" 352 | 353 | if (deviceInfo.percent != null) { 354 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 355 | } 356 | 357 | if (deviceInfo.transition != null) { 358 | checkChanged("exitDelay", deviceInfo.transition == "exit" ? "active" : "inactive") 359 | sendEvent(name: "countdownTimeLeft", value: deviceInfo.timeLeft) 360 | sendEvent(name: "countdownTotal", value: deviceInfo.total) 361 | } 362 | } 363 | 364 | void runCleanup() { 365 | state.remove('lastCommTime') 366 | state.remove('nextExpectedWakeup') 367 | state.remove('signalStrength') 368 | 369 | device.removeDataValue('firmware') // Is an attribute now 370 | device.removeDataValue('softwareVersion') // Is an attribute now 371 | 372 | device.removeDataValue('fingerprint') // Hub doesn't appear to have a fingerprint. Previously value was coming from dataType access-code, which doesn't make sense 373 | device.removeDataValue('null-zid') 374 | device.removeDataValue('access-code.vault-zid') 375 | device.removeDataValue('adapter.zigbee-zid') 376 | device.removeDataValue('adapter.zwave-zid') 377 | } 378 | 379 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 380 | final boolean changed = device.currentValue(attribute) != newStatus 381 | if (changed) { 382 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 383 | } 384 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 385 | return changed 386 | } 387 | 388 | void checkChangedDataValue(final String name, final value) { 389 | if (device.getDataValue(name) != value) { 390 | device.updateDataValue(name, value) 391 | } 392 | } 393 | 394 | @Field final static Integer VOLUME_INC = 5 395 | 396 | @Field final static Map RING_TO_HSM_MODE_MAP = [ 397 | "home": [set: "armHome", status: "armedHome"], 398 | "away": [set: "armAway", status: "armedAway"], 399 | "off": [set: "disarm", status: "disarmed"] 400 | ].asImmutable() 401 | 402 | @Field final static Map AC_STATUS = [ 403 | ok: "connected", 404 | error: "disconnected", 405 | ].asImmutable() 406 | 407 | @Field final static Map POWER_SOURCE = [ 408 | ok: "mains", 409 | error: "battery", 410 | ].asImmutable() 411 | 412 | @Field final static Map MODES = [ 413 | none: "off", 414 | some: "home", 415 | all: "away" 416 | ].asImmutable() -------------------------------------------------------------------------------- /src/drivers/ring-virtual-alarm-range-extender.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Alarm Range Extender Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | import groovy.transform.Field 18 | 19 | metadata { 20 | definition(name: "Ring Virtual Alarm Range Extender", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 21 | capability "Battery" 22 | capability "PowerSource" 23 | capability "Refresh" 24 | capability "Sensor" 25 | capability "TamperAlert" 26 | 27 | attribute "acStatus", "enum", ["brownout", "connected", "disconnected"] 28 | attribute "batteryStatus", "enum", ["charged", "charging", "failed", "full", "low", "malfunction", "none", "ok", "warn"] 29 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 30 | attribute "firmware", "string" 31 | } 32 | 33 | preferences { 34 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 35 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 36 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 37 | } 38 | } 39 | 40 | void logInfo(msg) { 41 | if (descriptionTextEnable) { log.info msg } 42 | } 43 | 44 | void logDebug(msg) { 45 | if (logEnable) { log.debug msg } 46 | } 47 | 48 | void logTrace(msg) { 49 | if (traceLogEnable) { log.trace msg } 50 | } 51 | 52 | void refresh() { 53 | parent.refresh(device.getDataValue("src")) 54 | } 55 | 56 | void setValues(final Map deviceInfo) { 57 | logDebug "setValues(${deviceInfo})" 58 | 59 | if (deviceInfo.acStatus != null) { 60 | final String acStatus = deviceInfo.acStatus 61 | checkChanged("acStatus", AC_STATUS.getOrDefault(acStatus, "brownout")) 62 | checkChanged("powerSource", POWER_SOURCE.getOrDefault(acStatus, "unknown")) 63 | } 64 | 65 | if (deviceInfo.batteryLevel != null) { 66 | checkChanged("battery", deviceInfo.batteryLevel, "%") 67 | } 68 | 69 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 70 | for (final entry in deviceInfo.subMap(["batteryStatus", "commStatus", "firmware", "tamper"])) { 71 | checkChanged(entry.key, entry.value) 72 | } 73 | 74 | // Update state values 75 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'signalStrength']) 76 | if (stateValues) { 77 | state << stateValues 78 | } 79 | } 80 | 81 | void setPassthruValues(final Map deviceInfo) { 82 | logDebug "setPassthruValues(${deviceInfo})" 83 | 84 | if (deviceInfo.percent != null) { 85 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 86 | } 87 | } 88 | 89 | void runCleanup() { 90 | state.remove('nextExpectedWakeup') 91 | device.removeDataValue('firmware') // Is an attribute now 92 | } 93 | 94 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 95 | final boolean changed = device.currentValue(attribute) != newStatus 96 | if (changed) { 97 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 98 | } 99 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 100 | return changed 101 | } 102 | 103 | @Field final static Map AC_STATUS = [ 104 | ok: "connected", 105 | error: "disconnected", 106 | ].asImmutable() 107 | 108 | @Field final static Map POWER_SOURCE = [ 109 | ok: "mains", 110 | error: "battery", 111 | ].asImmutable() -------------------------------------------------------------------------------- /src/drivers/ring-virtual-alarm-smoke-co-listener.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Alarm Smoke & CO Listener Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | import groovy.transform.Field 18 | 19 | metadata { 20 | definition(name: "Ring Virtual Alarm Smoke & CO Listener", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 21 | capability "Battery" 22 | capability "CarbonMonoxideDetector" 23 | capability "Refresh" 24 | capability "Sensor" 25 | capability "SmokeDetector" 26 | capability "TamperAlert" 27 | 28 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 29 | attribute "firmware", "string" 30 | attribute "listeningCarbonMonoxide", "enum", ["listening", "inactive"] 31 | attribute "listeningSmoke", "enum", ["listening", "inactive"] 32 | attribute "testMode", "string" 33 | } 34 | 35 | preferences { 36 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 37 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 38 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 39 | } 40 | } 41 | 42 | void logInfo(msg) { 43 | if (descriptionTextEnable) { log.info msg } 44 | } 45 | 46 | void logDebug(msg) { 47 | if (logEnable) { log.debug msg } 48 | } 49 | 50 | void logTrace(msg) { 51 | if (traceLogEnable) { log.trace msg } 52 | } 53 | 54 | void refresh() { 55 | parent.refresh(device.getDataValue("src")) 56 | } 57 | 58 | void setValues(final Map deviceInfo) { 59 | logDebug "setValues(${deviceInfo})" 60 | 61 | if (deviceInfo.co != null) { 62 | final Map co = deviceInfo.co 63 | 64 | checkChanged("carbonMonoxide", ALARM_STATUS.getOrDefault(co.alarmStatus, "tested")) 65 | state.coEnabled = co.enabledTimeMs 66 | 67 | checkChanged("listeningCarbonMonoxide", co.enabled ? "listening" : "inactive") 68 | } 69 | 70 | if (deviceInfo.smoke != null) { 71 | final Map smoke = deviceInfo.smoke 72 | 73 | checkChanged("smoke", ALARM_STATUS.getOrDefault(smoke.alarmStatus, "tested")) 74 | state.smokeEnabled = smoke.enabledTimeMs 75 | 76 | checkChanged("listeningSmoke", smoke.enabled ? "listening" : "inactive") 77 | } 78 | 79 | if (deviceInfo.pending != null) { 80 | final Map deviceInfoPending = deviceInfo.pending 81 | 82 | if (deviceInfoPending.commands) { 83 | logDebug "Device ${device.label} will set the commands ${deviceInfoPending.commands} on ${getNextExpectedWakeupString(deviceInfo)}" 84 | } 85 | } 86 | 87 | if (deviceInfo.batteryLevel != null) { 88 | checkChanged("battery", deviceInfo.batteryLevel, "%") 89 | } 90 | 91 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 92 | for (final entry in deviceInfo.subMap(["commStatus", "firmware", "tamper", "testMode"])) { 93 | checkChanged(entry.key, entry.value) 94 | } 95 | 96 | // Update state values 97 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'nextExpectedWakeup', 'signalStrength']) 98 | if (stateValues) { 99 | state << stateValues 100 | } 101 | } 102 | 103 | void setPassthruValues(final Map deviceInfo) { 104 | logDebug "setPassthruValues(${deviceInfo})" 105 | 106 | if (deviceInfo.percent != null) { 107 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 108 | } 109 | } 110 | 111 | void runCleanup() { 112 | device.removeDataValue('firmware') // Is an attribute now 113 | } 114 | 115 | // @return Next expected wakeup time as a string. 116 | // Gets value from deviceInfo first, falls back to state because nextExpectedWakeup isn't sent with every deviceInfo 117 | String getNextExpectedWakeupString(final Map deviceInfo) { 118 | final Long nextExpectedWakeup = deviceInfo.nextExpectedWakeup ?: state.nextExpectedWakeup 119 | 120 | return nextExpectedWakeup ? new Date(nextExpectedWakeup).toString() : 'unknown' 121 | } 122 | 123 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 124 | final boolean changed = device.currentValue(attribute) != newStatus 125 | if (changed) { 126 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 127 | } 128 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 129 | return changed 130 | } 131 | 132 | @Field final static Map ALARM_STATUS = [ 133 | active: 'detected', 134 | inactive: 'clear', 135 | ] -------------------------------------------------------------------------------- /src/drivers/ring-virtual-beams-bridge.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Beams Bridge Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Beams Bridge", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Refresh" 20 | capability "Sensor" 21 | 22 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 23 | attribute "connectionStatus", "enum", ["asset-cell-backup", "backing-up", "connected", "connecting", "extended-cell-backup", 24 | "restoring", "updating"] 25 | attribute "firmware", "string" 26 | attribute "networkConnection", "enum", ["unknown", "wifi"] 27 | attribute "wifi", "string" 28 | } 29 | 30 | preferences { 31 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 32 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 33 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 34 | } 35 | } 36 | 37 | void logInfo(msg) { 38 | if (descriptionTextEnable) { log.info msg } 39 | } 40 | 41 | void logDebug(msg) { 42 | if (logEnable) { log.debug msg } 43 | } 44 | 45 | void logTrace(msg) { 46 | if (traceLogEnable) { log.trace msg } 47 | } 48 | 49 | def refresh() { 50 | parent.refresh(device.getDataValue("src")) 51 | } 52 | 53 | void setValues(final Map deviceInfo) { 54 | logDebug "setValues(${deviceInfo})" 55 | 56 | if (deviceInfo.containsKey('lastConnectivityCheckError')) { 57 | if (deviceInfo.lastConnectivityCheckError) { 58 | log.error "Ring connectivity error: ${deviceInfo.lastConnectivityCheckError}" 59 | } else { 60 | log.info "Ring connectivity error resolved." 61 | } 62 | } 63 | 64 | if (deviceInfo.networks != null) { 65 | final Map networks = deviceInfo.networks 66 | 67 | if (deviceInfo.containsKey('networkConnection')) { 68 | final networkConnection = deviceInfo.networkConnection 69 | 70 | checkChanged("networkConnection", networks.getOrDefault(networkConnection, [type: "unknown"]).type) 71 | } 72 | 73 | // Beams bridge appears to only support wifi 74 | for (final String networkKey in ['wlan0']) { 75 | final Map network = networks[networkKey] 76 | if (network != null) { 77 | String networkType = network.type 78 | 79 | // Sometimes the type isn't included. Just skip updating things for now 80 | if (!networkType) { 81 | logDebug "Could not get network.type for ${networkKey}: ${networks}" 82 | continue 83 | } 84 | 85 | String networkName = network.ssid ?: device.getDataValue(networkKey + "Ssid") 86 | String networkRssi = network.rssi ?: device.getDataValue(networkKey + "Rssi") 87 | 88 | checkChangedDataValue(networkKey + "Type", networkType) 89 | checkChangedDataValue(networkKey + "Ssid", networkName) 90 | checkChangedDataValue(networkKey + "Rssi", networkRssi) 91 | 92 | final String fullNetworkStr = networkName + " RSSI " + networkRssi 93 | logInfo "${networkKey} ${networkType} ${fullNetworkStr}" 94 | checkChanged(networkType, fullNetworkStr) 95 | state[networkKey] = fullNetworkStr 96 | } 97 | } 98 | } 99 | 100 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 101 | for (final entry in deviceInfo.subMap(["commStatus", "connectionStatus", "firmware"])) { 102 | checkChanged(entry.key, entry.value) 103 | } 104 | 105 | // Update state values 106 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastUpdate']) 107 | if (stateValues) { 108 | state << stateValues 109 | } 110 | } 111 | 112 | void setPassthruValues(final Map deviceInfo) { 113 | logDebug "setPassthruValues(${deviceInfo})" 114 | 115 | if (deviceInfo.percent != null) { 116 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 117 | } 118 | } 119 | 120 | void runCleanup() { 121 | device.removeDataValue('nordicFirmwareVersion') // Is an attribute now 122 | device.removeDataValue('softwareVersion') // Is an attribute now 123 | device.removeDataValue('version') // Is an attribute now 124 | state.remove('lastCommTime') 125 | } 126 | 127 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 128 | final boolean changed = device.currentValue(attribute) != newStatus 129 | if (changed) { 130 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 131 | } 132 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 133 | return changed 134 | } 135 | 136 | void checkChangedDataValue(final String name, final value) { 137 | if (device.getDataValue(name) != value) { 138 | device.updateDataValue(name, value) 139 | } 140 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-beams-group.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Beams Group Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Beams Group", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Battery" 20 | capability "Motion Sensor" 21 | capability "Refresh" 22 | capability "Sensor" 23 | capability "Switch" 24 | 25 | command "on", [[name: "Duration", type: "NUMBER", range: "0..28800", description: "Choose a value between 0 and 28800 seconds"]] 26 | } 27 | 28 | preferences { 29 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 30 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 31 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 32 | } 33 | } 34 | 35 | void logInfo(msg) { 36 | if (descriptionTextEnable) { log.info msg } 37 | } 38 | 39 | void logDebug(msg) { 40 | if (logEnable) { log.debug msg } 41 | } 42 | 43 | void logTrace(msg) { 44 | if (traceLogEnable) { log.trace msg } 45 | } 46 | 47 | def refresh() { 48 | parent.refresh(device.getDataValue("src")) 49 | } 50 | 51 | def on(duration = 60) { 52 | parent.apiWebsocketRequestSetCommand("light-mode.set", device.getDataValue("src"), device.getDataValue("zid"), [lightMode: "on", duration: duration]) 53 | } 54 | 55 | def off() { 56 | parent.apiWebsocketRequestSetCommand("light-mode.set", device.getDataValue("src"), device.getDataValue("zid"), [lightMode: "default"]) 57 | } 58 | 59 | void setValues(final Map deviceInfo) { 60 | logDebug "setValues(${deviceInfo})" 61 | 62 | if (deviceInfo.groupMembers) { 63 | Map members = [:] 64 | for (final String groupMemeber in deviceInfo.groupMembers) { 65 | def d = parent.getChildByZID(groupMemeber) 66 | if (d) { 67 | members[d.deviceNetworkId] = d.label 68 | } else { 69 | log.warn "Device ${groupMemeber} isn't created in Hubitat and will not be included in this group's members." 70 | } 71 | } 72 | state.members = members 73 | } 74 | 75 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 76 | for (final entry in deviceInfo.subMap(["motion", "switch"])) { 77 | checkChanged(entry.key, entry.value) 78 | } 79 | 80 | // Update state values 81 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastUpdate']) 82 | if (stateValues) { 83 | state << stateValues 84 | } 85 | } 86 | 87 | void setPassthruValues(final Map deviceInfo) { 88 | logDebug "setPassthruValues(${deviceInfo})" 89 | } 90 | 91 | void runCleanup() { 92 | state.remove('lastCommTime') 93 | } 94 | 95 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 96 | final boolean changed = device.currentValue(attribute) != newStatus 97 | if (changed) { 98 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 99 | } 100 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 101 | return changed 102 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-beams-light.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Beams Light Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | import groovy.transform.Field 18 | 19 | metadata { 20 | definition(name: "Ring Virtual Beams Light", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 21 | capability "Battery" 22 | capability "Motion Sensor" 23 | capability "Refresh" 24 | capability "Sensor" 25 | capability "Switch" 26 | 27 | attribute "brightness", "number" 28 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 29 | attribute "firmware", "string" 30 | attribute "rfChannel", "number" 31 | attribute "rssi", "number" 32 | attribute "sensitivity", "enum", ["low", "medium", "high", "custom2", "custom4"] 33 | 34 | command "on", [[name: "Duration", type: "NUMBER", range: "0..28800", description: "Choose a value between 0 and 28800 seconds"]] 35 | command "setBrightness", [[name: "Set LED Brightness*", type: "NUMBER", range: "0..100", description: "Choose a value between 0 and 100"]] 36 | command "setSensitivity", [[name: "mode", type: "ENUM", constraints: ["low", "medium", "high", "custom2", "custom4"], description: "Set motion sensor sensitivity"]] 37 | } 38 | 39 | preferences { 40 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 41 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 42 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 43 | } 44 | } 45 | 46 | void logInfo(msg) { 47 | if (descriptionTextEnable) { log.info msg } 48 | } 49 | 50 | void logDebug(msg) { 51 | if (logEnable) { log.debug msg } 52 | } 53 | 54 | void logTrace(msg) { 55 | if (traceLogEnable) { log.trace msg } 56 | } 57 | 58 | def refresh() { 59 | parent.refresh(device.getDataValue("src")) 60 | } 61 | 62 | def on(duration = 60) { 63 | parent.apiWebsocketRequestSetCommand("light-mode.set", device.getDataValue("src"), device.getDataValue("zid"), [lightMode: "on", duration: duration]) 64 | } 65 | 66 | def off() { 67 | parent.apiWebsocketRequestSetCommand("light-mode.set", device.getDataValue("src"), device.getDataValue("zid"), [lightMode: "default"]) 68 | } 69 | 70 | def setBrightness(brightness) { 71 | if (NO_BRIGHTNESS_DEVICES.contains(device.getDataValue("fingerprint"))) { 72 | log.error "This device doesn't support brightness!" 73 | return 74 | } 75 | parent.apiWebsocketRequestSetDevice(device.getDataValue("src"), device.getDataValue("zid"), 76 | [level: ((brightness == null ? 100 : brightness).toDouble() / 100)]) 77 | } 78 | 79 | void setSensitivity(String sensitivity) { 80 | Integer ringSensitivity = MOTION_SENSITIVITY.find { it.value == sensitivity }?.key 81 | 82 | if (ringSensitivity == null) { 83 | log.error "Could not map ${sensitivity} to value ring expects" 84 | return 85 | } 86 | 87 | parent.apiWebsocketRequestSetDevice(device.getDataValue("src"), device.getDataValue("zid"), [sensitivity: ringSensitivity]) 88 | } 89 | 90 | void setValues(final Map deviceInfo) { 91 | logDebug "setValues(${deviceInfo})" 92 | 93 | if (deviceInfo.level != null && !NO_BRIGHTNESS_DEVICES.contains(device.getDataValue("fingerprint"))) { 94 | checkChanged("brightness", deviceInfo.level) 95 | } 96 | 97 | if (deviceInfo.batteryLevel != null && !NO_BATTERY_DEVICES.contains(device.getDataValue("fingerprint"))) { 98 | checkChanged("battery", deviceInfo.batteryLevel, "%") 99 | } 100 | 101 | if (deviceInfo.sensitivity != null) { 102 | checkChanged("sensitivity", MOTION_SENSITIVITY[deviceInfo.sensitivity]) 103 | } 104 | 105 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 106 | for (final entry in deviceInfo.subMap(["commStatus", "firmware", "motion", "rfChannel", "rssi", "switch"])) { 107 | checkChanged(entry.key, entry.value) 108 | } 109 | 110 | // Update state values 111 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastUpdate']) 112 | if (stateValues) { 113 | state << stateValues 114 | } 115 | } 116 | 117 | void setPassthruValues(final Map deviceInfo) { 118 | logDebug "setPassthruValues(${deviceInfo})" 119 | 120 | if (deviceInfo.percent != null) { 121 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 122 | } 123 | } 124 | 125 | void runCleanup() { 126 | device.removeDataValue('firmware') // Is an attribute now 127 | state.remove('lastCommTime') 128 | state.remove('signalStrength') 129 | state.remove('nextExpectedWakeup') 130 | } 131 | 132 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 133 | final boolean changed = device.currentValue(attribute) != newStatus 134 | if (changed) { 135 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 136 | } 137 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 138 | return changed 139 | } 140 | 141 | @Field final Set NO_BATTERY_DEVICES = ["ring-beams-c5000"].toSet().asImmutable() 142 | @Field final Set NO_BRIGHTNESS_DEVICES = ["ring-beams-c5000"].toSet().asImmutable() 143 | 144 | @Field final static Map MOTION_SENSITIVITY = [ 145 | 0: 'high', // Custom 5 146 | 63: 'custom4', 147 | 127: 'medium', // Custom 3 148 | 191: 'custom2', 149 | 255: 'low', // Custom 1 150 | ].asImmutable() -------------------------------------------------------------------------------- /src/drivers/ring-virtual-beams-motion-sensor.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Beams Motion Sensor Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | import groovy.transform.Field 18 | 19 | metadata { 20 | definition(name: "Ring Virtual Beams Motion Sensor", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 21 | capability "Battery" 22 | capability "Motion Sensor" 23 | capability "Refresh" 24 | capability "Sensor" 25 | 26 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 27 | attribute "firmware", "string" 28 | attribute "rfChannel", "number" 29 | attribute "rssi", "number" 30 | attribute "sensitivity", "enum", ["low", "medium", "high", "custom2", "custom4"] 31 | 32 | command "setSensitivity", [[name: "mode", type: "ENUM", constraints: ["low", "medium", "high", "custom2", "custom4"], description: "Set motion sensor sensitivity"]] 33 | } 34 | 35 | preferences { 36 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 37 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 38 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 39 | } 40 | } 41 | 42 | void logInfo(msg) { 43 | if (descriptionTextEnable) { log.info msg } 44 | } 45 | 46 | void logDebug(msg) { 47 | if (logEnable) { log.debug msg } 48 | } 49 | 50 | void logTrace(msg) { 51 | if (traceLogEnable) { log.trace msg } 52 | } 53 | 54 | def refresh() { 55 | parent.refresh(device.getDataValue("src")) 56 | } 57 | 58 | void setSensitivity(String sensitivity) { 59 | Integer ringSensitivity = MOTION_SENSITIVITY.find { it.value == sensitivity }?.key 60 | 61 | if (ringSensitivity == null) { 62 | log.error "Could not map ${sensitivity} to value ring expects" 63 | return 64 | } 65 | 66 | parent.apiWebsocketRequestSetDevice(device.getDataValue("src"), device.getDataValue("zid"), [sensitivity: ringSensitivity]) 67 | } 68 | 69 | void setValues(final Map deviceInfo) { 70 | logDebug "setValues(${deviceInfo})" 71 | 72 | if (deviceInfo.batteryLevel != null) { 73 | checkChanged("battery", deviceInfo.batteryLevel, "%") 74 | } 75 | 76 | if (deviceInfo.sensitivity != null) { 77 | checkChanged("sensitivity", MOTION_SENSITIVITY[deviceInfo.sensitivity]) 78 | } 79 | 80 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 81 | for (final entry in deviceInfo.subMap(["commStatus", "firmware", "motion", "rfChannel", "rssi"])) { 82 | checkChanged(entry.key, entry.value) 83 | } 84 | 85 | // Update state values 86 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastUpdate']) 87 | if (stateValues) { 88 | state << stateValues 89 | } 90 | } 91 | 92 | void setPassthruValues(final Map deviceInfo) { 93 | logDebug "setPassthruValues(${deviceInfo})" 94 | 95 | if (deviceInfo.percent != null) { 96 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 97 | } 98 | } 99 | 100 | void runCleanup() { 101 | device.removeDataValue('firmware') // Is an attribute now 102 | state.remove('lastCommTime') 103 | state.remove('signalStrength') 104 | state.remove('nextExpectedWakeup') 105 | } 106 | 107 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 108 | final boolean changed = device.currentValue(attribute) != newStatus 109 | if (changed) { 110 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 111 | } 112 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 113 | return changed 114 | } 115 | 116 | @Field final static Map MOTION_SENSITIVITY = [ 117 | 0: 'high', // Custom 5 118 | 63: 'custom4', 119 | 127: 'medium', // Custom 3 120 | 191: 'custom2', 121 | 255: 'low', // Custom 1 122 | ] -------------------------------------------------------------------------------- /src/drivers/ring-virtual-camera-with-siren.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Camera with Siren Device Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Camera with Siren", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Alarm" 20 | capability "Actuator" 21 | capability "Battery" 22 | capability "MotionSensor" 23 | capability "Polling" 24 | capability "PushableButton" 25 | capability "Refresh" 26 | capability "Sensor" 27 | 28 | attribute "firmware", "string" 29 | attribute "rssi", "number" 30 | attribute "wifi", "string" 31 | 32 | command "getDings" 33 | } 34 | 35 | preferences { 36 | input name: "snapshotPolling", type: "bool", title: "Enable polling for thumbnail snapshots on this device", defaultValue: false 37 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 38 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 39 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 40 | } 41 | } 42 | 43 | void logInfo(msg) { 44 | if (descriptionTextEnable) { log.info msg } 45 | } 46 | 47 | void logDebug(msg) { 48 | if (logEnable) { log.debug msg } 49 | } 50 | 51 | void logTrace(msg) { 52 | if (traceLogEnable) { log.trace msg } 53 | } 54 | 55 | def parse(String description) { 56 | logDebug "description: ${description}" 57 | } 58 | 59 | def poll() { 60 | refresh() 61 | } 62 | 63 | def refresh() { 64 | logDebug "refresh()" 65 | parent.apiRequestDeviceRefresh(device.deviceNetworkId) 66 | parent.apiRequestDeviceHealth(device.deviceNetworkId, "doorbots") 67 | } 68 | 69 | def getDings() { 70 | logDebug "getDings()" 71 | parent.apiRequestDings() 72 | } 73 | 74 | def updated() { 75 | parent.snapshotOption(device.deviceNetworkId, snapshotPolling) 76 | } 77 | 78 | def off() { 79 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "siren_off") 80 | } 81 | 82 | def siren() { 83 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "siren_on") 84 | } 85 | 86 | def strobe(value = "strobe") { 87 | log.error "Strobe not implemented for device type ${device.getDataValue("kind")}" 88 | } 89 | 90 | def both() { 91 | log.error "Both (strobe and siren) not implemented for device type ${device.getDataValue("kind")}" 92 | } 93 | 94 | def push(Integer button) { 95 | log.error "Push not implemented for device type ${device.getDataValue("kind")}" 96 | } 97 | 98 | void handleDeviceSet(final String action, final Map msg, final Map query) { 99 | if (action == "siren_on") { 100 | if (device.currentValue("alarm") != "both") { 101 | checkChanged("alarm", "siren") 102 | } 103 | 104 | runIn(msg.seconds_remaining + 1, refresh) 105 | } 106 | else if (action == "siren_off") { 107 | checkChanged('alarm', "off") 108 | } 109 | else { 110 | log.error "handleDeviceSet unsupported action ${action}, msg=${msg}, query=${query}" 111 | } 112 | } 113 | 114 | void handleHealth(final Map msg) { 115 | if (msg.device_health) { 116 | if (msg.device_health.wifi_name) { 117 | checkChanged("wifi", msg.device_health.wifi_name) 118 | } 119 | } 120 | } 121 | 122 | void handleMotion(final Map msg) { 123 | if (msg.motion == true) { 124 | checkChanged("motion", "active") 125 | 126 | runIn(60, motionOff) // We don't get motion off msgs from ifttt, and other motion only happens on a manual refresh 127 | } 128 | else if (msg.motion == false) { 129 | checkChanged("motion", "inactive") 130 | unschedule(motionOff) 131 | } 132 | else { 133 | log.error("handleMotion unsupported msg: ${msg}") 134 | } 135 | } 136 | 137 | void handleRefresh(final Map msg) { 138 | if (msg.battery_life != null) { 139 | checkChanged("battery", msg.battery_life, '%') 140 | } 141 | else if (msg.battery_life_2 != null) { 142 | checkChanged("battery", msg.battery_life_2, "%") 143 | } 144 | if (msg.siren_status?.seconds_remaining != null) { 145 | final Integer secondsRemaining = msg.siren_status.seconds_remaining 146 | checkChanged("alarm", secondsRemaining > 0 ? "siren" : "off") 147 | if (secondsRemaining > 0) { 148 | runIn(secondsRemaining + 1, refresh) 149 | } 150 | } 151 | if (msg.health) { 152 | final Map health = msg.health 153 | 154 | if (health.firmware_version) { 155 | checkChanged("firmware", health.firmware_version) 156 | } 157 | 158 | if (health.rssi) { 159 | checkChanged("rssi", health.rssi) 160 | } 161 | } 162 | } 163 | 164 | void motionOff() { 165 | checkChanged("motion", "inactive") 166 | } 167 | 168 | void runCleanup() { 169 | device.removeDataValue("firmware") // Is an attribute now 170 | device.removeDataValue("device_id") 171 | } 172 | 173 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 174 | final boolean changed = device.currentValue(attribute) != newStatus 175 | if (changed) { 176 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 177 | } 178 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 179 | return changed 180 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-camera.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Camera Device Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Camera", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Actuator" 20 | capability "Battery" 21 | capability "MotionSensor" 22 | capability "Polling" 23 | capability "PushableButton" 24 | capability "Refresh" 25 | capability "Sensor" 26 | 27 | attribute "firmware", "string" 28 | attribute "rssi", "number" 29 | attribute "wifi", "string" 30 | 31 | command "getDings" 32 | } 33 | 34 | preferences { 35 | input name: "snapshotPolling", type: "bool", title: "Enable polling for thumbnail snapshots on this device", defaultValue: false 36 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 37 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 38 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 39 | } 40 | } 41 | 42 | void logInfo(msg) { 43 | if (descriptionTextEnable) { log.info msg } 44 | } 45 | 46 | void logDebug(msg) { 47 | if (logEnable) { log.debug msg } 48 | } 49 | 50 | void logTrace(msg) { 51 | if (traceLogEnable) { log.trace msg } 52 | } 53 | 54 | def updated() { 55 | checkChanged("numberOfButtons", 1) 56 | parent.snapshotOption(device.deviceNetworkId, snapshotPolling) 57 | } 58 | 59 | def parse(String description) { 60 | logDebug "description: ${description}" 61 | } 62 | 63 | def poll() { 64 | refresh() 65 | } 66 | 67 | void push(buttonNumber) { 68 | log.error "Not implemented! push(buttonNumber)" 69 | } 70 | 71 | def refresh() { 72 | logDebug "refresh()" 73 | parent.apiRequestDeviceRefresh(device.deviceNetworkId) 74 | parent.apiRequestDeviceHealth(device.deviceNetworkId, "doorbots") 75 | } 76 | 77 | def getDings() { 78 | logDebug "getDings()" 79 | parent.apiRequestDings() 80 | } 81 | 82 | void handleDing(final Map msg) { 83 | logInfo "${device.label} button 1 was pushed" 84 | sendEvent(name: "pushed", value: 1, isStateChange: true) 85 | } 86 | 87 | void handleHealth(final Map msg) { 88 | if (msg.device_health) { 89 | if (msg.device_health.wifi_name) { 90 | checkChanged("wifi", msg.device_health.wifi_name) 91 | } 92 | } 93 | } 94 | 95 | void handleMotion(final Map msg) { 96 | if (msg.motion == true) { 97 | checkChanged("motion", "active") 98 | 99 | runIn(60, motionOff) // We don't get motion off msgs from ifttt, and other motion only happens on a manual refresh 100 | } 101 | else if (msg.motion == false) { 102 | checkChanged("motion", "inactive") 103 | unschedule(motionOff) 104 | } 105 | else { 106 | log.error("handleMotion unsupported msg: ${msg}") 107 | } 108 | } 109 | 110 | void handleRefresh(final Map msg) { 111 | if (!["jbox_v1", "lpd_v1", "lpd_v2"].contains(device.getDataValue("kind"))) { 112 | if (msg.battery_life != null) { 113 | checkChanged("battery", msg.battery_life, '%') 114 | } 115 | else if (msg.battery_life_2 != null) { 116 | checkChanged("battery", msg.battery_life_2, "%") 117 | } 118 | } 119 | 120 | if (msg.health) { 121 | Map health = msg.health 122 | 123 | if (health.firmware_version) { 124 | checkChanged("firmware", health.firmware_version) 125 | } 126 | 127 | if (health.rssi) { 128 | checkChanged("rssi", health.rssi) 129 | } 130 | } 131 | } 132 | 133 | void motionOff() { 134 | checkChanged("motion", "inactive") 135 | } 136 | 137 | void runCleanup() { 138 | device.removeDataValue("firmware") // Is an attribute now 139 | device.removeDataValue("device_id") 140 | } 141 | 142 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 143 | final boolean changed = device.currentValue(attribute) != newStatus 144 | if (changed) { 145 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 146 | } 147 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 148 | return changed 149 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-chime.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Chime Device Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | // @todo Consider using /ringtones 18 | // @todo Consider being able to set do_not_disturb 19 | 20 | import groovy.transform.Field 21 | 22 | metadata { 23 | definition(name: "Ring Virtual Chime", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 24 | capability "Actuator" 25 | capability "AudioNotification" 26 | capability "AudioVolume" 27 | capability "Refresh" 28 | capability "Polling" 29 | capability "Tone" 30 | 31 | attribute "rssi", "number" 32 | attribute "wifi", "string" 33 | 34 | command "playDing" 35 | command "playMotion" 36 | } 37 | 38 | preferences { 39 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 40 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 41 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 42 | } 43 | } 44 | 45 | void logInfo(msg) { 46 | if (descriptionTextEnable) { log.info msg } 47 | } 48 | 49 | void logDebug(msg) { 50 | if (logEnable) { log.debug msg } 51 | } 52 | 53 | void logTrace(msg) { 54 | if (traceLogEnable) { log.trace msg } 55 | } 56 | 57 | def parse(String description) { 58 | logDebug "description: ${description}" 59 | } 60 | 61 | def poll() { 62 | logDebug "poll()" 63 | refresh() 64 | } 65 | 66 | def refresh() { 67 | logDebug "refresh()" 68 | parent.apiRequestDeviceRefresh(device.deviceNetworkId) 69 | parent.apiRequestDeviceHealth(device.deviceNetworkId, "chimes") 70 | } 71 | 72 | void beep() { playMotion() } 73 | 74 | void playMotion() { 75 | if (isMuted()) { 76 | logInfo "playMotion: Not playing because device is muted" 77 | } else { 78 | parent.apiRequestDeviceControl(device.deviceNetworkId, "chimes", "play_sound", [kind: "motion"]) 79 | } 80 | } 81 | 82 | void playDing() { 83 | if (isMuted()) { 84 | logInfo "playDing: Not playing because device is muted" 85 | } else { 86 | parent.apiRequestDeviceControl(device.deviceNetworkId, "chimes", "play_sound", [kind: "ding"]) 87 | } 88 | } 89 | 90 | void setVolume(volumelevel) { 91 | // Value must be in [0, 100] 92 | volumelevel = Math.min(Math.max(volumelevel == null ? 50 : volumelevel.toInteger(), 0), 100) 93 | 94 | Integer currentVolume = device.currentValue("volume") 95 | 96 | if (currentVolume != volumelevel) { 97 | logTrace "requesting volume change to ${volumelevel}" 98 | 99 | final Integer sentValue = volumelevel / 10 100 | 101 | parent.apiRequestDeviceSet(device.deviceNetworkId, "chimes", null, ["chime[settings][volume]": sentValue]) 102 | } 103 | else { 104 | logInfo "Already at volume." 105 | sendEvent(name: "volume", value: currentVolume) 106 | } 107 | } 108 | 109 | void volumeUp() { 110 | Integer currentVolume = device.currentValue("volume") 111 | Integer nextVol = currentVolume + VOLUME_INC 112 | if (nextVol <= 100) { 113 | setVolume(nextVol) 114 | } 115 | else { 116 | logInfo "Already max volume." 117 | sendEvent(name: "volume", value: currentVolume) 118 | } 119 | } 120 | 121 | void volumeDown() { 122 | Integer currentVolume = device.currentValue("volume") 123 | Integer nextVol = currentVolume - VOLUME_INC 124 | if (nextVol >= 0) { 125 | setVolume(nextVol) 126 | } 127 | else { 128 | logInfo "Already min volume." 129 | sendEvent(name: "volume", value: currentVolume) 130 | } 131 | } 132 | 133 | void mute() { 134 | setVolume(0) 135 | } 136 | 137 | void unmute() { 138 | setVolume(state.prevVolume) 139 | } 140 | 141 | void updateVolumeInternal(volume) { 142 | Integer prevVolume = device.currentValue("volume") 143 | 144 | volume = volume.toInteger() * 10 145 | 146 | if (checkChanged("volume", volume)) { 147 | state.prevVolume == prevVolume 148 | if (volume == 0) { 149 | checkChanged("mute", "muted") 150 | } else { 151 | checkChanged("mute", "unmuted") 152 | } 153 | } 154 | } 155 | 156 | void playText(text, volumelevel) { log.error "playText not implemented!" } 157 | void playTextAndRestore(text, volumelevel) { log.error "playTextAndRestore not implemented!" } 158 | void playTextAndResume(text, volumelevel) { log.error "playTextAndResume not implemented!" } 159 | def playTrack(trackuri, volumelevel) { log.error "playTrack not implemented!" } 160 | def playTrackAndRestore(trackuri, volumelevel) { log.error "playTrackAndRestore not implemented!" } 161 | def playTrackAndResume(trackuri, volumelevel) { log.error "playTrackAndResume not implemented!" } 162 | 163 | private boolean isMuted() { 164 | return device.currentValue("mute") == "muted" 165 | } 166 | 167 | void handleDeviceControl(final String action, final Map msg, final Map query) { 168 | if (action == "play_sound") { 169 | if (query?.kind) { 170 | logInfo "Device ${device.label} played '${query?.kind}'" 171 | } 172 | else { 173 | log.error "handleDeviceControl unsupported play_sound with query ${query}" 174 | } 175 | } 176 | else { 177 | log.error "handleDeviceControl unsupported action ${action}" 178 | } 179 | } 180 | 181 | void handleDeviceSet(final String action, final Map msg, final Map query) { 182 | if (action == null) { 183 | if (query?.containsKey("chime[settings][volume]")) { 184 | updateVolumeInternal(query["chime[settings][volume]"]) 185 | } 186 | else { 187 | log.error "handleDeviceSet unsupported null action with query ${query}" 188 | } 189 | } 190 | else { 191 | log.error "handleDeviceSet unsupported action ${action}, msg=${msg}, query=${query}" 192 | } 193 | } 194 | 195 | void handleHealth(final Map msg) { 196 | if (msg.device_health) { 197 | if (msg.device_health.wifi_name) { 198 | checkChanged("wifi", msg.device_health.wifi_name) 199 | } 200 | } 201 | } 202 | 203 | void handleRefresh(final Map msg) { 204 | if (msg.settings?.volume != null) { 205 | updateVolumeInternal(msg.settings.volume) 206 | } 207 | 208 | if (msg.kind != null) { 209 | checkChangedDataValue("kind", msg.kind) 210 | } 211 | } 212 | 213 | void runCleanup() { 214 | state.remove('lastUpdate') 215 | device.removeDataValue("firmware") // Doesn't appear to be available for this device 216 | device.removeDataValue("device_id") 217 | } 218 | 219 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 220 | final boolean changed = device.currentValue(attribute) != newStatus 221 | if (changed) { 222 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 223 | } 224 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 225 | return changed 226 | } 227 | 228 | void checkChangedDataValue(final String name, final value) { 229 | if (device.getDataValue(name) != value) { 230 | device.updateDataValue(name, value) 231 | } 232 | } 233 | 234 | @Field final static Integer VOLUME_INC = 10 // Chime volume is only in multiples of 10 -------------------------------------------------------------------------------- /src/drivers/ring-virtual-co-alarm.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual CO Alarm 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | import groovy.transform.Field 18 | 19 | metadata { 20 | definition(name: "Ring Virtual CO Alarm", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 21 | capability "Battery" 22 | capability "CarbonMonoxideDetector" 23 | capability "Refresh" 24 | capability "Sensor" 25 | capability "TamperAlert" 26 | 27 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 28 | attribute "firmware", "string" 29 | } 30 | 31 | preferences { 32 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 33 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 34 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 35 | } 36 | } 37 | 38 | void logInfo(msg) { 39 | if (descriptionTextEnable) { log.info msg } 40 | } 41 | 42 | void logDebug(msg) { 43 | if (logEnable) { log.debug msg } 44 | } 45 | 46 | void logTrace(msg) { 47 | if (traceLogEnable) { log.trace msg } 48 | } 49 | 50 | void refresh() { 51 | parent.refresh(device.getDataValue("src")) 52 | } 53 | 54 | void setValues(final Map deviceInfo) { 55 | logDebug "setValues(${deviceInfo})" 56 | 57 | if (deviceInfo.co != null) { 58 | final Map co = deviceInfo.co 59 | 60 | checkChanged("carbonMonoxide", ALARM_STATUS.getOrDefault(co.alarmStatus, "tested")) 61 | state.coEnabled = co.enabledTimeMs 62 | } 63 | 64 | if (deviceInfo.batteryLevel != null) { 65 | checkChanged("battery", deviceInfo.batteryLevel, "%") 66 | } 67 | 68 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 69 | for (final entry in deviceInfo.subMap(["commStatus", "firmware", "tamper"])) { 70 | checkChanged(entry.key, entry.value) 71 | } 72 | 73 | // Update state values 74 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'nextExpectedWakeup', 'signalStrength']) 75 | if (stateValues) { 76 | state << stateValues 77 | } 78 | } 79 | 80 | void setPassthruValues(final Map deviceInfo) { 81 | logDebug "setPassthruValues(${deviceInfo})" 82 | 83 | if (deviceInfo.percent != null) { 84 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 85 | } 86 | } 87 | 88 | void runCleanup() { 89 | device.removeDataValue('firmware') // Is an attribute now 90 | } 91 | 92 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 93 | final boolean changed = device.currentValue(attribute) != newStatus 94 | if (changed) { 95 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 96 | } 97 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 98 | return changed 99 | } 100 | 101 | @Field final static Map ALARM_STATUS = [ 102 | active: 'detected', 103 | inactive: 'clear', 104 | ].asImmutable() -------------------------------------------------------------------------------- /src/drivers/ring-virtual-contact-sensor.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Contact Sensor Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Contact Sensor", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Contact Sensor" 20 | capability "Battery" 21 | capability "Refresh" 22 | capability "Sensor" 23 | capability "TamperAlert" 24 | 25 | attribute "bypassed", "enum", ["true", "false"] 26 | attribute "chirp", "string" 27 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 28 | attribute "firmware", "string" 29 | 30 | command "setChirp", [[name: "Set Chirp", type: "ENUM", description: "Choose the sound your Base Station and Keypads will make when this contact sensor is triggered", 31 | constraints: ['ding-dong', 'harp', 'navi', 'wind-chime', 'none']]] 32 | } 33 | 34 | preferences { 35 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 36 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 37 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 38 | } 39 | } 40 | 41 | void logInfo(msg) { 42 | if (descriptionTextEnable) { log.info msg } 43 | } 44 | 45 | void logDebug(msg) { 46 | if (logEnable) { log.debug msg } 47 | } 48 | 49 | void logTrace(msg) { 50 | if (traceLogEnable) { log.trace msg } 51 | } 52 | 53 | void setChirp(chirp) { 54 | final Map data = [chirps: [(device.getDataValue("zid")): [type: chirp]]] 55 | parent.apiWebsocketRequestSetDeviceSecurityPanel(device.getDataValue("src"), data) 56 | } 57 | 58 | void refresh() { 59 | parent.refresh(device.getDataValue("src")) 60 | } 61 | 62 | void setValues(final Map deviceInfo) { 63 | logDebug "setValues(${deviceInfo})" 64 | 65 | if (deviceInfo.faulted != null) { 66 | checkChanged("contact", deviceInfo.faulted ? "open" : "closed") 67 | } 68 | 69 | if (deviceInfo.batteryLevel != null) { 70 | checkChanged("battery", deviceInfo.batteryLevel, "%") 71 | } 72 | 73 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 74 | for (final entry in deviceInfo.subMap(["bypassed", "chirp", "commStatus", "firmware", "tamper"])) { 75 | checkChanged(entry.key, entry.value) 76 | } 77 | 78 | // Update state values 79 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'nextExpectedWakeup', 'signalStrength']) 80 | if (stateValues) { 81 | state << stateValues 82 | } 83 | } 84 | 85 | void setPassthruValues(final Map deviceInfo) { 86 | logDebug "setPassthruValues(${deviceInfo})" 87 | 88 | if (deviceInfo.percent != null) { 89 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 90 | } 91 | } 92 | 93 | void runCleanup() { 94 | device.removeDataValue('firmware') // Is an attribute now 95 | } 96 | 97 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 98 | final boolean changed = device.currentValue(attribute) != newStatus 99 | if (changed) { 100 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 101 | } 102 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 103 | return changed 104 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-flood-freeze-sensor.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Alarm Flood & Freeze Sensor Driver 3 | * 4 | * Copyright 2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Alarm Flood & Freeze Sensor", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Battery" 20 | capability "Refresh" 21 | capability "Sensor" 22 | capability "TamperAlert" 23 | capability "WaterSensor" 24 | 25 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 26 | attribute "firmware", "string" 27 | attribute "freeze", "string" 28 | } 29 | 30 | preferences { 31 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 32 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 33 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 34 | } 35 | } 36 | 37 | void logInfo(msg) { 38 | if (descriptionTextEnable) { log.info msg } 39 | } 40 | 41 | void logDebug(msg) { 42 | if (logEnable) { log.debug msg } 43 | } 44 | 45 | void logTrace(msg) { 46 | if (traceLogEnable) { log.trace msg } 47 | } 48 | 49 | void refresh() { 50 | parent.refresh(device.getDataValue("src")) 51 | } 52 | 53 | void setValues(final Map deviceInfo) { 54 | logDebug "setValues(${deviceInfo})" 55 | 56 | if (deviceInfo.faulted != null) { 57 | if (deviceInfo.flood?.faulted != null) { 58 | checkChanged("water", deviceInfo.flood.faulted ? "wet" : "dry") 59 | } 60 | if (deviceInfo.freeze?.faulted != null) { 61 | checkChanged("freeze", deviceInfo.freeze.faulted ? "detected" : "clear") 62 | } 63 | } 64 | 65 | if (deviceInfo.batteryLevel != null) { 66 | checkChanged("battery", deviceInfo.batteryLevel, "%") 67 | } 68 | 69 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 70 | for (final entry in deviceInfo.subMap(["commStatus", "firmware", "tamper"])) { 71 | checkChanged(entry.key, entry.value) 72 | } 73 | 74 | // Update state values 75 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'nextExpectedWakeup', 'signalStrength']) 76 | if (stateValues) { 77 | state << stateValues 78 | } 79 | } 80 | 81 | void setPassthruValues(final Map deviceInfo) { 82 | logDebug "setPassthruValues(${deviceInfo})" 83 | 84 | if (deviceInfo.percent != null) { 85 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 86 | } 87 | } 88 | 89 | void runCleanup() { 90 | device.removeDataValue('firmware') // Is an attribute now 91 | } 92 | 93 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 94 | final boolean changed = device.currentValue(attribute) != newStatus 95 | if (changed) { 96 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 97 | } 98 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 99 | return changed 100 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-glass-break-sensor.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Contact Sensor Driver 3 | * 4 | * Copyright 2022 Caleb Morse 5 | * Copyright 2022 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Glass Break Sensor", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Battery" 20 | capability "Refresh" 21 | capability "Sensor" 22 | capability "Shock Sensor" 23 | capability "TamperAlert" 24 | 25 | attribute "bypassed", "enum", ["true", "false"] 26 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 27 | attribute "firmware", "string" 28 | attribute "listening", "enum", ["listening", "inactive"] 29 | attribute "testMode", "string" 30 | // all = Detects in all modes 31 | // monitored = Won't detect unless armed and monitored 32 | attribute "sensorReporting", "enum", ["all", "monitored"] 33 | } 34 | 35 | preferences { 36 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 37 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 38 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 39 | } 40 | } 41 | 42 | void logInfo(msg) { 43 | if (descriptionTextEnable) { log.info msg } 44 | } 45 | 46 | void logDebug(msg) { 47 | if (logEnable) { log.debug msg } 48 | } 49 | 50 | void logTrace(msg) { 51 | if (traceLogEnable) { log.trace msg } 52 | } 53 | 54 | void refresh() { 55 | parent.refresh(device.getDataValue("src")) 56 | } 57 | 58 | void setValues(final Map deviceInfo) { 59 | logDebug "setValues(${deviceInfo})" 60 | 61 | if (deviceInfo.faulted != null) { 62 | checkChanged("shock", deviceInfo.faulted ? "detected" : "clear") 63 | } 64 | 65 | if (deviceInfo.batteryLevel != null) { 66 | checkChanged("battery", deviceInfo.batteryLevel, "%") 67 | } 68 | 69 | if (deviceInfo.deviceActive != null) { 70 | checkChanged("listening", deviceInfo.deviceActive ? 'listening' : 'inactive') 71 | } 72 | 73 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 74 | for (final entry in deviceInfo.subMap(["bypassed", "commStatus", "firmware", "tamper", "sensorReporting", "testMode"])) { 75 | checkChanged(entry.key, entry.value) 76 | } 77 | 78 | // Update state values 79 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'signalStrength']) 80 | if (stateValues) { 81 | state << stateValues 82 | } 83 | } 84 | 85 | void setPassthruValues(final Map deviceInfo) { 86 | logDebug "setPassthruValues(${deviceInfo})" 87 | 88 | if (deviceInfo.percent != null) { 89 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 90 | } 91 | } 92 | 93 | void runCleanup() { 94 | device.removeDataValue('firmware') // Is an attribute now 95 | } 96 | 97 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 98 | final boolean changed = device.currentValue(attribute) != newStatus 99 | if (changed) { 100 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 101 | } 102 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 103 | return changed 104 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-keypad.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Keypad Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | import groovy.transform.Field 18 | 19 | metadata { 20 | definition(name: "Ring Virtual Keypad", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 21 | capability "AudioVolume" 22 | capability "Battery" 23 | capability "Motion Sensor" 24 | capability "Refresh" 25 | capability "Sensor" 26 | capability "TamperAlert" 27 | 28 | attribute "batteryStatus", "enum", ["charged", "charging", "failed", "full", "low", "malfunction", "none", "ok", "warn"] 29 | attribute "brightness", "number" 30 | attribute "chirps", "enum", ["disabled", "enabled"] 31 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 32 | attribute "firmware", "string" 33 | attribute "powerSave", "enum", ["off", "on", "unknown"] 34 | 35 | command "setBrightness", [[name: "Set LED Brightness*", type: "NUMBER", range: "0..100", description: "Choose a value between 0 and 100"]] 36 | command "setChirps", [[name: "mode", type: "ENUM", constraints: ["disabled", "enabled"]]] 37 | command "setPowerSave", [[name: "mode", type: "ENUM", constraints: ["off", "on"]]] 38 | } 39 | 40 | preferences { 41 | input name: "motionTimeout", type: "number", range: '5..600', title: "Time in seconds before motion resets to inactive", defaultValue: 15 42 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 43 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 44 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 45 | } 46 | } 47 | 48 | void logInfo(msg) { 49 | if (descriptionTextEnable) { log.info msg } 50 | } 51 | 52 | void logDebug(msg) { 53 | if (logEnable) { log.debug msg } 54 | } 55 | 56 | void logTrace(msg) { 57 | if (traceLogEnable) { log.trace msg } 58 | } 59 | 60 | void setVolume(volumelevel) { 61 | // Value must be in [0, 100] 62 | volumelevel = Math.min(Math.max(volumelevel == null ? 50 : volumelevel.toInteger(), 0), 100) 63 | 64 | Integer currentVolume = device.currentValue("volume") 65 | 66 | if (currentVolume != volumelevel) { 67 | logTrace "requesting volume change to ${volumelevel}" 68 | parent.apiWebsocketRequestSetDevice(null, device.getDataValue("zid"), [volume: volumelevel.toDouble() / 100]) 69 | } 70 | else { 71 | logInfo "Already at volume." 72 | sendEvent(name: "volume", value: currentVolume) 73 | } 74 | } 75 | 76 | void volumeUp() { 77 | Integer currentVolume = device.currentValue("volume") 78 | Integer nextVol = currentVolume + VOLUME_INC 79 | if (nextVol <= 100) { 80 | setVolume(nextVol) 81 | } 82 | else { 83 | logInfo "Already max volume." 84 | sendEvent(name: "volume", value: currentVolume) 85 | } 86 | } 87 | 88 | void volumeDown() { 89 | Integer currentVolume = device.currentValue("volume") 90 | Integer nextVol = currentVolume - VOLUME_INC 91 | if (nextVol >= 0) { 92 | setVolume(nextVol) 93 | } 94 | else { 95 | logInfo "Already min volume." 96 | sendEvent(name: "volume", value: currentVolume) 97 | } 98 | } 99 | 100 | void mute() { 101 | setVolume(0) 102 | } 103 | 104 | void unmute() { 105 | setVolume(state.prevVolume) 106 | } 107 | 108 | void updateVolumeInternal(Integer volume) { 109 | Integer prevVolume = device.currentValue("volume") 110 | 111 | if (checkChanged("volume", volume)) { 112 | state.prevVolume == prevVolume 113 | if (volume == 0) { 114 | checkChanged("mute", "muted") 115 | } else { 116 | checkChanged("mute", "unmuted") 117 | } 118 | } 119 | } 120 | 121 | def setBrightness(brightness) { 122 | // Value must be in [0, 100] 123 | brightness = Math.min(Math.max(brightness == null ? 100 : brightness.toInteger(), 0), 100) 124 | 125 | parent.apiWebsocketRequestSetDevice(null, device.getDataValue("zid"), [brightness: brightness.toDouble() / 100]) 126 | } 127 | 128 | def setChirps(chirps) { 129 | parent.apiWebsocketRequestSetDevice(null, device.getDataValue("zid"), [chirps: chirps]) 130 | } 131 | 132 | def setPowerSave(powerSave) { 133 | String ringValue 134 | 135 | for (it in POWER_SAVE) { 136 | if (it.value == powerSave) { 137 | ringValue = it.key 138 | break 139 | } 140 | } 141 | 142 | if (ringValue == null) { 143 | log.error "Could not map ${powerSave} to value ring expects" 144 | return 145 | } 146 | 147 | parent.apiWebsocketRequestSetDevice(null, device.getDataValue("zid"), [powerSave: ringValue]) 148 | } 149 | 150 | void refresh() { 151 | parent.refresh(device.getDataValue("src")) 152 | } 153 | 154 | void stopMotion() { 155 | checkChanged("motion", "inactive") 156 | } 157 | 158 | void setValues(final Map deviceInfo) { 159 | logDebug "setValues(${deviceInfo})" 160 | 161 | if (deviceInfo.powerSave != null) { 162 | checkChanged("powerSave", POWER_SAVE.getOrDefault(deviceInfo.powerSave, 'unknown')) 163 | } 164 | 165 | if (deviceInfo.batteryLevel != null) { 166 | checkChanged("battery", deviceInfo.batteryLevel, "%") 167 | } 168 | 169 | if (deviceInfo.impulseType == "keypad.motion") { 170 | checkChanged("motion", "active") 171 | //The inactive message almost never comes reliably. for now we'll schedule it off 172 | runIn(motionTimeout.toInteger(), stopMotion) 173 | } 174 | 175 | if (deviceInfo.volume != null) { 176 | updateVolumeInternal(deviceInfo.volume) 177 | } 178 | 179 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 180 | for (final entry in deviceInfo.subMap(["batteryStatus", "brightness", "chirps", "commStatus", "firmware", "tamper"])) { 181 | checkChanged(entry.key, entry.value) 182 | } 183 | 184 | // Update state values 185 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'signalStrength']) 186 | if (stateValues) { 187 | state << stateValues 188 | } 189 | } 190 | 191 | void setPassthruValues(final Map deviceInfo) { 192 | logDebug "setPassthruValues(${deviceInfo})" 193 | 194 | if (deviceInfo.percent != null) { 195 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 196 | } 197 | } 198 | 199 | void runCleanup() { 200 | device.removeDataValue('firmware') // Is an attribute now 201 | state.remove('nextExpectedWakeup') // Device doesn't seem to have this value 202 | } 203 | 204 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 205 | final boolean changed = device.currentValue(attribute) != newStatus 206 | if (changed) { 207 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 208 | } 209 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 210 | return changed 211 | } 212 | 213 | @Field final static Integer VOLUME_INC = 5 214 | 215 | @Field final static Map POWER_SAVE = [ 216 | 'off': 'off', 217 | 'extended': 'on', 218 | ].asImmutable() -------------------------------------------------------------------------------- /src/drivers/ring-virtual-light-with-siren.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Light with Siren Device Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Light with Siren", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Actuator" 20 | capability "Alarm" 21 | capability "MotionSensor" 22 | capability "Polling" 23 | capability "Refresh" 24 | capability "Sensor" 25 | capability "Switch" 26 | 27 | attribute "firmware", "string" 28 | attribute "rssi", "number" 29 | attribute "wifi", "string" 30 | 31 | command "alarmOff" 32 | command "getDings" 33 | } 34 | 35 | preferences { 36 | input name: "lightPolling", type: "bool", title: "Enable polling for light status on this device", defaultValue: false 37 | input name: "lightInterval", type: "number", range: 10..600, title: "Number of seconds in between light polls", defaultValue: 15 38 | input name: "snapshotPolling", type: "bool", title: "Enable polling for thumbnail snapshots on this device", defaultValue: false 39 | input name: "strobeTimeout", type: "enum", title: "Strobe Timeout", options: [[30: "30s"], [60: "1m"], [120: "2m"], [180: "3m"]], defaultValue: 30 40 | input name: "strobeRate", type: "enum", title: "Strobe rate", options: [[1000: "1s"], [2000: "2s"], [5000: "5s"]], defaultValue: 1000 41 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 42 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 43 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 44 | } 45 | } 46 | 47 | void logInfo(msg) { 48 | if (descriptionTextEnable) { log.info msg } 49 | } 50 | 51 | void logDebug(msg) { 52 | if (logEnable) { log.debug msg } 53 | } 54 | 55 | void logTrace(msg) { 56 | if (traceLogEnable) { log.trace msg } 57 | } 58 | 59 | def parse(String description) { 60 | logDebug "description: ${description}" 61 | } 62 | 63 | def poll() { 64 | refresh() 65 | } 66 | 67 | def refresh() { 68 | logDebug "refresh()" 69 | parent.apiRequestDeviceRefresh(device.deviceNetworkId) 70 | parent.apiRequestDeviceHealth(device.deviceNetworkId, "doorbots") 71 | } 72 | 73 | def getDings() { 74 | logDebug "getDings()" 75 | parent.apiRequestDings() 76 | } 77 | 78 | def setupPolling() { 79 | unschedule() 80 | if (lightPolling) { 81 | pollLight() 82 | } 83 | } 84 | 85 | def pollLight() { 86 | logTrace "pollLight()" 87 | refresh() 88 | if (pollLight) { 89 | runIn(lightInterval, pollLight) //time in seconds 90 | } 91 | } 92 | 93 | def updated() { 94 | setupPolling() 95 | parent.snapshotOption(device.deviceNetworkId, snapshotPolling) 96 | } 97 | 98 | def on() { 99 | state.strobing = false 100 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "floodlight_light_on") 101 | } 102 | 103 | def off() { 104 | alarmOff(false) 105 | switchOff() 106 | } 107 | 108 | def switchOff() { 109 | if (state.strobing) { 110 | unschedule() 111 | } 112 | state.strobing = false 113 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "floodlight_light_off") 114 | } 115 | 116 | def alarmOff(boolean modifyLight = true) { 117 | final String alarm = device.currentValue("alarm") 118 | logTrace "alarm: $alarm" 119 | sendEvent(name: "alarm", value: "off") 120 | if ((alarm == "strobe" || alarm == "both") && modifyLight) { 121 | switchOff() 122 | } 123 | if (alarm == "siren" || alarm == "both") { 124 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "siren_off") 125 | } 126 | } 127 | 128 | def siren() { 129 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "siren_on") 130 | } 131 | 132 | def strobe(value = "strobe") { 133 | logInfo "$device was set to strobe with a rate of $strobeRate milliseconds for $strobeTimeout seconds" 134 | state.strobing = true 135 | strobeOn() 136 | sendEvent(name: "alarm", value: value) 137 | runIn(strobeTimeout.toInteger(), alarmOff) 138 | } 139 | 140 | def both() { 141 | strobe("both") 142 | siren() 143 | } 144 | 145 | def strobeOn() { 146 | if (state.strobing) { 147 | runInMillis(strobeRate.toInteger(), strobeOff) 148 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "floodlight_light_on") 149 | } 150 | } 151 | 152 | def strobeOff() { 153 | if (state.strobing) { 154 | runInMillis(strobeRate.toInteger(), strobeOn) 155 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "floodlight_light_off") 156 | } 157 | } 158 | 159 | void handleDeviceSet(final String action, final Map msg, final Map query) { 160 | if (action == "floodlight_light_on") { 161 | checkChanged("switch", "on") 162 | } 163 | else if (action == "floodlight_light_off") { 164 | checkChanged("switch", "off") 165 | } 166 | else if (action == "siren_on") { 167 | if (device.currentValue("alarm") != "both") { 168 | checkChanged("alarm", "siren") 169 | } 170 | 171 | runIn(msg.seconds_remaining + 1, refresh) 172 | } 173 | else if (action == "siren_off") { 174 | checkChanged('alarm', "off") 175 | } 176 | else { 177 | log.error "handleDeviceSet unsupported action ${action}, msg=${msg}, query=${query}" 178 | } 179 | } 180 | 181 | void handleHealth(final Map msg) { 182 | if (msg.device_health) { 183 | if (msg.device_health.wifi_name) { 184 | checkChanged("wifi", msg.device_health.wifi_name) 185 | } 186 | } 187 | } 188 | 189 | void handleMotion(final Map msg) { 190 | if (msg.motion == true) { 191 | checkChanged("motion", "active") 192 | 193 | runIn(60, motionOff) // We don't get motion off msgs from ifttt, and other motion only happens on a manual refresh 194 | } 195 | else if (msg.motion == false) { 196 | checkChanged("motion", "inactive") 197 | unschedule(motionOff) 198 | } 199 | else { 200 | log.error("handleMotion unsupported msg: ${msg}") 201 | } 202 | } 203 | 204 | void handleRefresh(final Map msg) { 205 | if (msg.led_status) { 206 | checkChanged("switch", msg.led_status) 207 | } 208 | 209 | if (msg.siren_status?.seconds_remaining != null) { 210 | final Integer secondsRemaining = msg.siren_status.seconds_remaining 211 | checkChanged("alarm", secondsRemaining > 0 ? "siren" : "off") 212 | if (secondsRemaining > 0) { 213 | runIn(secondsRemaining + 1, refresh) 214 | } 215 | } 216 | 217 | if (msg.is_sidewalk_gateway) { 218 | log.warn("Your device is being used as an Amazon sidewalk device.") 219 | } 220 | 221 | if (msg.health) { 222 | Map health = msg.health 223 | 224 | if (health.firmware_version) { 225 | checkChanged("firmware", health.firmware_version) 226 | } 227 | 228 | if (health.rssi) { 229 | checkChanged("rssi", health.rssi) 230 | } 231 | } 232 | } 233 | 234 | void motionOff() { 235 | checkChanged("motion", "inactive") 236 | } 237 | 238 | void runCleanup() { 239 | state.remove('lastActivity') 240 | device.removeDataValue("firmware") // Is an attribute now 241 | device.removeDataValue("device_id") 242 | } 243 | 244 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 245 | final boolean changed = device.currentValue(attribute) != newStatus 246 | if (changed) { 247 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 248 | } 249 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 250 | return changed 251 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-light.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Light Device Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Light", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Actuator" 20 | capability "Battery" 21 | capability "MotionSensor" 22 | capability "Polling" 23 | capability "Sensor" 24 | capability "Switch" 25 | capability "Refresh" 26 | 27 | attribute "firmware", "string" 28 | attribute "battery2", "number" 29 | attribute "rssi", "number" 30 | attribute "wifi", "string" 31 | 32 | command "flash" 33 | command "getDings" 34 | } 35 | 36 | preferences { 37 | input name: "lightPolling", type: "bool", title: "Enable polling for light status on this device", defaultValue: false 38 | input name: "lightInterval", type: "number", range: 10..600, title: "Number of seconds in between light polls", defaultValue: 15 39 | input name: "snapshotPolling", type: "bool", title: "Enable polling for thumbnail snapshots on this device", defaultValue: false 40 | input name: "strobeTimeout", type: "enum", title: "Flash Timeout", options: [[30: "30s"], [60: "1m"], [120: "2m"], [180: "3m"]], defaultValue: 30 41 | input name: "strobeRate", type: "enum", title: "Flash rate", options: [[1000: "1s"], [2000: "2s"], [5000: "5s"]], defaultValue: 1000 42 | input name: "discardBatteryLevel", type: "bool", title: "Discard the battery level because this device is plugged in or doesn't support " + 43 | "battery level", description: "This setting can prevent a battery level attribute from showing up but it cannot remove one once battery " + 44 | "has been set. Nothing can.", defaultValue: true 45 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 46 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 47 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 48 | } 49 | } 50 | 51 | void logInfo(msg) { 52 | if (descriptionTextEnable) { log.info msg } 53 | } 54 | 55 | void logDebug(msg) { 56 | if (logEnable) { log.debug msg } 57 | } 58 | 59 | void logTrace(msg) { 60 | if (traceLogEnable) { log.trace msg } 61 | } 62 | 63 | def parse(String description) { 64 | logDebug "description: ${description}" 65 | } 66 | 67 | def poll() { 68 | refresh() 69 | } 70 | 71 | def refresh() { 72 | logDebug "refresh()" 73 | parent.apiRequestDeviceRefresh(device.deviceNetworkId) 74 | parent.apiRequestDeviceHealth(device.deviceNetworkId, "doorbots") 75 | } 76 | 77 | def getDings() { 78 | logDebug "getDings()" 79 | parent.apiRequestDings() 80 | } 81 | 82 | def setupPolling() { 83 | unschedule() 84 | if (lightPolling) { 85 | pollLight() 86 | } 87 | } 88 | 89 | def pollLight() { 90 | logTrace "pollLight()" 91 | refresh() 92 | if (pollLight) { 93 | runIn(lightInterval, pollLight) //time in seconds 94 | } 95 | } 96 | 97 | def updated() { 98 | setupPolling() 99 | parent.snapshotOption(device.deviceNetworkId, snapshotPolling) 100 | } 101 | 102 | def on() { 103 | state.strobing = false 104 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "floodlight_light_on") 105 | } 106 | 107 | def off() { 108 | if (state.strobing) { 109 | unschedule() 110 | } 111 | state.strobing = false 112 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "floodlight_light_off") 113 | } 114 | 115 | def flash() { 116 | logInfo "$device was set to flash with a rate of $strobeRate milliseconds for $strobeTimeout seconds" 117 | state.strobing = true 118 | strobeOn() 119 | runIn(strobeTimeout.toInteger(), off) 120 | } 121 | 122 | def strobeOn() { 123 | if (state.strobing) { 124 | runInMillis(strobeRate.toInteger(), strobeOff) 125 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "floodlight_light_on") 126 | } 127 | } 128 | 129 | def strobeOff() { 130 | if (state.strobing) { 131 | runInMillis(strobeRate.toInteger(), strobeOn) 132 | parent.apiRequestDeviceSet(device.deviceNetworkId, "doorbots", "floodlight_light_off") 133 | } 134 | } 135 | 136 | void handleDeviceSet(final String action, final Map msg, final Map query) { 137 | if (action == "floodlight_light_on") { 138 | checkChanged("switch", "on") 139 | } 140 | else if (action == "floodlight_light_off") { 141 | checkChanged("switch", "off") 142 | } 143 | else { 144 | log.error "handleDeviceSet unsupported action ${action}, msg=${msg}, query=${query}" 145 | } 146 | } 147 | 148 | void handleHealth(final Map msg) { 149 | if (msg.device_health) { 150 | if (msg.device_health.wifi_name) { 151 | checkChanged("wifi", msg.device_health.wifi_name) 152 | } 153 | } 154 | } 155 | 156 | void handleMotion(final Map msg) { 157 | if (msg.motion == true) { 158 | checkChanged("motion", "active") 159 | 160 | runIn(60, motionOff) // We don't get motion off msgs from ifttt, and other motion only happens on a manual refresh 161 | } 162 | else if (msg.motion == false) { 163 | checkChanged("motion", "inactive") 164 | unschedule(motionOff) 165 | } 166 | else { 167 | log.error("handleMotion unsupported msg: ${msg}") 168 | } 169 | } 170 | 171 | void handleRefresh(final Map msg) { 172 | if (!discardBatteryLevel) { 173 | if (msg.battery_life != null) { 174 | checkChanged("battery", msg.battery_life, "%") 175 | if (msg.battery_life_2 != null) { 176 | checkChanged("battery2", msg.battery_life_2, "%") 177 | } 178 | } 179 | else if (msg.battery_life_2 != null) { 180 | checkChanged("battery", msg.battery_life_2, "%") 181 | } 182 | } 183 | 184 | if (msg.led_status) { 185 | if (!(msg.led_status instanceof String) && msg.led_status.seconds_remaining != null) { 186 | checkChanged("switch", msg.led_status.seconds_remaining > 0 ? "on" : "off") 187 | } 188 | else { 189 | checkChanged("switch", msg.led_status) 190 | } 191 | } 192 | 193 | if (msg.health) { 194 | Map health = msg.health 195 | 196 | if (health.firmware_version) { 197 | checkChanged("firmware", health.firmware_version) 198 | } 199 | 200 | if (health.rssi) { 201 | checkChanged("rssi", health.rssi) 202 | } 203 | } 204 | } 205 | 206 | void motionOff() { 207 | checkChanged("motion", "inactive") 208 | } 209 | 210 | void runCleanup() { 211 | state.remove('lastActivity') 212 | device.removeDataValue("firmware") // Is an attribute now 213 | device.removeDataValue("device_id") 214 | } 215 | 216 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 217 | final boolean changed = device.currentValue(attribute) != newStatus 218 | if (changed) { 219 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 220 | } 221 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 222 | return changed 223 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-lock.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Lock Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | import groovy.transform.Field 18 | 19 | metadata { 20 | definition(name: "Ring Virtual Lock", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 21 | capability "Battery" 22 | capability "Lock" 23 | capability "Refresh" 24 | capability "Sensor" 25 | capability "TamperAlert" 26 | 27 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 28 | attribute "firmware", "string" 29 | } 30 | 31 | preferences { 32 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 33 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 34 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 35 | } 36 | } 37 | 38 | void logInfo(msg) { 39 | if (descriptionTextEnable) { log.info msg } 40 | } 41 | 42 | void logDebug(msg) { 43 | if (logEnable) { log.debug msg } 44 | } 45 | 46 | void logTrace(msg) { 47 | if (traceLogEnable) { log.trace msg } 48 | } 49 | 50 | void refresh() { 51 | parent.refresh(device.getDataValue("src")) 52 | } 53 | 54 | def lock() { lockUnlockInternal('lock') } 55 | def unlock() { lockUnlockInternal('unlock') } 56 | 57 | def lockUnlockInternal(final String command) { 58 | if (device.currentValue('lock') != "${command}ed") { 59 | parent.apiWebsocketRequestSetCommand("lock.${command}", device.getDataValue("dst"), device.getDataValue("zid")) 60 | } 61 | } 62 | 63 | // @todo When lock fails to digitally lock/unlock, an error.set-info gets sent. Maybe this could be logged? 64 | void setValues(final Map deviceInfo) { 65 | logDebug "setValues(${deviceInfo})" 66 | 67 | if (deviceInfo.locked != null) { 68 | final boolean isPhysical = PHYSICAL_LOCK_IMPUSES.contains(deviceInfo.impulseType) 69 | checkChanged("lock", deviceInfo.locked, null, isPhysical ? 'physical' : 'digital') 70 | } 71 | 72 | if (deviceInfo.batteryLevel != null) { 73 | checkChanged("battery", deviceInfo.batteryLevel, "%") 74 | } 75 | 76 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 77 | for (final entry in deviceInfo.subMap(["commStatus", "firmware", "tamper"])) { 78 | checkChanged(entry.key, entry.value) 79 | } 80 | 81 | // Update state values 82 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'signalStrength']) 83 | if (stateValues) { 84 | state << stateValues 85 | } 86 | } 87 | 88 | void setPassthruValues(final Map deviceInfo) { 89 | logDebug "setPassthruValues(${deviceInfo})" 90 | 91 | if (deviceInfo.percent != null) { 92 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 93 | } 94 | } 95 | 96 | void runCleanup() { 97 | device.removeDataValue('firmware') // Is an attribute now 98 | state.remove('nextExpectedWakeup') // Device doesn't seem to have this value 99 | } 100 | 101 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 102 | final boolean changed = device.currentValue(attribute) != newStatus 103 | if (changed) { 104 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 105 | } 106 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 107 | return changed 108 | } 109 | 110 | @Field final static Set PHYSICAL_LOCK_IMPUSES = ['locked', 'unlocked', 'locked.by-manual', 'unlocked.by-manual'].toSet().asImmutable() -------------------------------------------------------------------------------- /src/drivers/ring-virtual-motion-sensor.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Motion Sensor Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | import groovy.transform.Field 18 | 19 | metadata { 20 | definition(name: "Ring Virtual Motion Sensor", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 21 | capability "Battery" 22 | capability "Motion Sensor" 23 | capability "Refresh" 24 | capability "Sensor" 25 | capability "TamperAlert" 26 | 27 | attribute "bypassed", "enum", ["true", "false"] 28 | attribute "chirp", "string" 29 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 30 | attribute "firmware", "string" 31 | attribute "sensitivity", "enum", ["low", "medium", "high"] 32 | 33 | command "setChirp", [[name: "Set Chirp", type: "ENUM", description: "Choose the sound your Base Station and Keypads will make when this contact sensor is triggered", 34 | constraints: ['ding-dong', 'harp', 'navi', 'wind-chime', 'none']]] 35 | command "setSensitivity", [[name: "mode", type: "ENUM", constraints: ["low", "medium", "high"], description: "Set motion sensor sensitivity. WARNING: This setting does not apply immediately. May take up to 12 hours to apply. To apply immediately, open the device cover, wait for LED to stop blinking, then close the cover."]] 36 | } 37 | 38 | preferences { 39 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 40 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 41 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 42 | } 43 | } 44 | 45 | void logInfo(msg) { 46 | if (descriptionTextEnable) { log.info msg } 47 | } 48 | 49 | void logDebug(msg) { 50 | if (logEnable) { log.debug msg } 51 | } 52 | 53 | void logTrace(msg) { 54 | if (traceLogEnable) { log.trace msg } 55 | } 56 | 57 | void setChirp(chirp) { 58 | final Map data = [chirps: [(device.getDataValue("zid")): [type: chirp]]] 59 | parent.apiWebsocketRequestSetDeviceSecurityPanel(device.getDataValue("src"), data) 60 | } 61 | 62 | void setSensitivity(String sensitivity) { 63 | Integer ringSensitivity = MOTION_SENSITIVITY.find { it.value == sensitivity }?.key 64 | 65 | if (ringSensitivity == null) { 66 | log.error "Could not map ${sensitivity} to value ring expects" 67 | return 68 | } 69 | 70 | parent.apiWebsocketRequestSetDevice(device.getDataValue("src"), device.getDataValue("zid"), [sensitivity: ringSensitivity]) 71 | } 72 | 73 | void refresh() { 74 | parent.refresh(device.getDataValue("src")) 75 | } 76 | 77 | void setValues(final Map deviceInfo) { 78 | logDebug "setValues(${deviceInfo})" 79 | 80 | if (deviceInfo.faulted != null) { 81 | checkChanged("motion", deviceInfo.faulted ? "active" : "inactive") 82 | } 83 | 84 | if (deviceInfo.sensitivity != null) { 85 | checkChanged("sensitivity", MOTION_SENSITIVITY[deviceInfo.sensitivity]) 86 | } 87 | 88 | if (deviceInfo.pending != null) { 89 | final Map deviceInfoPending = deviceInfo.pending 90 | 91 | if (deviceInfoPending.sensitivity != null) { 92 | logInfo "Device ${device.label} will set 'Sensitivity' to ${MOTION_SENSITIVITY[deviceInfoPending.sensitivity]} on ${getNextExpectedWakeupString(deviceInfo)}" 93 | } 94 | 95 | if (deviceInfoPending.commands) { 96 | logDebug "Device ${device.label} will set the commands ${deviceInfoPending.commands} on ${getNextExpectedWakeupString(deviceInfo)}" 97 | } 98 | } 99 | 100 | if (deviceInfo.batteryLevel != null) { 101 | checkChanged("battery", deviceInfo.batteryLevel, "%") 102 | } 103 | 104 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 105 | for (final entry in deviceInfo.subMap(["bypassed", "chirp", "commStatus", "firmware", "tamper"])) { 106 | checkChanged(entry.key, entry.value) 107 | } 108 | 109 | // Update state values 110 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'nextExpectedWakeup', 'signalStrength']) 111 | if (stateValues) { 112 | state << stateValues 113 | } 114 | } 115 | 116 | void setPassthruValues(final Map deviceInfo) { 117 | logDebug "setPassthruValues(${deviceInfo})" 118 | 119 | if (deviceInfo.percent != null) { 120 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 121 | } 122 | } 123 | 124 | void runCleanup() { 125 | device.removeDataValue('firmware') // Is an attribute now 126 | } 127 | 128 | // @return Next expected wakeup time as a string. 129 | // Gets value from deviceInfo first, falls back to state because nextExpectedWakeup isn't sent with every deviceInfo 130 | String getNextExpectedWakeupString(final Map deviceInfo) { 131 | final Long nextExpectedWakeup = deviceInfo.nextExpectedWakeup ?: state.nextExpectedWakeup 132 | 133 | return nextExpectedWakeup ? new Date(nextExpectedWakeup).toString() : 'unknown' 134 | } 135 | 136 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 137 | final boolean changed = device.currentValue(attribute) != newStatus 138 | if (changed) { 139 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 140 | } 141 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 142 | return changed 143 | } 144 | 145 | @Field final static Map MOTION_SENSITIVITY = [ 146 | 0: 'high', 147 | 1: 'medium', 148 | 2: 'low', 149 | ].asImmutable() -------------------------------------------------------------------------------- /src/drivers/ring-virtual-panic-button.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Panic Button Driver 3 | * 4 | * Copyright 2021 Caleb Morse 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 | metadata { 17 | definition(name: "Ring Virtual Panic Button", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 18 | capability 'Actuator' 19 | capability "Battery" 20 | capability "Refresh" 21 | capability "TamperAlert" 22 | 23 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 24 | attribute "firmware", "string" 25 | attribute "testMode", "string" 26 | } 27 | 28 | preferences { 29 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 30 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 31 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 32 | } 33 | } 34 | 35 | void logInfo(msg) { 36 | if (descriptionTextEnable) { log.info msg } 37 | } 38 | 39 | void logDebug(msg) { 40 | if (logEnable) { log.debug msg } 41 | } 42 | 43 | void logTrace(msg) { 44 | if (traceLogEnable) { log.trace msg } 45 | } 46 | 47 | void refresh() { 48 | parent.refresh(device.getDataValue("src")) 49 | } 50 | 51 | void setValues(final Map deviceInfo) { 52 | logDebug "setValues(${deviceInfo})" 53 | 54 | if (deviceInfo.batteryLevel != null) { 55 | checkChanged("battery", deviceInfo.batteryLevel, "%") 56 | } 57 | 58 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 59 | for (final entry in deviceInfo.subMap(["commStatus", "firmware", "tamper", "testMode"])) { 60 | checkChanged(entry.key, entry.value) 61 | } 62 | 63 | // Update state values 64 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'nextExpectedWakeup', 'signalStrength']) 65 | if (stateValues) { 66 | state << stateValues 67 | } 68 | } 69 | 70 | void setPassthruValues(final Map deviceInfo) { 71 | logDebug "setPassthruValues(${deviceInfo})" 72 | 73 | if (deviceInfo.percent != null) { 74 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 75 | } 76 | } 77 | 78 | void runCleanup() { 79 | device.removeDataValue('firmware') // Is an attribute now 80 | } 81 | 82 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 83 | final boolean changed = device.currentValue(attribute) != newStatus 84 | if (changed) { 85 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 86 | } 87 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 88 | return changed 89 | } 90 | -------------------------------------------------------------------------------- /src/drivers/ring-virtual-retrofit-alarm-kit.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Retrofit Alarm Kit 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Retrofit Alarm Kit", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Battery" 20 | capability "Refresh" 21 | capability "Sensor" 22 | capability "TamperAlert" 23 | 24 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 25 | attribute "firmware", "string" 26 | } 27 | 28 | preferences { 29 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 30 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 31 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 32 | } 33 | } 34 | 35 | void logInfo(msg) { 36 | if (descriptionTextEnable) { log.info msg } 37 | } 38 | 39 | void logDebug(msg) { 40 | if (logEnable) { log.debug msg } 41 | } 42 | 43 | void logTrace(msg) { 44 | if (traceLogEnable) { log.trace msg } 45 | } 46 | 47 | void refresh() { 48 | parent.refresh(device.getDataValue("src")) 49 | } 50 | 51 | void setValues(final Map deviceInfo) { 52 | logDebug "setValues(${deviceInfo})" 53 | 54 | if (deviceInfo.batteryLevel != null) { 55 | checkChanged("battery", deviceInfo.batteryLevel, "%") 56 | } 57 | 58 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 59 | for (final entry in deviceInfo.subMap(["commStatus", "firmware", "tamper"])) { 60 | checkChanged(entry.key, entry.value) 61 | } 62 | 63 | // Update state values 64 | Map stateValues = deviceInfo.subMap(['componentDevices', 'impulseType', 'lastCommTime', 'lastUpdate', 'nextExpectedWakeup', 'signalStrength']) 65 | if (stateValues) { 66 | state << stateValues 67 | } 68 | } 69 | 70 | void setPassthruValues(final Map deviceInfo) { 71 | logDebug "setPassthruValues(${deviceInfo})" 72 | 73 | if (deviceInfo.percent != null) { 74 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 75 | } 76 | } 77 | 78 | void runCleanup() { 79 | device.removeDataValue('firmware') // Is an attribute now 80 | } 81 | 82 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 83 | final boolean changed = device.currentValue(attribute) != newStatus 84 | if (changed) { 85 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 86 | } 87 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 88 | return changed 89 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-siren.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Siren Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Siren", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Battery" 20 | capability "Refresh" 21 | capability "Sensor" 22 | capability "TamperAlert" 23 | // capability "Alarm" For now this is commented out because I can't see a way through the WS or API to turn the siren on 24 | // using the alarm hub's 'security-panel.sound-siren' set command does not work. Technically, the siren tests could be 25 | // chained back to back with a scheduled call back but leaving this as is for now 26 | 27 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 28 | attribute "firmware", "string" 29 | 30 | command "sirenTest" 31 | command "sirenTestCancel" 32 | } 33 | 34 | preferences { 35 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 36 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 37 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 38 | } 39 | } 40 | 41 | void logInfo(msg) { 42 | if (descriptionTextEnable) { log.info msg } 43 | } 44 | 45 | void logDebug(msg) { 46 | if (logEnable) { log.debug msg } 47 | } 48 | 49 | void logTrace(msg) { 50 | if (traceLogEnable) { log.trace msg } 51 | } 52 | 53 | void refresh() { 54 | parent.refresh(device.getDataValue("src")) 55 | } 56 | 57 | def sirenTest() { 58 | // @todo Make this impossible when alarm is armed. If you attempt this through Ring's UIs it is prevented 59 | //pearl is too deep a dive to add code so this device can ask the hub device what the mode is right now. 60 | parent.apiWebsocketRequestSetCommand("siren-test.start", device.getDataValue("src"), device.getDataValue("zid")) 61 | } 62 | 63 | def sirenTestCancel() { 64 | parent.apiWebsocketRequestSetCommand("siren-test.stop", device.getDataValue("src"), device.getDataValue("zid")) 65 | } 66 | 67 | void setValues(final Map deviceInfo) { 68 | logDebug "setValues(${deviceInfo})" 69 | 70 | if (deviceInfo.batteryLevel != null) { 71 | checkChanged("battery", deviceInfo.batteryLevel, "%") 72 | } 73 | 74 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 75 | for (final entry in deviceInfo.subMap(["commStatus", "firmware", "tamper"])) { 76 | checkChanged(entry.key, entry.value) 77 | } 78 | 79 | // Update state values 80 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'nextExpectedWakeup', 'signalStrength']) 81 | if (stateValues) { 82 | state << stateValues 83 | } 84 | } 85 | 86 | void setPassthruValues(final Map deviceInfo) { 87 | logDebug "setPassthruValues(${deviceInfo})" 88 | 89 | if (deviceInfo.percent != null) { 90 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 91 | } 92 | } 93 | 94 | void runCleanup() { 95 | device.removeDataValue('firmware') // Is an attribute now 96 | } 97 | 98 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 99 | final boolean changed = device.currentValue(attribute) != newStatus 100 | if (changed) { 101 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 102 | } 103 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 104 | return changed 105 | } -------------------------------------------------------------------------------- /src/drivers/ring-virtual-smoke-alarm.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Smoke Alarm 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | import groovy.transform.Field 18 | 19 | metadata { 20 | definition(name: "Ring Virtual Smoke Alarm", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 21 | capability "Battery" 22 | capability "Refresh" 23 | capability "Sensor" 24 | capability "SmokeDetector" 25 | capability "TamperAlert" 26 | 27 | attribute "commStatus", "enum", ["error", "ok", "update-queued", "updating", "waiting-for-join", "wrong-network"] 28 | attribute "firmware", "string" 29 | } 30 | 31 | preferences { 32 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 33 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 34 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 35 | } 36 | } 37 | 38 | void logInfo(msg) { 39 | if (descriptionTextEnable) { log.info msg } 40 | } 41 | 42 | void logDebug(msg) { 43 | if (logEnable) { log.debug msg } 44 | } 45 | 46 | void logTrace(msg) { 47 | if (traceLogEnable) { log.trace msg } 48 | } 49 | 50 | void refresh() { 51 | parent.refresh(device.getDataValue("src")) 52 | } 53 | 54 | void setValues(final Map deviceInfo) { 55 | logDebug "setValues(${deviceInfo})" 56 | 57 | if (deviceInfo.smoke != null) { 58 | final Map smoke = deviceInfo.smoke 59 | 60 | checkChanged("smoke", ALARM_STATUS.getOrDefault(smoke.alarmStatus, "tested")) 61 | state.smokeEnabled = smoke.enabledTimeMs 62 | } 63 | 64 | if (deviceInfo.batteryLevel != null) { 65 | checkChanged("battery", deviceInfo.batteryLevel, "%") 66 | } 67 | 68 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 69 | for (final entry in deviceInfo.subMap(["commStatus", "firmware", "tamper"])) { 70 | checkChanged(entry.key, entry.value) 71 | } 72 | 73 | // Update state values 74 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'nextExpectedWakeup', 'signalStrength']) 75 | if (stateValues) { 76 | state << stateValues 77 | } 78 | } 79 | 80 | void setPassthruValues(final Map deviceInfo) { 81 | logDebug "setPassthruValues(${deviceInfo})" 82 | 83 | if (deviceInfo.percent != null) { 84 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 85 | } 86 | } 87 | 88 | void runCleanup() { 89 | device.removeDataValue('firmware') // Is an attribute now 90 | } 91 | 92 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 93 | final boolean changed = device.currentValue(attribute) != newStatus 94 | if (changed) { 95 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 96 | } 97 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 98 | return changed 99 | } 100 | 101 | @Field final static Map ALARM_STATUS = [ 102 | active: 'detected', 103 | inactive: 'clear', 104 | ].asImmutable() -------------------------------------------------------------------------------- /src/drivers/ring-virtual-switch.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Ring Virtual Switch Driver 3 | * 4 | * Copyright 2019-2020 Ben Rimmasch 5 | * Copyright 2021 Caleb Morse 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 | * in compliance with the License. You may obtain a copy of the License at: 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 14 | * for the specific language governing permissions and limitations under the License. 15 | */ 16 | 17 | metadata { 18 | definition(name: "Ring Virtual Switch", namespace: "ring-hubitat-codahq", author: "Ben Rimmasch") { 19 | capability "Refresh" 20 | capability "Sensor" 21 | capability "Battery" 22 | capability "Switch" 23 | capability "TamperAlert" 24 | 25 | attribute "firmware", "string" 26 | } 27 | 28 | preferences { 29 | input name: "descriptionTextEnable", type: "bool", title: "Enable descriptionText logging", defaultValue: false 30 | input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: false 31 | input name: "traceLogEnable", type: "bool", title: "Enable trace logging", defaultValue: false 32 | } 33 | } 34 | 35 | void logInfo(msg) { 36 | if (descriptionTextEnable) { log.info msg } 37 | } 38 | 39 | void logDebug(msg) { 40 | if (logEnable) { log.debug msg } 41 | } 42 | 43 | void logTrace(msg) { 44 | if (traceLogEnable) { log.trace msg } 45 | } 46 | 47 | void refresh() { 48 | parent.refresh(device.getDataValue("src")) 49 | } 50 | 51 | def on() { 52 | parent.apiWebsocketRequestSetDevice(device.getDataValue("src"), device.getDataValue("zid"), ["on": true]) 53 | } 54 | 55 | def off() { 56 | parent.apiWebsocketRequestSetDevice(device.getDataValue("src"), device.getDataValue("zid"), ["on": false]) 57 | } 58 | 59 | void setValues(final Map deviceInfo) { 60 | logDebug "setValues(${deviceInfo})" 61 | 62 | if (deviceInfo.batteryLevel != null) { 63 | checkChanged("battery", deviceInfo.batteryLevel, "%") 64 | } 65 | 66 | // Update attributes where deviceInfo key is the same as attribute name and no conversion is necessary 67 | for (final entry in deviceInfo.subMap(["firmware", "switch", "tamper"])) { 68 | checkChanged(entry.key, entry.value) 69 | } 70 | 71 | // Update state values 72 | Map stateValues = deviceInfo.subMap(['impulseType', 'lastCommTime', 'lastUpdate', 'nextExpectedWakeup', 'signalStrength']) 73 | if (stateValues) { 74 | state << stateValues 75 | } 76 | } 77 | 78 | void setPassthruValues(final Map deviceInfo) { 79 | logDebug "setPassthruValues(${deviceInfo})" 80 | 81 | if (deviceInfo.percent != null) { 82 | log.warn "${device.label} is updating firmware: ${deviceInfo.percent}% complete" 83 | } 84 | } 85 | 86 | void runCleanup() { 87 | device.removeDataValue('firmware') // Is an attribute now 88 | } 89 | 90 | boolean checkChanged(final String attribute, final newStatus, final String unit=null, final String type=null) { 91 | final boolean changed = device.currentValue(attribute) != newStatus 92 | if (changed) { 93 | logInfo "${attribute.capitalize()} for device ${device.label} is ${newStatus}" 94 | } 95 | sendEvent(name: attribute, value: newStatus, unit: unit, type: type) 96 | return changed 97 | } --------------------------------------------------------------------------------