diff --git a/lnxlink/modules/disk_usage.py b/lnxlink/modules/disk_usage.py index 98728e2..6b9702c 100644 --- a/lnxlink/modules/disk_usage.py +++ b/lnxlink/modules/disk_usage.py @@ -20,8 +20,8 @@ def exposed_controls(self): "icon": "mdi:harddisk", "unit": "%", "state_class": "measurement", - "value_template": f"{{{{ value_json.{device}.percent }}}}", - "attributes_template": f"{{{{ value_json.{device} | tojson }}}}", + "value_template": f"{{{{ value_json.get('{device}', {{}}).get('percent') }}}}", + "attributes_template": f"{{{{ value_json.get('{device}', {{}}) | tojson }}}}", "enabled": True, } return discovery_info @@ -35,6 +35,7 @@ def get_info(self): for disk_name in unmounted: disks[disk_name] = self.disks[disk_name] self.disks[disk_name]['connected'] = False + self.disks[disk_name]['percent'] = None self.disks = disks for disk_name in mounted: self.lnxlink.setup_discovery()