@@ -13,13 +13,13 @@ discard block |
||
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'], |
|
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 | 23 | ]; |
24 | 24 | |
25 | 25 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $changeSet = []; |
59 | 59 | |
60 | 60 | |
61 | - if ($request->get('cmd')==4) { |
|
61 | + if ($request->get('cmd') == 4) { |
|
62 | 62 | // reverse state, only by human |
63 | 63 | |
64 | 64 | $oldState = $device->getState(); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | /** @var Action $action */ |
72 | 72 | foreach ($actions as $action) { |
73 | - if ($action->getArguments()=='{"state":"on"}') { |
|
73 | + if ($action->getArguments() == '{"state":"on"}') { |
|
74 | 74 | $resultAction = $action; |
75 | 75 | break; |
76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $changeSet = ['state'=>'off']; |
81 | 81 | /** @var Action $action */ |
82 | 82 | foreach ($actions as $action) { |
83 | - if ($action->getArguments()=='{"state":"off"}') { |
|
83 | + if ($action->getArguments() == '{"state":"off"}') { |
|
84 | 84 | $resultAction = $action; |
85 | 85 | break; |
86 | 86 | } |
@@ -88,41 +88,41 @@ discard block |
||
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - if ($request->get('cmd')==0) { |
|
91 | + if ($request->get('cmd') == 0) { |
|
92 | 92 | // turn off, only by pi |
93 | 93 | |
94 | 94 | $changeSet = ['state'=>'off']; |
95 | 95 | /** @var Action $action */ |
96 | 96 | foreach ($actions as $action) { |
97 | - if ($action->getArguments()=='{"state":"off"}') { |
|
97 | + if ($action->getArguments() == '{"state":"off"}') { |
|
98 | 98 | $resultAction = $action; |
99 | 99 | break; |
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - if ($request->get('cmd')==6) { |
|
104 | + if ($request->get('cmd') == 6) { |
|
105 | 105 | // turn off, only by pi |
106 | 106 | |
107 | - $percent = round((($request->get('d0') - 34)/123) * 100); |
|
107 | + $percent = round((($request->get('d0') - 34)/123)*100); |
|
108 | 108 | |
109 | - $changeSet = ['state'=>'on','percent'=>$percent]; |
|
109 | + $changeSet = ['state'=>'on', 'percent'=>$percent]; |
|
110 | 110 | /** @var Action $action */ |
111 | 111 | foreach ($actions as $action) { |
112 | - if ($action->getArguments()=='{"state":"on"}') { |
|
112 | + if ($action->getArguments() == '{"state":"on"}') { |
|
113 | 113 | $resultAction = $action; |
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | - if ($request->get('cmd')==2) { |
|
119 | + if ($request->get('cmd') == 2) { |
|
120 | 120 | // turn on, only by pi |
121 | 121 | |
122 | 122 | $changeSet = ['state'=>'on']; |
123 | 123 | /** @var Action $action */ |
124 | 124 | foreach ($actions as $action) { |
125 | - if ($action->getArguments()=='{"state":"on"}') { |
|
125 | + if ($action->getArguments() == '{"state":"on"}') { |
|
126 | 126 | $resultAction = $action; |
127 | 127 | break; |
128 | 128 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | if (($changeSet['state'] == 'on') && !isset($changeSet['percent'])) { |
137 | - $changeSet['percent'] = 100; // ? I don't really know if they restore their states |
|
137 | + $changeSet['percent'] = 100; // ? I don't really know if they restore their states |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | if (!$resultAction) { |