-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed text sensors shown as numeric - Entity id for new integrations show the clientId - Breaking change to bluetooth_battery, replaced with battery
- Loading branch information
Showing
5 changed files
with
39 additions
and
32 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 |
---|---|---|
|
@@ -49,7 +49,7 @@ | |
update_interval: 5 | ||
modules: | ||
- bash | ||
- bluetooth_battery | ||
- battery | ||
- camera_used | ||
- cpu | ||
- disk_usage | ||
|
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,32 @@ | ||
import subprocess | ||
import jc | ||
|
||
|
||
class Addon(): | ||
def __init__(self, lnxlink): | ||
self.name = 'Battery' | ||
self.sensor_type = 'sensor' | ||
self.icon = 'mdi:battery' | ||
self.device_class = 'battery' | ||
self.unit = 'json' | ||
|
||
def getInfo(self) -> dict: | ||
stdout = subprocess.run( | ||
'upower --dump', | ||
shell=True, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE).stdout.decode("UTF-8") | ||
upower_json = jc.parse('upower', stdout) | ||
|
||
devices = {'status': None} | ||
for device in upower_json: | ||
if 'detail' in device: | ||
if 'percentage' in device['detail']: | ||
name = ''.join([ | ||
device.get('vendor', ''), | ||
device.get('model', ''), | ||
]).strip() | ||
devices[name] = device['detail']['percentage'] | ||
if devices['status'] is None: | ||
devices['status'] = device['detail']['percentage'] | ||
return devices |
This file was deleted.
Oops, something went wrong.
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