diff --git a/src/HassModel/NetDeamon.HassModel/Entities/EntityExtensions.cs b/src/HassModel/NetDeamon.HassModel/Entities/EntityExtensions.cs index b612ae7c4..9f91bf18d 100644 --- a/src/HassModel/NetDeamon.HassModel/Entities/EntityExtensions.cs +++ b/src/HassModel/NetDeamon.HassModel/Entities/EntityExtensions.cs @@ -10,28 +10,28 @@ public static class EntityExtensions /// /// The state to check /// true if the state equals "on", otherwise false - public static bool IsOn(this EntityState? entityState) => string.Equals(entityState?.State, "on", StringComparison.OrdinalIgnoreCase); + public static bool IsOn([NotNullWhen(true)] this EntityState? entityState) => string.Equals(entityState?.State, "on", StringComparison.OrdinalIgnoreCase); /// /// Checks if an EntityState has the state "off" /// /// The state to check /// true if the state equals "off", otherwise false - public static bool IsOff(this EntityState? entityState) => string.Equals(entityState?.State, "off", StringComparison.OrdinalIgnoreCase); + public static bool IsOff([NotNullWhen(true)] this EntityState? entityState) => string.Equals(entityState?.State, "off", StringComparison.OrdinalIgnoreCase); /// /// Checks if an Entity has the state "on" /// /// The state to check /// true if the state equals "on", otherwise false - public static bool IsOn(this Entity? entity) => entity?.EntityState?.IsOn() ?? false; + public static bool IsOn([NotNullWhen(true)] this Entity? entity) => entity?.EntityState?.IsOn() ?? false; /// /// Checks if an Entity has the state "off" /// /// The state to check /// true if the state equals "off", otherwise false - public static bool IsOff(this Entity? entity) => entity?.EntityState?.IsOff() ?? false; + public static bool IsOff([NotNullWhen(true)] this Entity? entity) => entity?.EntityState?.IsOff() ?? false; /// Gets a NumericEntity from a given Entity public static NumericEntity AsNumeric(this Entity entity) => new(entity); @@ -56,4 +56,4 @@ public static NumericEntity WithAttributesAs(this Nume internal static IObservable StateChangesOnly(this IObservable changes) where T : StateChange => changes.Where(c => c.New?.State != c.Old?.State); -} \ No newline at end of file +}