###############################################################################
#   @author         :   Jeffrey Stone 
#   @date           :   06/12/2020
#   @package        :   Batteries
#   @description    :   Package for handling Battery automations and scripts.  
###############################################################################


sensor:
  - platform: mqtt
    name: "Battery Front Door Sensor"
    state_topic: "zwave2mqtt/front_door/128/1/0"
    unit_of_measurement: "%"
    device_class: battery
    value_template: "{{ value }}"
    json_attributes_topic: "zwave2mqtt/front_door/128/1/0"
  - platform: mqtt
    name: "Battery Laundry Door Sensor"
    state_topic: "zwave2mqtt/laundry_door/128/1/0"
    unit_of_measurement: "%"
    device_class: battery
    value_template: "{{ value }}"
    json_attributes_topic: "zwave2mqtt/laundry_door/128/1/0"
  - platform: mqtt
    name: "Battery Kitchen Smoke Detector"
    state_topic: "zwave2mqtt/kitchen_smoke/128/1/0"
    unit_of_measurement: "%"
    device_class: battery
    value_template: "{{ value }}"
    json_attributes_topic: "zwave2mqtt/kitchen_smoke/128/1/0"
  - platform: mqtt
    name: "Battery Garage Smoke Detector"
    state_topic: "zwave2mqtt/garage_smoke/128/1/0"
    unit_of_measurement: "%"
    device_class: battery
    value_template: "{{ value }}"
    json_attributes_topic: "zwave2mqtt/garage_smoke/128/1/0"
  - platform: mqtt
    name: "Battery Attic Door Sensor"
    state_topic: "zwave2mqtt/attic_door/128/1/0"
    unit_of_measurement: "%"
    device_class: battery
    value_template: "{{ value }}"
    json_attributes_topic: "zwave2mqtt/attic_door/128/1/0"
  - platform: mqtt
    name: "Battery Washer Door Sensor"
    state_topic: "zwave2mqtt/washer_door/128/1/0"
    unit_of_measurement: "%"
    device_class: battery
    value_template: "{{ value }}"
    json_attributes_topic: "zwave2mqtt/washer_door/128/1/0"
  - platform: mqtt
    name: "Battery Back Door Sensor"
    state_topic: "zwave2mqtt/back_door/128/1/0"
    unit_of_measurement: "%"
    device_class: battery
    value_template: "{{ value }}"
    json_attributes_topic: "zwave2mqtt/back_door/128/1/0"
  - platform: mqtt
    name: "Battery Side Door Sensor"
    state_topic: "zwave2mqtt/side_door/128/1/0"
    unit_of_measurement: "%"
    device_class: battery
    value_template: "{{ value }}"
    json_attributes_topic: "zwave2mqtt/side_door/128/1/0"
  - platform: mqtt
    name: "Battery Garage Door Sensor"
    state_topic: "zwave2mqtt/garage_door/128/1/0"
    unit_of_measurement: "%"
    device_class: battery
    value_template: "{{ value }}"
    json_attributes_topic: "zwave2mqtt/garage_door/128/1/0"
  - platform: mqtt 
    name: "Battery Garage Motion Sensor"
    state_topic: "zwave2mqtt/garage_motion/128/1/0"
    unit_of_measurement: "%"
    device_class: battery
    value_template: "{{ value }}"
    json_attributes_topic: "zwave2mqtt/garage_motion/128/1/0"

# automation:
  
#   - alias: 'Battery Alert'
#     initial_state: true
#     trigger:
#       - platform: time
#         at: '10:00:00'
#       - platform: time
#         at: '18:00:00'
#     condition:
#       condition: template
#       value_template: "{% if states('sensor.low_battery') %}true{% endif %}"
#     action:
#       - service: persistent_notification.create
#         data_template:
#           title: Low Battery
#           message: "{{ states('sensor.low_battery') }}"
#           notification_id: low-battery-alert
#       - service: script.text_notify
#         data_template:
#           title: "HA Issue"
#           message: "Low battery levels: {{ states('sensor.low_battery') }}"
#           who: 'jeff'