You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'ToBooleanObservable' will now treat all states other than IsOn as false. This means observables will emit even if an entity is removed, unavailable, or unknown. (#234)
* 'ToBooleanObservable' will now treat all states other than `IsOn` as false. This means observables will emit even if an entity is removed, unavailable, or unknown.
* Fixed unit tests.
Copy file name to clipboardExpand all lines: src/CodeCasa.NetDaemon.Extensions.Observables/EntityExtensions.ToBooleanObservable.cs
+22-38Lines changed: 22 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -7,52 +7,46 @@ public static partial class EntityExtensions
7
7
{
8
8
/// <summary>
9
9
/// <para>
10
-
/// Returns a boolean observable that emits true when the entity opens and emits false when the entity closes.
11
-
/// The observable is distinct until changed. Other state changes are ignored.
10
+
/// Returns a boolean observable that emits <see langword="true"/> when the entity opens
11
+
/// and emits <see langword="false"/> when the entity closes or changes to any other state.
12
+
/// The observable is distinct until changed.
12
13
/// </para>
13
14
/// <para>
14
-
/// State changes other than open or closed (on or off on the entity) are ignored. This also includes a null entity state. This is typically received when an entity is removed. This will not be emitted in the observable.
15
+
/// Any state other than "on" (such as off, unknown, unavailable, or a null state when
16
+
/// the entity is removed) is treated as closed and will emit <see langword="false"/>.
/// Returns a boolean observable that emits true when the entity turns on and emits false when the entity turns off.
22
-
/// The observable is distinct until changed. Other state changes are ignored.
23
+
/// Returns a boolean observable that emits <see langword="true"/> when the entity turns on
24
+
/// and emits <see langword="false"/> when the entity turns off or changes to any other state.
25
+
/// The observable is distinct until changed.
23
26
/// </para>
24
27
/// <para>
25
-
/// State changes other than on or off are ignored. This also includes a null entity state. This is typically received when an entity is removed. This will not be emitted in the observable.
28
+
/// Any state other than "on" (such as off, unknown, unavailable, or a null state when
29
+
/// the entity is removed) is treated as off and will emit <see langword="false"/>.
/// Returns a boolean observable that emits true when the entity turns on and emits false when the entity turns off.
33
-
/// The observable is distinct until changed. Other state changes are ignored.
36
+
/// Returns a boolean observable that emits true when the entity turns on and emits false when the entity changes to any other state (including off, unknown, unavailable or null).
37
+
/// The observable is distinct until changed.
34
38
/// </para>
35
39
/// <para>
36
-
/// State changes other than on or off are ignored. This also includes a null entity state. This is typically received when an entity is removed. This will not be emitted in the observable.
40
+
/// A null entity state, which typically indicates the entity has been removed, will emit false.
@@ -97,31 +91,21 @@ public static IObservable<bool>
97
91
98
92
/// <summary>
99
93
/// <para>
100
-
/// Returns a boolean observable that emits true when the entity turns on and emits false when the entity turns off.
94
+
/// Returns a boolean observable that emits true when the entity turns on and emits false when the entity changes to any other state (including off, unknown, unavailable or null).
101
95
/// Predicate will be evaluated on all state changes, including attribute changes.
102
-
/// The observable only emits changes and will not emit the initial state.
103
-
/// The observable is distinct until changed. Other state changes are ignored.
104
96
/// </para>
105
97
/// <para>
106
-
/// State changes other than on or off are ignored. This also includes a null entity state. This is typically received when an entity is removed. This will not be emitted in the observable.
98
+
/// The observable only emits subsequent changes and will not emit the initial state.
99
+
/// A null entity state, which typically indicates the entity has been removed, will emit false.
Copy file name to clipboardExpand all lines: tests/CodeCasa.NetDaemon.Extensions.Observables.Tests/EntityExtensions.ToBooleanObservable.Entity.Tests.cs
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -103,7 +103,7 @@ public void ToBooleanObservable_Distinct()
0 commit comments