34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Evergreen.Health.Application.Health.Integrations.HomeAssistant;
|
|
|
|
public sealed class HomeAssistantState
|
|
{
|
|
[JsonPropertyName("entity_id")]
|
|
public string EntityId { get; set; } = string.Empty;
|
|
|
|
[JsonPropertyName("state")]
|
|
public string State { get; set; } = string.Empty;
|
|
|
|
[JsonPropertyName("attributes")]
|
|
public JsonElement Attributes { get; set; }
|
|
|
|
[JsonPropertyName("last_updated")]
|
|
public DateTimeOffset? LastUpdated { get; set; }
|
|
|
|
public string? GetStringAttribute(string name)
|
|
{
|
|
if (!Attributes.TryGetProperty(name, out var value)) return null;
|
|
return value.ValueKind == JsonValueKind.String ? value.GetString() : value.ToString();
|
|
}
|
|
}
|
|
|
|
public sealed class HomeAssistantActionResult
|
|
{
|
|
public string Name { get; set; } = string.Empty;
|
|
public string EntityId { get; set; } = string.Empty;
|
|
public string Status { get; set; } = string.Empty;
|
|
public string Message { get; set; } = string.Empty;
|
|
}
|