Skip to content

Commit 1ff3382

Browse files
authored
merge issue40-unsupported to master, solve #40
fix unsupported schedules, solve #40
2 parents 848c761 + 509ec89 commit 1ff3382

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

src/Lights.vala

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,15 @@ public class Lights : ListBox {
198198
}
199199
}
200200

201-
// append found lights in json-response to internal list of lights
202-
Light found_light = new Light(
203-
light_id, name, hue, sat, bri, lswitch, reachable, bridge,
204-
this
205-
);
206-
lights.append(found_light);
201+
// append found lights in json-response to internal list of
202+
// lights
203+
if (light_id != 0) {
204+
Light found_light = new Light(
205+
light_id, name, hue, sat, bri, lswitch, reachable, bridge,
206+
this
207+
);
208+
lights.append(found_light);
209+
}
207210
}
208211
}
209212
catch (Error e) {
@@ -283,12 +286,20 @@ public class Lights : ListBox {
283286
foreach (string command in command_obj.get_members()) {
284287
if (command == "address") {
285288
address = command_obj.get_string_member(command);
289+
290+
// test
291+
//address = "";
292+
286293
debug("[Lights.schedules_received] address = '"
287294
+ address + "'");
288295
parts_of_address = address.split("/");
289-
if (parts_of_address[3] == "lights") {
290-
light_id = int.parse(parts_of_address[4]);
291-
}
296+
297+
int parts = parts_of_address.length;
298+
if (parts > 0) {
299+
if (parts_of_address[3] == "lights") {
300+
light_id = int.parse(parts_of_address[4]);
301+
}
302+
}
292303
debug("[Lights.schedules_received] light_id = '"
293304
+ light_id.to_string() + "'");
294305
}
@@ -312,11 +323,13 @@ public class Lights : ListBox {
312323
}
313324
}
314325

315-
// insert found schedules to temporary schedules list
316-
Schedule s = new Schedule(schedule_id, name, light_id, time,
317-
bri, sat, status, app, bridge
318-
);
319-
schedule_list.append(s);
326+
// insert found schedules of lights to temporary schedules list
327+
if (light_id != 0) {
328+
Schedule s = new Schedule(schedule_id, name, light_id, time,
329+
bri, sat, status, app, bridge
330+
);
331+
schedule_list.append(s);
332+
}
320333
}
321334
}
322335
catch (Error e) {

0 commit comments

Comments
 (0)