We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4ccb1ca commit e109802Copy full SHA for e109802
modules/devices/SDevices_batteryLevelUpdated.php
@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+$batteryOperated = (int)$this->getProperty('batteryOperated');
4
+$batteryLevel = (int)$this->getProperty('batteryLevel');
5
6
+if ($batteryOperated && $batteryLevel <= 20) {
7
+ $batteryWarning = 1;
8
+} elseif ($batteryOperated && $batteryLevel <= 50) {
9
+ $batteryWarning = 2;
10
+} else {
11
+ $batteryWarning = 0;
12
+}
13
14
+$this->setProperty('batteryWarning', $batteryWarning);
15
16
+if ($batteryOperated && $batteryLevel>0) {
17
+ $this->callMethod('keepAlive');
18
0 commit comments