Completed
Push — master ( ce3d64...3a87d5 )
by Kirill
04:20
created
src/AppBundle/Controller/NooliteController.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 
14 14
     private $channelMap = [
15 15
 
16
-        1 => ['name'=>'noolite.main','source'=>'human'],
17
-        2 => ['name'=>'noolite.kitchen','source'=>'human'],
18
-        3 => ['name'=>'noolite.diningroom','source'=>'human'],
19
-        4 => ['name'=>'noolite.main','source'=>'pi'],
20
-        5 => ['name'=>'noolite.toilet','source'=>'pi'],
21
-        6 => ['name'=>'noolite.diningroom','source'=>'pi'],
22
-        7 => ['name'=>'noolite.kitchen','source'=>'pi'],
23
-        9 => ['name'=>'noolite.toilet','source'=>'human,upper'],
24
-        10 => ['name'=>'noolite.toilet','source'=>'human,lower'],
16
+        1 => ['name'=>'noolite.main', 'source'=>'human'],
17
+        2 => ['name'=>'noolite.kitchen', 'source'=>'human'],
18
+        3 => ['name'=>'noolite.diningroom', 'source'=>'human'],
19
+        4 => ['name'=>'noolite.main', 'source'=>'pi'],
20
+        5 => ['name'=>'noolite.toilet', 'source'=>'pi'],
21
+        6 => ['name'=>'noolite.diningroom', 'source'=>'pi'],
22
+        7 => ['name'=>'noolite.kitchen', 'source'=>'pi'],
23
+        9 => ['name'=>'noolite.toilet', 'source'=>'human,upper'],
24
+        10 => ['name'=>'noolite.toilet', 'source'=>'human,lower'],
25 25
     ];
26 26
 
27 27
     /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             $changeSet = [];
61 61
 
62 62
 
63
-            if ($request->get('cmd')==4) {
63
+            if ($request->get('cmd') == 4) {
64 64
                 // reverse state, only by human
65 65
 
66 66
                 $oldState = $device->getState();
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                     /** @var Action $action */
74 74
                     foreach ($actions as $action) {
75 75
                         $args = json_decode($action->getArguments(), true);
76
-                        if (isset($args['state']) && ($args['state']=='on')) {
76
+                        if (isset($args['state']) && ($args['state'] == 'on')) {
77 77
                             $resultAction = $action;
78 78
                             break;
79 79
                         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                     /** @var Action $action */
85 85
                     foreach ($actions as $action) {
86 86
                         $args = json_decode($action->getArguments(), true);
87
-                        if (isset($args['state']) && ($args['state']=='off')) {
87
+                        if (isset($args['state']) && ($args['state'] == 'off')) {
88 88
                             $resultAction = $action;
89 89
                             break;
90 90
                         }
@@ -92,44 +92,44 @@  discard block
 block discarded – undo
92 92
                 }
93 93
             }
94 94
 
95
-            if ($request->get('cmd')==0) {
95
+            if ($request->get('cmd') == 0) {
96 96
                 // turn off, only by pi
97 97
 
98 98
                 $changeSet = ['state'=>'off'];
99 99
                 /** @var Action $action */
100 100
                 foreach ($actions as $action) {
101 101
                     $args = json_decode($action->getArguments(), true);
102
-                    if (isset($args['state']) && ($args['state']=='off')) {
102
+                    if (isset($args['state']) && ($args['state'] == 'off')) {
103 103
                         $resultAction = $action;
104 104
                         break;
105 105
                     }
106 106
                 }
107 107
             }
108 108
 
109
-            if ($request->get('cmd')==6) {
109
+            if ($request->get('cmd') == 6) {
110 110
                 // turn off, only by pi
111 111
 
112
-                $percent = round((($request->get('d0') - 34)/123) * 100);
112
+                $percent = round((($request->get('d0') - 34)/123)*100);
113 113
 
114
-                $changeSet = ['state'=>'on','percent'=>$percent];
114
+                $changeSet = ['state'=>'on', 'percent'=>$percent];
115 115
                 /** @var Action $action */
116 116
                 foreach ($actions as $action) {
117 117
                     $args = json_decode($action->getArguments(), true);
118
-                    if (isset($args['state']) && ($args['state']=='on')) {
118
+                    if (isset($args['state']) && ($args['state'] == 'on')) {
119 119
                         $resultAction = $action;
120 120
                         break;
121 121
                     }
122 122
                 }
123 123
             }
124 124
 
125
-            if ($request->get('cmd')==2) {
125
+            if ($request->get('cmd') == 2) {
126 126
                 // turn on, only by pi
127 127
 
128 128
                 $changeSet = ['state'=>'on'];
129 129
                 /** @var Action $action */
130 130
                 foreach ($actions as $action) {
131 131
                     $args = json_decode($action->getArguments(), true);
132
-                    if (isset($args['state']) && ($args['state']=='on')) {
132
+                    if (isset($args['state']) && ($args['state'] == 'on')) {
133 133
                         $resultAction = $action;
134 134
                         break;
135 135
                     }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             }
142 142
 
143 143
             if (($changeSet['state'] == 'on') && !isset($changeSet['percent'])) {
144
-                $changeSet['percent'] = 100;  // ? I don't really know if they restore their states
144
+                $changeSet['percent'] = 100; // ? I don't really know if they restore their states
145 145
             }
146 146
 
147 147
             if (!$resultAction) {
Please login to merge, or discard this patch.