Skip to content

Commit

Permalink
Capture light levels into respective models (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
PonchoPowers committed May 9, 2022
1 parent f8fead4 commit c1e1d11
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
10 changes: 3 additions & 7 deletions src/HueApi/BaseHueApi.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using HueApi.Models;
using HueApi.Models.Requests;
using HueApi.Models.Responses;
using System;
using System.Collections.Generic;
using System.Linq;
using HueApi.Models.Sensors;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace HueApi
{
Expand Down Expand Up @@ -50,8 +46,8 @@ public abstract class BaseHueApi


#region Light
public Task<HueResponse<Light>> GetLightsAsync() => HueGetRequestAsync<Light>(LightUrl);
public Task<HueResponse<Light>> GetLightAsync(Guid id) => HueGetRequestAsync<Light>(ResourceIdUrl(LightUrl, id));
public Task<HueResponse<Models.Light>> GetLightsAsync() => HueGetRequestAsync<Models.Light>(LightUrl);
public Task<HueResponse<Models.Light>> GetLightAsync(Guid id) => HueGetRequestAsync<Models.Light>(ResourceIdUrl(LightUrl, id));
public Task<HuePutResponse> UpdateLightAsync(Guid id, UpdateLight data) => HuePutRequestAsync(ResourceIdUrl(LightUrl, id), data);
#endregion

Expand Down
14 changes: 0 additions & 14 deletions src/HueApi/Models/LightLevel.cs

This file was deleted.

25 changes: 25 additions & 0 deletions src/HueApi/Models/Sensors/LightLevel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Text.Json.Serialization;

namespace HueApi.Models.Sensors
{
public class LightLevel : HueResource
{
[JsonPropertyName("enabled")]
public bool Enabled { get; set; } = default!;

[JsonPropertyName("light")]
public Light Light { get; set; } = default!;

[JsonPropertyName("owner")]
public ResourceIdentifier? Owner { get; set; }
}

public class Light
{
[JsonPropertyName("light_level")]
public int LightLevel { get; set; } = default!;

[JsonPropertyName("light_level_valid")]
public bool LightLevelValid { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace HueApi.Models
namespace HueApi.Models.Sensors
{
public class Motion : HueResource
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace HueApi.Models
namespace HueApi.Models.Sensors
{
public class Temperature : HueResource
{
Expand Down

0 comments on commit c1e1d11

Please sign in to comment.