@@ -49,14 +49,38 @@ function getPowerStatus($Id){
49
49
50
50
$ psid = $ this ->getDetails ("15001/ $ Id " );
51
51
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
+ }
53
65
54
66
}
55
67
56
68
function poweroff ($ path ){
57
69
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 )){
60
84
$ this ->action ("put " , $ payload , "15001/ $ path " );
61
85
62
86
if ($ this ->getPowerStatus ($ path ) == 0 )
@@ -72,8 +96,21 @@ function poweroff($path){
72
96
73
97
function poweron ($ path ){
74
98
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
+
77
114
$ this ->action ("put " , $ payload , "15001/ $ path " );
78
115
79
116
if ($ this ->getPowerStatus ($ path ) == 1 )
@@ -108,13 +145,31 @@ function setDimmer($path, $dimmer, $transition = NULL){
108
145
109
146
}
110
147
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
+
111
164
function statusremotecontrol (){
112
165
113
166
$ Ids = $ this ->getIds ();
167
+ sort ($ Ids , SORT_NUMERIC );
168
+
114
169
foreach ($ Ids as $ device ){
115
170
$ details = $ this ->getDetails ("15001/ $ device " );
116
171
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 ] );
118
173
}
119
174
}
120
175
@@ -140,7 +195,7 @@ function statuslamps(){
140
195
//Set Dimmer to the INT Value in %
141
196
$ details [LIGHT ]['0 ' ][DIMMER ] = round ($ details [LIGHT ]['0 ' ][DIMMER ] * 100 / 255 );
142
197
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 ] );
144
199
145
200
//Clean up
146
201
unset($ colorhex , $ colorx , $ colory , $ colortemp , $ transition );
0 commit comments