File tree 5 files changed +26
-4
lines changed
custom_components/solis_cloud_control 5 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ def __init__(
34
34
35
35
@property
36
36
def available (self ) -> bool :
37
- if not super (). available :
37
+ if not self . coordinator . last_update_success :
38
38
return False
39
39
40
40
for cid in self .cids :
Original file line number Diff line number Diff line change @@ -346,9 +346,7 @@ def create_hybrid_inverter(
346
346
def all_cids (self ) -> list [int ]:
347
347
cids : list [int ] = []
348
348
349
- if self .on_off :
350
- cids .append (self .on_off .on_cid )
351
- cids .append (self .on_off .off_cid )
349
+ # CIDs for on-off are write-only, so they are not included
352
350
if self .storage_mode :
353
351
cids .append (self .storage_mode .cid )
354
352
if self .charge_discharge_settings :
Original file line number Diff line number Diff line change @@ -110,6 +110,13 @@ def __init__(
110
110
self ._attr_is_on = True
111
111
self ._attr_assumed_state = True
112
112
113
+ @property
114
+ def available (self ) -> bool :
115
+ if not self .coordinator .last_update_success :
116
+ return False
117
+ # CIDs for on-off are write only, skip availability check based on coordinator data
118
+ return True
119
+
113
120
async def async_turn_on (self , ** kwargs : dict [str , any ]) -> None : # noqa: ARG002
114
121
_LOGGER .info ("Turning on inverter" )
115
122
await self .coordinator .control_no_check (self .on_off .on_cid , self .on_off .on_value )
Original file line number Diff line number Diff line change @@ -45,3 +45,13 @@ def test_available_multiple_cids(
45
45
)
46
46
mock_coordinator .data = coordinator_data
47
47
assert entity .available == expected_available
48
+
49
+ def test_available_when_coordinator_unavailable (self , mock_coordinator ):
50
+ entity = SolisCloudControlEntity (
51
+ coordinator = mock_coordinator ,
52
+ entity_description = EntityDescription (key = "any_key" , name = "any name" ),
53
+ cids = 1 ,
54
+ )
55
+
56
+ entity .coordinator .last_update_success = False
57
+ assert entity .available is False
Original file line number Diff line number Diff line change @@ -27,6 +27,13 @@ def test_init(self, on_off_switch):
27
27
assert on_off_switch .is_on is True
28
28
assert on_off_switch .assumed_state is True
29
29
30
+ def test_available (self , on_off_switch ):
31
+ assert on_off_switch .available is True
32
+
33
+ def test_available_when_coordinator_unavailable (self , on_off_switch ):
34
+ on_off_switch .coordinator .last_update_success = False
35
+ assert on_off_switch .available is False
36
+
30
37
async def test_turn_on (self , on_off_switch ):
31
38
await on_off_switch .async_turn_on ()
32
39
on_off_switch .coordinator .control_no_check .assert_awaited_once_with (
You can’t perform that action at this time.
0 commit comments