Add ‘%’ unit_of_measurement for Home Assistant battery sensor. #787

This commit is contained in:
Koen Kanters 2019-01-06 15:35:30 +01:00
parent 3bb1f0f10b
commit 3d0541a32d
2 changed files with 12 additions and 0 deletions

View File

@ -555,6 +555,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:
@ -595,6 +596,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:
@ -622,6 +624,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:
@ -649,6 +652,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:
@ -676,6 +680,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:
@ -792,6 +797,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:
@ -819,6 +825,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:
@ -1494,6 +1501,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:
@ -2746,6 +2754,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:
@ -2773,6 +2782,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:
@ -2922,6 +2932,7 @@ sensor:
- platform: "mqtt"
state_topic: "zigbee2mqtt/<FRIENDLY_NAME>"
availability_topic: "zigbee2mqtt/bridge/state"
unit_of_measurement: "%"
device_class: "battery"
value_template: "{{ value_json.battery }}"
json_attributes:

View File

@ -176,6 +176,7 @@ const configurations = {
type: 'sensor',
object_id: 'battery',
discovery_payload: {
unit_of_measurement: '%',
device_class: 'battery',
value_template: '{{ value_json.battery }}',
json_attributes: ['linkquality', 'voltage', 'action', 'sensitivity', 'last_seen'],