-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
143 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity | ||
from homeassistant.helpers.entity import DeviceInfo | ||
|
||
class battery_percentage_sensor(SensorEntity): | ||
def __init__(self, device): | ||
self._device = device | ||
|
||
@property | ||
def available(self): | ||
return self._device.available | ||
|
||
@property | ||
def device_info(self) -> DeviceInfo: | ||
return self._device.device_info | ||
|
||
@property | ||
def unique_id(self): | ||
return f"{self._device.unique_id}_BP01" | ||
|
||
@property | ||
def device_class(self) -> str: | ||
return SensorDeviceClass.BATTERY | ||
|
||
@property | ||
def native_unit_of_measurement(self) -> str: | ||
return "%" | ||
|
||
@property | ||
def name(self) -> str: | ||
return f"{self._device.name} Battery" | ||
|
||
@property | ||
def native_value(self): | ||
return getattr(self._device, "battery_percentage", 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
dirigera==1.1.1 | ||
dirigera==1.1.4 |