1111
This commit is contained in:
@@ -22,6 +22,76 @@ public sealed class HomeAssistantState
|
||||
if (!Attributes.TryGetProperty(name, out var value)) return null;
|
||||
return value.ValueKind == JsonValueKind.String ? value.GetString() : value.ToString();
|
||||
}
|
||||
|
||||
public double? GetDoubleAttribute(string name)
|
||||
{
|
||||
if (!Attributes.TryGetProperty(name, out var value)) return null;
|
||||
if (value.ValueKind == JsonValueKind.Number && value.TryGetDouble(out var d)) return d;
|
||||
if (double.TryParse(value.ToString(), out var parsed)) return parsed;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class HomeAssistantDeviceRegistryItem
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[JsonPropertyName("name_by_user")]
|
||||
public string? NameByUser { get; set; }
|
||||
|
||||
[JsonPropertyName("model")]
|
||||
public string? Model { get; set; }
|
||||
|
||||
[JsonPropertyName("manufacturer")]
|
||||
public string? Manufacturer { get; set; }
|
||||
|
||||
[JsonPropertyName("area_id")]
|
||||
public string? AreaId { get; set; }
|
||||
|
||||
[JsonPropertyName("disabled_by")]
|
||||
public string? DisabledBy { get; set; }
|
||||
}
|
||||
|
||||
public sealed class HomeAssistantEntityRegistryItem
|
||||
{
|
||||
[JsonPropertyName("entity_id")]
|
||||
public string EntityId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("device_id")]
|
||||
public string? DeviceId { get; set; }
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[JsonPropertyName("original_name")]
|
||||
public string? OriginalName { get; set; }
|
||||
|
||||
[JsonPropertyName("platform")]
|
||||
public string? Platform { get; set; }
|
||||
|
||||
[JsonPropertyName("disabled_by")]
|
||||
public string? DisabledBy { get; set; }
|
||||
}
|
||||
|
||||
public sealed class HomeAssistantAreaRegistryItem
|
||||
{
|
||||
[JsonPropertyName("area_id")]
|
||||
public string AreaId { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public sealed class HomeAssistantRegistries
|
||||
{
|
||||
public List<HomeAssistantDeviceRegistryItem> Devices { get; set; } = [];
|
||||
public List<HomeAssistantEntityRegistryItem> Entities { get; set; } = [];
|
||||
public List<HomeAssistantAreaRegistryItem> Areas { get; set; } = [];
|
||||
public DateTimeOffset CachedAt { get; set; } = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
public sealed class HomeAssistantActionResult
|
||||
|
||||
Reference in New Issue
Block a user