@@ -49,14 +49,38 @@ function getPowerStatus($Id){
4949
5050 $ psid = $ this ->getDetails ("15001/ $ Id " );
5151
52- return $ psid ['3311 ' ]['0 ' ][ONOFF ];
52+ switch ($ psid [TYPE ]) {
53+ case TYPE_LIGHT :
54+ return $ psid ['3311 ' ]['0 ' ][ONOFF ];
55+ break ;
56+
57+ case TYPE_CONTROL_OUTLET :
58+ return $ psid ['3312 ' ]['0 ' ][ONOFF ];
59+ break ;
60+
61+ default :
62+ return NULL ;
63+ break ;
64+ }
5365
5466 }
5567
5668 function poweroff ($ path ){
5769
58- if ($ this ->getTypeId ($ path ) == TYPE_LIGHT ){
59- $ payload = '{ "3311": [{ "5850": 0 }] } ' ;
70+ switch ($ this ->getTypeId ($ path )){
71+ case TYPE_LIGHT :
72+ $ payload = '{ "3311": [{ "5850": 0 }] } ' ;
73+ break ;
74+
75+ case TYPE_CONTROL_OUTLET :
76+ $ payload = '{ "3312": [{ "5850": 0 }] } ' ;
77+ break ;
78+
79+ default :
80+ $ payload = NULL ;
81+ }
82+
83+ if (!is_null ($ payload )){
6084 $ this ->action ("put " , $ payload , "15001/ $ path " );
6185
6286 if ($ this ->getPowerStatus ($ path ) == 0 )
@@ -72,8 +96,21 @@ function poweroff($path){
7296
7397 function poweron ($ path ){
7498
75- if ($ this ->getTypeId ($ path ) == TYPE_LIGHT ){
76- $ payload = '{ "3311": [{ "5850": 1 }] } ' ;
99+ switch ($ this ->getTypeId ($ path )){
100+ case TYPE_LIGHT :
101+ $ payload = '{ "3311": [{ "5850": 1 }] } ' ;
102+ break ;
103+
104+ case TYPE_CONTROL_OUTLET :
105+ $ payload = '{ "3312": [{ "5850": 1 }] } ' ;
106+ break ;
107+
108+ default :
109+ $ payload = NULL ;
110+ }
111+
112+ if (!is_null ($ payload )){
113+
77114 $ this ->action ("put " , $ payload , "15001/ $ path " );
78115
79116 if ($ this ->getPowerStatus ($ path ) == 1 )
@@ -108,13 +145,31 @@ function setDimmer($path, $dimmer, $transition = NULL){
108145
109146 }
110147
148+ function statuscontroloutlet (){
149+
150+ $ Ids = $ this ->getIds ();
151+ sort ($ Ids , SORT_NUMERIC );
152+
153+ foreach ($ Ids as $ device ){
154+ $ details = $ this ->getDetails ("15001/ $ device " );
155+ if ($ details [TYPE ] == TYPE_CONTROL_OUTLET ){
156+ $ output [] = array ("id " => $ device ,"name " => $ details [NAME ], "type " => $ details ['3 ' ]['1 ' ], "firmware " => $ details ['3 ' ]['3 ' ], "lastseen " => date ('H:i:s d.m.Y ' , $ details [LAST_SEEN ]), "lastseenunix " => $ details [LAST_SEEN ], "power " => $ details ['3312 ' ]['0 ' ][ONOFF ]);
157+ }
158+ }
159+
160+ return $ output ;
161+
162+ }
163+
111164 function statusremotecontrol (){
112165
113166 $ Ids = $ this ->getIds ();
167+ sort ($ Ids , SORT_NUMERIC );
168+
114169 foreach ($ Ids as $ device ){
115170 $ details = $ this ->getDetails ("15001/ $ device " );
116171 if ($ details [TYPE ] == TYPE_REMOTE_CONTROL || $ details [TYPE ] == TYPE_MOTION_SENSOR ){
117- $ output [] = array ("id " => $ device ,"name " => $ details [NAME ], "type " => $ details ['3 ' ]['1 ' ], "battery " => $ details ['3 ' ]['9 ' ], "firmware " => $ details ['3 ' ]['3 ' ]);
172+ $ output [] = array ("id " => $ device ,"name " => $ details [NAME ], "type " => $ details ['3 ' ]['1 ' ], "battery " => $ details ['3 ' ]['9 ' ], "firmware " => $ details ['3 ' ]['3 ' ], " lastseen " => date ( ' H:i:s d.m.Y ' , $ details [ LAST_SEEN ]), " lastseenunix " => $ details [ LAST_SEEN ] );
118173 }
119174 }
120175
@@ -140,7 +195,7 @@ function statuslamps(){
140195 //Set Dimmer to the INT Value in %
141196 $ details [LIGHT ]['0 ' ][DIMMER ] = round ($ details [LIGHT ]['0 ' ][DIMMER ] * 100 / 255 );
142197
143- $ output [] = array ("id " => $ device ,"name " => $ details [NAME ], "type " => $ details ['3 ' ]['1 ' ], "power " => $ details [LIGHT ]['0 ' ][ONOFF ], "dimmer " => $ details [LIGHT ]['0 ' ][DIMMER ], "colorhex " => $ colorhex , "colorx " => $ colorx , "colory " => $ colory , "colortemp " => $ colortemp , "transition " => $ transition );
198+ $ output [] = array ("id " => $ device ,"name " => $ details [NAME ], "type " => $ details ['3 ' ]['1 ' ], "power " => $ details [LIGHT ]['0 ' ][ONOFF ], "dimmer " => $ details [LIGHT ]['0 ' ][DIMMER ], "colorhex " => $ colorhex , "colorx " => $ colorx , "colory " => $ colory , "colortemp " => $ colortemp , "transition " => $ transition, " firmware " => $ details [ ' 3 ' ][ ' 3 ' ], " lastseen " => date ( ' H:i:s d.m.Y ' , $ details [ LAST_SEEN ]), " lastseenunix " => $ details [ LAST_SEEN ] );
144199
145200 //Clean up
146201 unset($ colorhex , $ colorx , $ colory , $ colortemp , $ transition );
0 commit comments