File tree 2 files changed +18
-12
lines changed
2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ def _get_disks(self):
69
69
disks = []
70
70
for disk in glob .glob ("/sys/block/*" , recursive = False ):
71
71
disk_name = disk .removeprefix ("/sys/block/" )
72
- excludes = ["loop" , "ram" ]
72
+ excludes = ["loop" , "ram" , "zram" ]
73
73
if any (disk_name .startswith (x ) for x in excludes ):
74
74
continue
75
75
disks .append (disk_name )
Original file line number Diff line number Diff line change @@ -19,17 +19,23 @@ def __init__(self, lnxlink):
19
19
def start_control (self , topic , data ):
20
20
"""Control system"""
21
21
self .lnxlink .temp_connection_callback (True )
22
- if which ("systemctl" ) is not None :
23
- syscommand ("systemctl poweroff" )
24
- elif which ("shutdown" ) is not None :
25
- syscommand ("shutdown now" )
26
- else :
27
- bus = self .dbus .connection .SystemMessageBus ()
28
- proxy = bus .get_proxy (
29
- service_name = "org.freedesktop.login1" ,
30
- object_path = "/org/freedesktop/login1" ,
31
- )
32
- proxy .PowerOff (True )
22
+ returncode = None
23
+ if which ("systemctl" ) is not None and returncode != 0 :
24
+ _ , _ , returncode = syscommand ("systemctl poweroff" )
25
+ if which ("shutdown" ) is not None and returncode != 0 :
26
+ _ , _ , returncode = syscommand ("shutdown now" )
27
+ if returncode != 0 :
28
+ try :
29
+ bus = self .dbus .connection .SystemMessageBus ()
30
+ proxy = bus .get_proxy (
31
+ service_name = "org.freedesktop.login1" ,
32
+ object_path = "/org/freedesktop/login1" ,
33
+ )
34
+ proxy .PowerOff (True )
35
+ except Exception :
36
+ returncode = - 1
37
+ if returncode != 0 :
38
+ self .lnxlink .temp_connection_callback (False )
33
39
34
40
def exposed_controls (self ):
35
41
"""Exposes to home assistant"""
You can’t perform that action at this time.
0 commit comments