@@ -13,15 +13,15 @@ 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'], |
|
| 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 |
||
| 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(); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | /** @var Action $action */ |
| 74 | 74 | foreach ($actions as $action) { |
| 75 | - if ($action->getArguments()=='{"state":"on"}') { |
|
| 75 | + if ($action->getArguments() == '{"state":"on"}') { |
|
| 76 | 76 | $resultAction = $action; |
| 77 | 77 | break; |
| 78 | 78 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $changeSet = ['state'=>'off']; |
| 83 | 83 | /** @var Action $action */ |
| 84 | 84 | foreach ($actions as $action) { |
| 85 | - if ($action->getArguments()=='{"state":"off"}') { |
|
| 85 | + if ($action->getArguments() == '{"state":"off"}') { |
|
| 86 | 86 | $resultAction = $action; |
| 87 | 87 | break; |
| 88 | 88 | } |
@@ -90,41 +90,41 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if ($request->get('cmd')==0) { |
|
| 93 | + if ($request->get('cmd') == 0) { |
|
| 94 | 94 | // turn off, only by pi |
| 95 | 95 | |
| 96 | 96 | $changeSet = ['state'=>'off']; |
| 97 | 97 | /** @var Action $action */ |
| 98 | 98 | foreach ($actions as $action) { |
| 99 | - if ($action->getArguments()=='{"state":"off"}') { |
|
| 99 | + if ($action->getArguments() == '{"state":"off"}') { |
|
| 100 | 100 | $resultAction = $action; |
| 101 | 101 | break; |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if ($request->get('cmd')==6) { |
|
| 106 | + if ($request->get('cmd') == 6) { |
|
| 107 | 107 | // turn off, only by pi |
| 108 | 108 | |
| 109 | - $percent = round((($request->get('d0') - 34)/123) * 100); |
|
| 109 | + $percent = round((($request->get('d0') - 34)/123)*100); |
|
| 110 | 110 | |
| 111 | - $changeSet = ['state'=>'on','percent'=>$percent]; |
|
| 111 | + $changeSet = ['state'=>'on', 'percent'=>$percent]; |
|
| 112 | 112 | /** @var Action $action */ |
| 113 | 113 | foreach ($actions as $action) { |
| 114 | - if ($action->getArguments()=='{"state":"on"}') { |
|
| 114 | + if ($action->getArguments() == '{"state":"on"}') { |
|
| 115 | 115 | $resultAction = $action; |
| 116 | 116 | break; |
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ($request->get('cmd')==2) { |
|
| 121 | + if ($request->get('cmd') == 2) { |
|
| 122 | 122 | // turn on, only by pi |
| 123 | 123 | |
| 124 | 124 | $changeSet = ['state'=>'on']; |
| 125 | 125 | /** @var Action $action */ |
| 126 | 126 | foreach ($actions as $action) { |
| 127 | - if ($action->getArguments()=='{"state":"on"}') { |
|
| 127 | + if ($action->getArguments() == '{"state":"on"}') { |
|
| 128 | 128 | $resultAction = $action; |
| 129 | 129 | break; |
| 130 | 130 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | if (($changeSet['state'] == 'on') && !isset($changeSet['percent'])) { |
| 139 | - $changeSet['percent'] = 100; // ? I don't really know if they restore their states |
|
| 139 | + $changeSet['percent'] = 100; // ? I don't really know if they restore their states |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | if (!$resultAction) { |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | continue; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if (time()-$args['last'] > $args['every']) { |
|
| 36 | + if (time() - $args['last'] > $args['every']) { |
|
| 37 | 37 | $output->writeln('Running '.$cronAction->getExecutor().' for "'. |
| 38 | 38 | $cronAction->getDevice()->getName().'" device'); |
| 39 | 39 | $this-> |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | if (!$virtual) { |
| 48 | 48 | list($executor, $method) = explode(':', $action->getExecutor()); |
| 49 | 49 | |
| 50 | - $executor = 'AppBundle\Action\Executor\\' . ucfirst($executor); |
|
| 50 | + $executor = 'AppBundle\Action\Executor\\'.ucfirst($executor); |
|
| 51 | 51 | |
| 52 | 52 | if (!class_exists($executor)) { |
| 53 | - throw new \Exception('Unknown executor: ' . $executor); |
|
| 53 | + throw new \Exception('Unknown executor: '.$executor); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** @var ExecutorInterface $executor */ |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | if (!method_exists($executor, $method)) { |
| 66 | - throw new \Exception('Unknown executor method: ' . $action->getExecutor().'()'); |
|
| 66 | + throw new \Exception('Unknown executor method: '.$action->getExecutor().'()'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $result = $executor->{$method}($action); |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | $variable = false; |
| 18 | 18 | |
| 19 | 19 | foreach ($params as $param) { |
| 20 | - list($p,$v) = explode(':', $param); |
|
| 21 | - if ($p=='variable') { |
|
| 20 | + list($p, $v) = explode(':', $param); |
|
| 21 | + if ($p == 'variable') { |
|
| 22 | 22 | $variable = $this->getDoctrine()->getManager()->getRepository('AppBundle:Variable')->findOneBy(['name'=>$v]); |
| 23 | 23 | break; |
| 24 | 24 | } |