Skip to content

Commit

Permalink
allow hue edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico Suter committed Nov 22, 2023
1 parent fc55fc1 commit 878904c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/HomeBlaze.Philips.Hue/HueBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HomeBlaze.Philips.Hue
{
[DisplayName("Philips Hue Bridge")]
[Description("The brains of the Philips Hue smart lighting system, the Hue Bridge allows you to connect and control up to 50 lights and accessories.")]
[ThingSetup(typeof(HueBridgeSetup))]
[ThingSetup(typeof(HueBridgeSetup), CanEdit = true)]
public class HueBridge : PollingThing, IIconProvider, ILastUpdatedProvider,
IConnectedThing, IHubDevice, IPowerConsumptionSensor
{
Expand Down
24 changes: 24 additions & 0 deletions src/HomeBlaze.Philips.Hue/HueBridgeSetup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,28 @@ else

return null;
}

public override async Task<bool> UpdateEditedThingAsync(CancellationToken cancellationToken)
{
try
{
if (EditedThing != null &&
_selectedBridge is LocatedBridge selectedBridge)
{
var client = new LocalHueClient(selectedBridge.IpAddress);
var appKey = await client.RegisterAsync("HomeBlaze", "Local");

EditedThing.AppKey = appKey;
EditedThing.BridgeId = selectedBridge.BridgeId;

return true;
}
}
catch (Exception e)
{
await DialogService.ShowMessageBox("Failed to add Philips Hue Bridge", e.Message);
}

return false;
}
}
2 changes: 1 addition & 1 deletion src/HomeBlaze.Services/ReflectionUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class StatePropertyInfo
}
catch (Exception e)
{
logger.LogWarning($"Getter of property threw an exception.", e);
logger.LogWarning(e, $"Getter of property threw an exception.");
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void StartHeartbeat()
}
catch (Exception ex)
{
logger.LogError("Error sending heartbeat", ex);
logger.LogError(ex, "Error sending heartbeat");
}
await Task.Delay(_heartbeatInterval);
if (DateTime.Now - _lastReceived > _heartbeatTimeout)
Expand Down

0 comments on commit 878904c

Please sign in to comment.