Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture light levels into respective models #281

Merged
merged 1 commit into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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