Added group support
This commit is contained in:
@@ -36,6 +36,7 @@ namespace HueUWP.Lights
|
||||
foreach (Light g in _groups)
|
||||
{
|
||||
await g.Update();
|
||||
await Task.Delay(TimeSpan.FromMilliseconds(100));
|
||||
}
|
||||
|
||||
return "success";
|
||||
|
||||
@@ -180,21 +180,21 @@ namespace HueUWP
|
||||
|
||||
public static async Task<String> SetGroup(int groupid, string json)
|
||||
{
|
||||
var response = await Put($"{(String)App.LOCAL_SETTINGS.Values["id"]}/groups/{groupid}", json);
|
||||
var response = await Put($"{(String)App.LOCAL_SETTINGS.Values["id"]}/groups/{groupid}/action", json);
|
||||
return response;
|
||||
}
|
||||
|
||||
public static async Task<String> SetGroup(int groupid, bool state)
|
||||
{
|
||||
string json = $"{{\"on\": { ((state) ? "true" : "false") }}}";
|
||||
var response = await Put($"{(String)App.LOCAL_SETTINGS.Values["id"]}/groups/{groupid}", json);
|
||||
var response = await Put($"{(String)App.LOCAL_SETTINGS.Values["id"]}/groups/{groupid}/action", json);
|
||||
return response;
|
||||
}
|
||||
|
||||
public static async Task<String> SetGroup(int groupid, int hue, int saturation, int brightness, bool instant = false)
|
||||
{
|
||||
string json = $"{{\"hue\": {(hue)},\"bri\": {brightness},\"sat\": {saturation} {(instant ? ",\"transitiontime\":0" : "")}}}";
|
||||
var response = await Put($"{(String)App.LOCAL_SETTINGS.Values["id"]}/groups/{groupid}", json);
|
||||
var response = await Put($"{(String)App.LOCAL_SETTINGS.Values["id"]}/groups/{groupid}/action", json);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,9 +50,24 @@ namespace HueUWP.Views
|
||||
QuietReloadGroups();
|
||||
}
|
||||
|
||||
private void StartTimer()
|
||||
{
|
||||
if ((bool)App.LOCAL_SETTINGS.Values["autorefresh"])
|
||||
{
|
||||
QuietReloadGroups();
|
||||
timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
ReloadGroups();
|
||||
if (e.NavigationMode == NavigationMode.New)
|
||||
ReloadGroups();
|
||||
else
|
||||
{
|
||||
GroupsList.SelectedItems.Clear();
|
||||
StartTimer();
|
||||
}
|
||||
this.DataContext = GroupsViewModel;
|
||||
}
|
||||
|
||||
@@ -79,7 +94,7 @@ namespace HueUWP.Views
|
||||
else
|
||||
{
|
||||
FeedbackPanel.Visibility = Visibility.Collapsed;
|
||||
timer.Start();
|
||||
StartTimer();
|
||||
}
|
||||
|
||||
Loading.IsActive = false;
|
||||
|
||||
Reference in New Issue
Block a user