File tree Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -106,11 +106,31 @@ def check_rpi_power_status():
106106 full_cmd = "vcgencmd get_throttled | cut -d= -f2"
107107 throttled = subprocess .Popen (full_cmd , shell = True , stdout = subprocess .PIPE ).communicate ()[0 ]
108108 throttled = throttled .decode ('utf-8' ).strip ()
109-
110- if throttled == "0x0" :
111- return "OK"
112- else :
113- return "KO"
109+ throttled_val = int (throttled , 16 )
110+
111+ if throttled_val & 1 << 0 :
112+ return "Under-voltage"
113+ if throttled_val & 1 << 3 :
114+ return "Soft temperature limit"
115+ if throttled_val & 1 << 1 :
116+ return "ARM frequency capped"
117+ if throttled_val & 1 << 2 :
118+ return "Throttled"
119+
120+ # These are "previous" statuses here for completeness
121+ # Home Assistant has the history so do not report them
122+ #
123+ #if throttled_val & 1<<16:
124+ # return "Previous under-voltage"
125+ #if throttled_val & 1<<17:
126+ # return "Previous ARM frequency cap"
127+ #if throttled_val & 1<<18:
128+ # return "Previous throttling"
129+ #if throttled_val & 1<<19:
130+ # return "Previous soft temperature limit"
131+
132+ return "OK"
133+
114134 except Exception as e :
115135 return "Error: " + str (e )
116136
You can’t perform that action at this time.
0 commit comments