Repository: notoriousbdg/Home-AssistantConfig Branch: master Commit: 6c7e8c383e8f Files: 15 Total size: 47.9 KB Directory structure: gitextract_l_bvoits/ ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── automations.yaml ├── configuration.yaml ├── customize.yaml ├── device_tracker.yaml ├── gitupdate.sh ├── groups.yaml ├── packages/ │ └── battery_alert.yaml ├── sensors.yaml ├── switches.yaml ├── travis_secrets.yaml └── zones.yaml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.pid *.xml *.csr *.crt *.key www OZW_Log.txt home-assistant.log home-assistant_v2.db *.db-journal lib deps tts secrets.yaml known_devices.yaml *.conf plex.conf phue.conf harmony_media_room.conf pyozw.sqlite .* !/.gitignore !/.travis.yml html5_push_registrations.conf ip_bans.yaml /icloud/* ozw_config emulated_hue_ids.json ================================================ FILE: .travis.yml ================================================ language: python python: - "3.6" install: - pip3 install homeassistant script: - hass -c . --script check_config before_install: - mv travis_secrets.yaml secrets.yaml ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ # [![Build Status](https://travis-ci.org/notoriousbdg/Home-AssistantConfig.svg?branch=master)](https://travis-ci.org/notoriousbdg/Home-AssistantConfig) My [Home Assistant](https://home-assistant.io/) Config ================================================ FILE: automations.yaml ================================================ [] ================================================ FILE: configuration.yaml ================================================ homeassistant: # Name of the location where Home Assistant is running name: Home # Location required to calculate the time the sun rises and sets latitude: !secret home_latitude longitude: !secret home_longitude # Impacts weather/sunrise data (altitude above sea level in meters) elevation: !secret home_elevation # metric for Metric, imperial for Imperial unit_system: imperial # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones time_zone: !secret home_timezone #customize: !include customize.yaml # Show links to resources in log and frontend #introduction: # Enables the frontend frontend: # Enables configuration UI config: http: # Uncomment this to add a password (recommended!) api_password: !secret http_api_password #ssl_certificate: !secret ssl_certificate #ssl_key: !secret ssl_key #base_url: !secret base_url #server_port: !secret server_port trusted_networks: - 127.0.0.1 - ::1 - !secret trusted_ip ip_ban_enabled: True login_attempts_threshold: 5 # Checks for available updates # Note: This component will send some information about your system to # the developers to assist with development of Home Assistant. # For more information, please see: # https://home-assistant.io/blog/2016/10/25/explaining-the-updater/ updater: # Optional, allows Home Assistant developers to focus on popular components. # include_used_components: true # Discover some devices automatically discovery: # Allows you to issue voice commands from the frontend in enabled browsers conversation: # Enables support for tracking state changes over time. history: # View all events in a logbook logbook: # Track the sun sun: # Weather Prediction sensor: platform: yr # Text to speech tts: platform: google group: !include groups.yaml automation: !include automations.yaml #zone: !include zones.yaml #sensor: !include sensors.yaml #switch: !include switches.yaml #device_tracker: !include device_tracker.yaml ffmpeg: ffmpeg_bin: /usr/bin/ffmpeg mqtt: broker: !secret mqtt_broker_ip port: !secret mqtt_port client_id: !secret mqtt_client_id username: !secret mqtt_username password: !secret mqtt_password discovery: true discovery_prefix: homeassistant ================================================ FILE: customize.yaml ================================================ ================================================ FILE: device_tracker.yaml ================================================ ================================================ FILE: gitupdate.sh ================================================ #!/bin/bash cd /home/homeassistant/.homeassistant source /srv/homeassistant/homeassistant_venv/bin/activate hass --script check_config git add . git status echo -n "Enter the Description for the Change: " [Minor Update] read CHANGE_MSG git commit -m "${CHANGE_MSG}" git push origin master exit ================================================ FILE: groups.yaml ================================================ ================================================ FILE: packages/battery_alert.yaml ================================================ ################################################################ ## Battery Alert Package by NotoriousBDG ## ## Source: https://raw.githubusercontent.com/notoriousbdg/Home-AssistantConfig/master/packages/battery_alert.yaml ################################################################ ################################################################ ## Changelog ################################################################ ## ## 1.0.0 (2018-02-14) ## Added ## - Added version number to enable better tracking ## ## 1.0.1 (2018-02-15) ## Added ## - Added battery_sensor_creation_disabled attibute to skip ## creating a battery sensor even when an battery attribute ## exists. ## ## 1.0.2 (2018-04-06) ## Added ## - Added battery icon to sensors. ## ## 1.0.3 (2018-05-10) ## Changed ## - Change device_class to battery and remove icon, which ## allows dynamic icons in 0.69. ## ## 1.0.4 (2018-05-11) ## Changed ## - Fixed condition battery_sensor_creation_disabled condition ## Added ## - Documented a jinja template that can be use to assist ## with creating a group containing all battery sensors. ## ## 1.0.5 (2018-05-14) ## Changed ## - Changed formatting of notifications to improve readability ## - Nofity via Slack immediately when thresholds are modified ## Added ## - Entities with device_class of battery no longer need ## battery in their friendly name to be monitored ## - Don't create a battery sensor from an entity if ## device_class is battery ## ## 1.0.6 (2018-05-14) ## Changed ## - Added object_id to notifications ## - Updated Battery Status group jinja code to check for ## battery device_class ## ## 1.0.7 (2018-05-16) ## Added ## - Added unique_id to disambiguate sensors with duplicate ## names ## - Added source info to mqtt config topic ## - Consider friendly names and entity_ids that end with _bat ## as a battery sensor (needed for rflink battery sensors) ## - Consider entities with icon of battery, battery-alert, or ## battery-unknown as a battery sensor regardles of its name ## - Consider entity_ids containing battery as a battery sensor ## Changed ## - Reduce code duplication using yaml anchors and references ## - Changed MQTT topic to be based on entity_id ## - Improve method of filtering non-battery devices that have ## battery in their name. Detection is now based on icon ## rather than keywords. ## ## 1.0.8 (2018-06-01) ## Added ## - Add support for defining battery_template attibute to ## allow manipulation of value of battery sensor ## - Support battery attributes that contain strings ## Removed ## - Cleaned up notifications by removing object id ## ## 1.0.9 (2018-06-08) ## Added ## - Automatically create Battery Status group containing all ## discovered batteries ## Removed ## - Removed sample jinja to create battery status group yaml ## ## 1.0.10 (2018-06-08) ## Added ## - Moved group.update_battery_status_group_members to Battery ## Alert group ## ## 1.1.0 (2018-08-09) ## Added ## - Added Batteries view ## - Added Telegram notification automation ## - Added Pushover notification automation ## - Added attributes to battery entities created via mqtt: ## entity_id, attribute, mqtt_config_topic, and mqtt_state_topic ## Changed ## - Simplified trigger for update_battery_status_group_members ## automation ## - Refactored conditions on automations to rely on ## group.battery_status members ## Breaking Changes ## - The attribute additions requires restarting Home Assistant ## after the first state change or clearing retained MQTT topics ## ## 1.1.1 (2018-08-11) ## Added ## - Added input text box named `MQTT Topic to Clear`, which can be used ## to clear MQTT topics with retained messages ## - Set initial_state to on for all automations to ensure they are enabled ## on startup ## Changed ## - Consider entities with battery in their entity_id or friendly_name a ## battery sensor if neither an icon nor a device class is defined ## - Consolidated the battery_sensor_from_* automations into a single ## automation ## ## 1.1.2 (2018-08-23) ## Fixed ## - Fixed issue where non-battery sensors with Battery in their name are ## added to group.battery_status ## ## 1.1.3 (2018-11-17) ## Fixed ## - Filter out trigger=none from automation.battery_sensor_from_attributes ## - Don't convert float to int in mqtt payload ## ## 1.1.4 (2018-11-17) ## Fixed ## - Ignore entities with null states ## - Fix issue causing TypeError: object of type 'NoneType' has no len() ## ## 1.1.5 (2018-11-18) ## Added ## - Add support for defining battery_template_string attibute to ## support templates that return strings ## ## 1.1.6 (2018-11-21) ## Removed ## - Removed attribute named attribute on the sensors ## Added ## - Added attribute to the MQTT sensors with the same name and value as the ## original entity ## ## 1.2.0 (2019-01-20) ## Breaking Changes ## - Setting up notifications have changed. Enter the name of the notifier in the `Notifier Name` input text box ## and select the notifier format using the `Notifier Format` input select. ## Changed ## - Migrate attributes from json_attributes to json_attributes_topic ## - Remove % unit for battery level attributes that contain strings ## - Replaced mqtt_config_topic and mqtt_state_topic attributes with delete_battery_sensor attribute ## to make deleting battery sensors easier ## - Renamed MQTT Topic to Clear input text box to Delete a Battery Sensor ## Added ## - Battery attributes containing strings now have dynamic icons that change with battery status ## - Added Notifier Name input text box to store name of the notifier to use for notifications (defaults to notify.notify) ## - Added Notifier Format input select to allow selection of notification format. Options are Default and Slack. ## - Added input_boolean.low_batteries to help with automations. True means there are low batteries. ## ## 1.2.1 (2019-01-23) ## Changed ## - Fixed Time platform to time_pattern platform ## ## 1.2.2 (2019-02-09) ## Added ## - Alert if battery state is unavailable ## Removed ## - Removed startup trigger from automation.update_battery_status_group_members ## Changed ## - Default to notify.notify if input_text.notifier_name doesn't contain "notify." ## ## 1.2.3 (2019-03-02) ## Changed ## - Handle null attributes gracefully ## ## 1.2.4 (2019-03-02) ## Added ## - Added support for battery_critical attributes by @Djebouh ## ## 1.3.0 (2020-11-05) by @KptnKMan ## Info ## - Running successfully with HA 0.117.2 ## Breaking Changes ## - Should be none, as far as I can tell. ## Fixed ## - Removed depreciated and defunct Group settings ## Removed ## - Persistent Notification of "None (Unavailable)" entities ## - Battery Status of "None (Unavailable)" entities ## - Battery Status Group no longer adds restored Unavailable entities ## - MQTT publish no longer adds restored Unavailable entities ## Added ## - Added Lovelace install instructions :) ## ################################################################ ################################################################ ################################################################ ## Install Instructions ################################################################ ## ## 1. Enable MQTT using your preferred MQTT broker ## https://home-assistant.io/components/mqtt/ ## ## 2. Enable MQTT Discovery by adding `discovery: true` and ## `discovery_prefix: homeassistant` under the `mqtt:` section ## of your configuration.yaml ## ## mqtt: ## discovery: true ## discovery_prefix: homeassistant ## ## 3. Save this file as CONFIGDIR/packages/battery_alert.yaml ## ## 4. Add `packages: !include_dir_named packages` under the ## `homeassistant:` section of your configuration.yaml ## ## homeassistant: ## packages: !include_dir_named packages ## ## 5. Restart Home Assistant ## ## 6. Adjust Min Alert Threshold slider to the minimum battery ## level to alert on. Note: the input slider requires the ## recorder component to keep it's state through restarts. ## If recorder is not enabled, the threshold can be set by ## un-remarking `initial` and setting the preferred default. ## ## 7. Adjust Max Alert Threshold slider to the maximum battery ## level to alert on. Note: the input slider requires the ## recorder component to keep it's state through restarts. ## If recorder is not enabled, the threshold can be set by ## un-remarking `initial` and setting the preferred default. ## ## 8. Setup notifications by entering the notifier name in the `Notifier Name` input text box. ## E.g. `notify.slack`. If no value is entered, it defaults to `notify.notify`. ## ## 9. Set the notifier format by selecting either `Default` or `Slack. Note: most notifiers ## are compatible with the `Default` format. ## ## 10. To disable alerts for a specific entity, use customize to ## set `battery_alert_disabled` to `true` ## ## homeassistant: ## customize: ## sensor.sensor_name_to_ignore_battery: ## battery_alert_disabled: true ## ## 11. To disable creating a sensor from battery attributes for a specific entity, use customize to ## set `battery_sensor_creation_disabled` to `true` ## ## homeassistant: ## customize: ## sensor.sensor_with_battery_attibute: ## battery_sensor_creation_disabled: true ## ## 12. If a battery attribute requires a template to convert it into a usable percent, use customize ## to add `battery_template` with the necessary template. The template result must be a number ## that represents a percentage. ## ## This example will create a battery sensor with the value of battery_level * 2 ## ## homeassistant: ## customize: ## sensor.sensor_with_battery_attibute_template: ## battery_template: "{{ value_json.value | int * 2 }}" ## ## 13. If a battery attribute requires a template to convert it into a string, use customize to add ## `battery_template_string` with the necessary template. The template result must be a string. ## For example, "Low" will trigger low battery notification). ## ## This example will create a battery sensor that contains "Low" if battery_level ## is less than 2 ## ## homeassistant: ## customize: ## sensor.sensor_with_battery_attibute_template: ## battery_template_string: >- ## {%- if value_json.value < 2 -%} ## Low ## {%- else -%} ## Full ## {%- endif -%} ################################################################ ################################################################ ## Lovelace Instructions - version 0.117+ ################################################################ ## ## If you are using a recent version of Home Asssistant, and want to add the Battery Alert ## to your Lovelace Dashboard, you should add the code snippet below to your Lovelace config. ## ## You can add this via the UI, select 'Edit Dashboard' -> 'Raw Configuration Editor'. ## You can also add it directly to your 'lovelace.yaml' file. ## ## You should just be able to add this to the bottom, and be good to go :) ## ## - title: Battery Alert ## path: battery-alert ## icon: 'mdi:battery-alert' ## badges: [] ## cards: ## - type: entities ## entities: ## - entity: input_boolean.low_batteries ## - entity: input_number.battery_alert_threshold_min ## - entity: input_number.battery_alert_threshold_max ## - entity: input_text.delete_battery_sensor ## - entity: input_text.notifier_name ## - entity: input_select.notifier_format ## - entity: automation.battery_persistent_notification ## - entity: automation.battery_persistent_notification_clear ## - entity: automation.battery_notification_default ## - entity: automation.battery_notification_slack ## - entity: automation.battery_sensor_from_attributes ## - entity: automation.update_battery_status_group_members ## - entity: automation.delete_battery_sensor ## title: Battery Alert Main ## show_header_toggle: false ## - type: entities ## entities: ## - entity: group.battery_status ## - entity: group.battery_alert ## - entity: group.battery_view ## title: Battery Alert View ## show_header_toggle: false ## ################################################################ ################################################################ ################################################ ## Customize ################################################ homeassistant: customize: ################################################ ## Node Anchors ################################################ package.node_anchors: customize: &customize package: 'battery_alert' ################################################ ## Group ################################################ group.battery_view: <<: *customize friendly_name: "Batteries" icon: mdi:battery-alert group.battery_alert: <<: *customize friendly_name: "Battery Alert" icon: mdi:steam group.battery_status: <<: *customize friendly_name: "Battery Status" icon: mdi:battery-charging ################################################ ## Automation ################################################ automation.battery_persistent_notification: <<: *customize friendly_name: "Battery Persistent Notification" icon: mdi:comment-alert-outline automation.battery_persistent_notification_clear: <<: *customize friendly_name: "Battery Persistent Notification Clear" icon: mdi:comment-remove-outline automation.battery_notification_default: <<: *customize friendly_name: "Battery Notification Default Format" icon: mdi:comment-alert-outline automation.battery_notification_slack: <<: *customize friendly_name: "Battery Notification Slack Format" icon: mdi:comment-alert-outline automation.battery_sensor_from_attributes: <<: *customize friendly_name: "Create Battery Sensor from Attributes" icon: mdi:battery-charging-wireless-outline automation.update_battery_status_group_members: <<: *customize friendly_name: "Update Battery Status Group Members" icon: mdi:group automation.delete_battery_sensor: <<: *customize friendly_name: "Delete a Battery Sensor" icon: mdi:server-remove ################################################ ## Group ################################################ group: battery_view: entities: - group.battery_status - group.battery_alert battery_alert: entities: - input_boolean.low_batteries - input_number.battery_alert_threshold_min - input_number.battery_alert_threshold_max - input_text.delete_battery_sensor - input_text.notifier_name - input_select.notifier_format - automation.battery_persistent_notification - automation.battery_persistent_notification_clear - automation.battery_notification_default - automation.battery_notification_slack - automation.battery_sensor_from_attributes - automation.update_battery_status_group_members - automation.delete_battery_sensor ################################################ ## Input Boolean ################################################ input_boolean: low_batteries: name: Low Batteries icon: mdi:battery-alert ################################################ ## Input Number ################################################ input_number: battery_alert_threshold_max: name: "Max Alert Threshold" icon: mdi:arrow-collapse-up mode: slider min: -1 max: 100 # initial: 40 battery_alert_threshold_min: name: "Min Alert Threshold" icon: mdi:arrow-collapse-down mode: slider min: -1 max: 100 # initial: -1 ################################################ ## Input Select ################################################ input_select: notifier_format: name: Notifier Format options: - Default - Slack icon: mdi:comment-question-outline ################################################ ## Input Text ################################################ input_text: delete_battery_sensor: name: Delete a Battery Sensor mode: text initial: '' notifier_name: name: Notifier Name mode: text ################################################ ## Automation ################################################ automation: - alias: battery_persistent_notification initial_state: 'on' trigger: - platform: time_pattern minutes: '/15' seconds: 00 - platform: state entity_id: - input_number.battery_alert_threshold_min - input_number.battery_alert_threshold_max action: - condition: template value_template: &low_battery_check > {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if ( not ( is_state_attr(entity_id, 'battery_alert_disabled', true) or is_state_attr(entity_id, 'restored', true) ) and states(entity_id) is not none and ( ( ( states(entity_id) is number or states(entity_id) | length == states(entity_id)| int | string | length or states(entity_id) | length == states(entity_id)| float | string | length ) and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int ) or states(entity_id) | lower == 'low' or states(entity_id) | lower == 'unknown' or states(entity_id) | lower == 'unavailable' ) ) -%} {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }}) {% endfor -%} {% endmacro %} {{ battery_level() | trim != "" }} - service: input_boolean.turn_on data: entity_id: input_boolean.low_batteries - service: persistent_notification.create data_template: title: "Low Battery Levels" notification_id: low_battery_alert message: &message > {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if ( not ( is_state_attr(entity_id, 'battery_alert_disabled', true) or is_state_attr(entity_id, 'restored', true) ) and states(entity_id) is not none and ( ( ( states(entity_id) is number or states(entity_id) | length == states(entity_id)| int | string | length or states(entity_id) | length == states(entity_id)| float | string | length ) and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int ) or states(entity_id) | lower == 'low' or states(entity_id) | lower == 'unknown' or states(entity_id) | lower == 'unavailable' ) ) -%} {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }}) {% endfor -%} {% endmacro %} {{ battery_level() }} - alias: battery_persistent_notification_clear initial_state: 'on' trigger: - platform: time_pattern minutes: '/15' seconds: 00 - platform: state entity_id: - input_number.battery_alert_threshold_min - input_number.battery_alert_threshold_max action: - condition: template value_template: &low_battery_clear > {% macro battery_level() %} {% for entity_id in states.group.battery_status.attributes.entity_id if ( not ( is_state_attr(entity_id, 'battery_alert_disabled', true) or is_state_attr(entity_id, 'restored', true) ) and states(entity_id) is not none and ( ( ( states(entity_id) is number or states(entity_id) | length == states(entity_id)| int | string | length or states(entity_id) | length == states(entity_id)| float | string | length ) and states(entity_id) | int < states.input_number.battery_alert_threshold_max.state | int and states(entity_id) | int > states.input_number.battery_alert_threshold_min.state | int ) or states(entity_id) | lower == 'low' or states(entity_id) | lower == 'unknown' or states(entity_id) | lower == 'unavailable' ) ) -%} {{ state_attr(entity_id, "friendly_name") }} ({{ states(entity_id) }}) {% endfor -%} {% endmacro %} {{ battery_level() | trim == "" }} - service: input_boolean.turn_off data: entity_id: input_boolean.low_batteries - service: persistent_notification.dismiss data: notification_id: low_battery_alert - alias: battery_notification_default initial_state: 'on' trigger: - platform: time at: '10:00:00' - platform: time at: '18:00:00' - platform: state entity_id: - input_number.battery_alert_threshold_min - input_number.battery_alert_threshold_max action: - condition: template value_template: *low_battery_check - condition: template value_template: "{{ states.input_select.notifier_format.state == 'Default' }}" - service_template: > {% if "notify." in states.input_text.notifier_name.state %} {{ states.input_text.notifier_name.state }} {% else %} notify.notify {% endif %} data_template: title: "Low Battery Levels" message: *message - alias: battery_notification_slack initial_state: 'on' trigger: - platform: time at: '10:00:00' - platform: time at: '18:00:00' - platform: state entity_id: - input_number.battery_alert_threshold_min - input_number.battery_alert_threshold_max action: - condition: template value_template: *low_battery_check - condition: template value_template: "{{ states.input_select.notifier_format.state == 'Slack' }}" - service_template: > {% if states.input_text.notifier_name.state != "" %} {{ states.input_text.notifier_name.state }} {% else %} notify.notify {% endif %} data_template: message: "Low Battery Levels" data: attachments: - color: '#52c0f2' title: "These devices have low battery levels" text: *message - alias: battery_sensor_from_attributes initial_state: 'on' trigger: - platform: event event_type: state_changed condition: - condition: template value_template: "{{ trigger is not none }}" - condition: template value_template: "{{ trigger.event.data is not none }}" - condition: template value_template: "{{ trigger.event.data.old_state is not none }}" - condition: template value_template: "{{ trigger.event.data.new_state is not none }}" - condition: template value_template: "{{ 'battery' not in trigger.event.data.new_state.name | lower }}" - condition: template value_template: "{{ not is_state_attr(trigger.event.data.entity_id, 'device_class', 'battery') }}" - condition: template value_template: "{{ not is_state_attr(trigger.event.data.entity_id, 'battery_sensor_creation_disabled', true) }}" - condition: template value_template: "{{ not is_state_attr(trigger.event.data.entity_id, 'restored', true) }}" - condition: or conditions: - condition: and conditions: - condition: template value_template: "{{ trigger.event.data.new_state.attributes.battery_level is defined }}" - condition: template value_template: "{{ trigger.event.data.new_state.attributes.battery_level is not none }}" - condition: and conditions: - condition: template value_template: "{{ trigger.event.data.new_state.attributes.battery is defined }}" - condition: template value_template: "{{ trigger.event.data.new_state.attributes.battery is not none }}" - condition: and conditions: - condition: template value_template: "{{ trigger.event.data.new_state.attributes['Battery numeric'] is defined }}" - condition: template value_template: "{{ trigger.event.data.new_state.attributes['Battery numeric'] is not none }}" - condition: and conditions: - condition: template value_template: "{{ trigger.event.data.new_state.attributes.battery_critical is defined }}" - condition: template value_template: "{{ trigger.event.data.new_state.attributes.battery_critical is not none }}" action: - service: mqtt.publish data_template: topic: "homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery/config" retain: true payload: &config_payload >- { {% if trigger.event.data.new_state.attributes.battery_level is defined -%} {%- set attribval = trigger.event.data.new_state.attributes.battery_level -%} {%- set attribname = 'battery_level' -%} {%- elif trigger.event.data.new_state.attributes.battery is defined -%} {%- set attribval = trigger.event.data.new_state.attributes.battery -%} {%- set attribname = 'battery' -%} {%- elif trigger.event.data.new_state.attributes['Battery numeric'] is defined -%} {%- set attribval = (trigger.event.data.new_state.attributes['Battery numeric'] | int + 1) * 10 -%} {%- set attribname = 'Battery numeric' -%} {% elif trigger.event.data.new_state.attributes.battery_critical is defined -%} {%- set attribval = trigger.event.data.new_state.attributes.battery_critical -%} {%- set attribname = 'battery_critical' -%} {%- endif -%} "name": "{{ trigger.event.data.new_state.name }} Battery", "state_topic": "homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery/state", {% if trigger.event.data.new_state.attributes.battery_template is defined -%} "value_template": "{{ trigger.event.data.new_state.attributes.battery_template }}", "unit_of_measurement": "%", "device_class": "battery", {% elif trigger.event.data.new_state.attributes.battery_template_string is defined -%} "value_template": "{{ trigger.event.data.new_state.attributes.battery_template_string }}", "icon": "mdi:battery", {% elif trigger.event.data.new_state.attributes.battery_critical is defined -%} "value_template": "{{ "{{" }} 'low' if value_json.value else 'full' {{ "}}" }}", "icon": "mdi:battery", {% else -%} "value_template": "{{ "{{" }} value_json.value | int {{ "}}" }}", {% if attribval | int == attribval or attribval | float == attribval or attribval | length == attribval | float | string | length or attribval | length == attribval | int | string | length -%} "unit_of_measurement": "%", "device_class": "battery", {%- elif attribval == "High" or attribval == "Full" -%} "icon": "mdi:battery", {%- elif attribval == "Medium" or attribval == "Med"-%} "icon": "mdi:battery-50", {%- elif attribval == "Low" -%} "icon": "mdi:battery-alert", {%- else -%} "icon": "mdi:battery-unknown", {%- endif %} {% endif -%} "unique_id": "{{ trigger.event.data.entity_id.split('.')[1] }}_battery", "json_attributes_topic": "homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery/attributes" } - service: mqtt.publish data_template: topic: "homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery/state" retain: true payload: >- { {% if trigger.event.data.new_state.attributes.battery_level is defined -%} {%- set attribval = trigger.event.data.new_state.attributes.battery_level -%} {%- elif trigger.event.data.new_state.attributes.battery is defined -%} {%- set attribval = trigger.event.data.new_state.attributes.battery -%} {%- elif trigger.event.data.new_state.attributes['Battery numeric'] is defined -%} {%- set attribval = (trigger.event.data.new_state.attributes['Battery numeric'] | int + 1) * 10 -%} {%- elif trigger.event.data.new_state.attributes.battery_critical is defined -%} {%- set attribval = trigger.event.data.new_state.attributes.battery_critical -%} {%- endif -%} "value": {% if attribval | int == attribval -%} {{ attribval | int }} {%- elif attribval | float == attribval -%} {{ attribval | float }} {%- elif attribval | length == attribval | float | string | length -%} {{ attribval | float }} {%- elif attribval | length == attribval | int | string | length -%} {{ attribval | int }} {%- else -%} "{{ attribval }}" {%- endif %} } - service: mqtt.publish data_template: topic: "homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery/attributes" retain: true payload: >- { {% if trigger.event.data.new_state.attributes.battery_level is defined -%} {%- set attribval = trigger.event.data.new_state.attributes.battery_level -%} {%- set attribname = 'battery_level' -%} {%- elif trigger.event.data.new_state.attributes.battery is defined -%} {%- set attribval = trigger.event.data.new_state.attributes.battery -%} {%- set attribname = 'battery' -%} {%- elif trigger.event.data.new_state.attributes['Battery numeric'] is defined -%} {%- set attribval = (trigger.event.data.new_state.attributes['Battery numeric'] | int + 1) * 10 -%} {%- set attribname = 'Battery numeric' -%} {%- elif trigger.event.data.new_state.attributes.battery_critical is defined -%} {%- set attribval = trigger.event.data.new_state.attributes.battery_critical -%} {%- set attribname = 'battery_critical' -%} {%- endif -%} "entity_id": "{{ trigger.event.data.entity_id }}", {% if attribname is defined -%} "{{ attribname }}": "{{ attribval }}", {%- endif %} "delete_battery_sensor": "homeassistant/sensor/{{ trigger.event.data.entity_id.split('.')[1] }}_battery" } - alias: update_battery_status_group_members initial_state: 'on' trigger: - platform: time_pattern minutes: '/1' seconds: 00 action: - service: group.set data_template: object_id: "battery_status" entities: >- {%- for item in states.sensor if ( not is_state_attr(item.entity_id, 'hidden', true) and ( is_state_attr(item.entity_id, 'device_class', 'battery') or 'battery' in item.attributes.icon | lower or (item.entity_id | lower).endswith('_bat') or (item.name | lower).endswith('_bat') ) or ( ( 'battery' in item.entity_id | lower or 'battery' in item.name | lower ) and ( item.attributes.icon is not defined ) and ( not is_state_attr(item.entity_id, 'battery_alert_disabled', true) ) and ( not is_state_attr(item.entity_id, 'restored', true) ) ) ) -%} {{ item.entity_id }}{% if not loop.last %}, {% endif %} {%- endfor -%} - alias: delete_battery_sensor initial_state: 'on' trigger: - platform: state entity_id: - input_text.delete_battery_sensor condition: - condition: template value_template: "{{ 'homeassistant/sensor/' in states.input_text.delete_battery_sensor.state }}" action: - service: mqtt.publish data_template: topic: "{{ states.input_text.delete_battery_sensor.state }}" retain: true - service: mqtt.publish data_template: topic: "{{ states.input_text.delete_battery_sensor.state }}/attributes" retain: true - service: mqtt.publish data_template: topic: "{{ states.input_text.delete_battery_sensor.state }}/state" retain: true - service: mqtt.publish data_template: topic: "{{ states.input_text.delete_battery_sensor.state }}/config" retain: true ================================================ FILE: sensors.yaml ================================================ ================================================ FILE: switches.yaml ================================================ ================================================ FILE: travis_secrets.yaml ================================================ http_api_password: password home_latitude: 000.0000000 home_longitude: 000.0000000 home_elevation: 00 home_timezone: America/New_York trusted_ip: 10.0.0.0/8 ha_ip: 127.0.0.1 mqtt_broker_ip: 127.0.0.1 mqtt_port: 1883 mqtt_username: username mqtt_password: password mqtt_client_id: hass-1 ================================================ FILE: zones.yaml ================================================