private void LoadAllDevices() { GatewayController gwc = new GatewayController(gatewayConnection.Client); comboBox2.Enabled = false; comboBox2.BeginUpdate(); comboBox2.Items.Clear(); // Read the devices foreach (long deviceID in gwc.GetDevices()) { DeviceController dcl = new DeviceController(deviceID, gatewayConnection.Client); TradFriDevice device = dcl.GetTradFriDevice(); comboBox2.Items.Add(device); } // Read the groups foreach (long groupID in gwc.GetGroups()) { GroupController gcl = new GroupController(groupID, gatewayConnection.Client); TradFriGroup currentGroup = gcl.GetTradFriGroup(); comboBox2.Items.Add(currentGroup); } comboBox2.SelectedIndex = -1; comboBox2.EndUpdate(); comboBox2.Enabled = true; }
/// <summary> /// Acquires TradFriGroup object /// </summary> /// <param name="refresh">If set to true, than it will ignore existing cached value and ask the gateway for the object</param> /// <returns></returns> public TradFriGroup GetTradFriGroup(bool refresh = false) { if (!refresh && group != null) { return(group); } group = JsonConvert.DeserializeObject <TradFriGroup>(Get().PayloadString); return(group); }
private void btnTest1_Click(object sender, EventArgs e) { GatewayController gwc = new GatewayController(gatewayConnection.Client); foreach (long groupID in gwc.GetGroups()) { GroupController gc = new GroupController(groupID, gatewayConnection.Client); TradFriGroup currentGroup = gc.GetTradFriGroup(); if (currentGroup.Name.Contains("Test")) { gc.TurnOff(); } } }
//set dimmer to specific group example private List <TradFriGroup> AcquireGroups() { GatewayController gwc = new GatewayController(_gatewayConnection.Client); List <TradFriGroup> groups = new List <TradFriGroup>(); foreach (long groupID in gwc.GetGroups()) { GroupController gc = new GroupController(groupID, _gatewayConnection.Client); if (groupID == 143700) { gc.SetDimmer(230); } //not neccessary for controlling the group, it is used when we need the group properties TradFriGroup group = gc.GetTradFriGroup(); groups.Add(group); } return(groups); }
// Set mood example private void SetMood() { GatewayController gwc = new GatewayController(_gatewayConnection.Client); List <TradFriMood> moods = gwc.GetMoods(); List <TradFriGroup> groups = new List <TradFriGroup>(); foreach (long groupID in gwc.GetGroups()) { GroupController gc = new GroupController(groupID, _gatewayConnection.Client); //not neccessary for controlling the group, it is used when we need the group properties TradFriGroup group = gc.GetTradFriGroup(); //check if group name property is 'TestGroup' if (group.Name.Equals("TestGroup")) { List <TradFriMood> groupMoods = moods.Where(x => x.GroupID.Equals(groupID)).ToList(); //gc.SetDimmer(230); //set mood Response response = gc.SetMood(groupMoods[2]); } groups.Add(group); } }
public TradFriGroup GetTradFriGroup() { group = JsonConvert.DeserializeObject <TradFriGroup>(Get().PayloadString); return(group); }