Skip to content

Commit 0bf8f09

Browse files
authored
disable on_self_speed for ai controller when in the off at_mode (#127)
1 parent 60006a0 commit 0bf8f09

File tree

7 files changed

+67
-60
lines changed

7 files changed

+67
-60
lines changed

custom_components/ac_infinity/core.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,15 +1021,15 @@ def __init__(
10211021
device: ACInfinityDevice,
10221022
enabled_fn: Callable[[ConfigEntry, str, str], bool],
10231023
suitable_fn: Callable[[ACInfinityEntity, ACInfinityDevice], bool],
1024-
at_type: int | None,
1024+
at_type_fn: Callable[[int], bool] | None,
10251025
data_key: str,
10261026
platform: str,
10271027
):
10281028
super().__init__(coordinator, platform, data_key)
10291029
self._device = device
10301030
self._enabled_fn = enabled_fn
10311031
self._suitable_fn = suitable_fn
1032-
self._at_type = at_type
1032+
self._at_type_fn = at_type_fn
10331033

10341034
@property
10351035
def unique_id(self) -> str:
@@ -1055,15 +1055,16 @@ def is_suitable(self) -> bool:
10551055
@property
10561056
def available(self) -> bool:
10571057
"""Returns true if the device is online and, if provided, the active mode matches the at_type filter"""
1058-
return super().available and self.ac_infinity.get_device_property(
1058+
active_at_type = self.ac_infinity.get_device_control(
10591059
self._device.controller.controller_id,
10601060
self.device_port.device_port,
1061-
DevicePropertyKey.ONLINE
1062-
) == 1 and (self._at_type is None or self.ac_infinity.get_device_control(
1061+
DeviceControlKey.AT_TYPE
1062+
)
1063+
return super().available and self.ac_infinity.get_device_property(
10631064
self._device.controller.controller_id,
10641065
self.device_port.device_port,
1065-
DeviceControlKey.AT_TYPE
1066-
) == self._at_type)
1066+
DevicePropertyKey.ONLINE
1067+
) == 1 and (self._at_type_fn is None or self._at_type_fn(active_at_type))
10671068

10681069

10691070
@dataclass(frozen=True)
@@ -1111,10 +1112,10 @@ class ACInfinityDeviceReadOnlyMixin[T](ACInfinityBaseMixin):
11111112
@dataclass(frozen=True)
11121113
class ACInfinityDeviceReadWriteMixin[T](ACInfinityDeviceReadOnlyMixin[T]):
11131114
"""Mixin for retrieving and updating values for port device level settings"""
1114-
at_type: int | None
1115-
"""List of modes that the control is applicable for"""
11161115
set_value_fn: Callable[[ACInfinityEntity, ACInfinityDevice, T], Awaitable[None]]
11171116
"""Input data object, device id, port number, and desired value."""
1117+
at_type_fn: Callable[[int], bool] | None
1118+
"""Function that accepts the active at_type and returns True if the entity should be available for that mode"""
11181119

11191120

11201121
class ACInfinityEntities(list[ACInfinityEntity]):

custom_components/ac_infinity/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"iot_class": "cloud_polling",
1111
"issue_tracker": "https://github.com/dalinicus/homeassistant-acinfinity",
1212
"requirements": [],
13-
"version": "2.0.0"
13+
"version": "2.1.1"
1414
}

custom_components/ac_infinity/number.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def __set_value_fn_dynamic_buffer_temp(
546546
suitable_fn=__suitable_fn_device_control_basic_controller,
547547
get_value_fn=__get_value_fn_device_control_default,
548548
set_value_fn=__set_value_fn_device_control_default,
549-
at_type=None
549+
at_type_fn=lambda at_type: True
550550
),
551551
ACInfinityDeviceNumberEntityDescription(
552552
key=DeviceControlKey.OFF_SPEED,
@@ -562,7 +562,7 @@ def __set_value_fn_dynamic_buffer_temp(
562562
suitable_fn=__suitable_fn_device_control_basic_controller,
563563
get_value_fn=__get_value_fn_device_control_default,
564564
set_value_fn=__set_value_fn_device_control_default,
565-
at_type=None
565+
at_type_fn=lambda at_type: True
566566
),
567567
ACInfinityDeviceNumberEntityDescription(
568568
key=DeviceControlKey.ON_SELF_SPEED,
@@ -578,7 +578,7 @@ def __set_value_fn_dynamic_buffer_temp(
578578
suitable_fn=__suitable_fn_device_control_ai_controller,
579579
get_value_fn=__get_value_fn_device_control_default,
580580
set_value_fn=__set_value_fn_device_control_default,
581-
at_type=None
581+
at_type_fn=lambda at_type: at_type != AtType.OFF
582582
),
583583
ACInfinityDeviceNumberEntityDescription(
584584
key=DeviceControlKey.TIMER_DURATION_TO_ON,
@@ -594,7 +594,7 @@ def __set_value_fn_dynamic_buffer_temp(
594594
suitable_fn=__suitable_fn_device_control_default,
595595
get_value_fn=__get_value_fn_timer_duration,
596596
set_value_fn=__set_value_fn_timer_duration,
597-
at_type=AtType.TIMER_TO_ON
597+
at_type_fn=lambda at_type: at_type == AtType.TIMER_TO_ON
598598
),
599599
ACInfinityDeviceNumberEntityDescription(
600600
key=DeviceControlKey.TIMER_DURATION_TO_OFF,
@@ -610,7 +610,7 @@ def __set_value_fn_dynamic_buffer_temp(
610610
suitable_fn=__suitable_fn_device_control_default,
611611
get_value_fn=__get_value_fn_timer_duration,
612612
set_value_fn=__set_value_fn_timer_duration,
613-
at_type=AtType.TIMER_TO_OFF
613+
at_type_fn=lambda at_type: at_type == AtType.TIMER_TO_OFF
614614
),
615615
ACInfinityDeviceNumberEntityDescription(
616616
key=DeviceControlKey.CYCLE_DURATION_ON,
@@ -626,7 +626,7 @@ def __set_value_fn_dynamic_buffer_temp(
626626
suitable_fn=__suitable_fn_device_control_default,
627627
get_value_fn=__get_value_fn_timer_duration,
628628
set_value_fn=__set_value_fn_timer_duration,
629-
at_type=AtType.CYCLE
629+
at_type_fn=lambda at_type: at_type == AtType.CYCLE
630630
),
631631
ACInfinityDeviceNumberEntityDescription(
632632
key=DeviceControlKey.CYCLE_DURATION_OFF,
@@ -642,7 +642,7 @@ def __set_value_fn_dynamic_buffer_temp(
642642
suitable_fn=__suitable_fn_device_control_default,
643643
get_value_fn=__get_value_fn_timer_duration,
644644
set_value_fn=__set_value_fn_timer_duration,
645-
at_type=AtType.CYCLE
645+
at_type_fn=lambda at_type: at_type == AtType.CYCLE
646646
),
647647
ACInfinityDeviceNumberEntityDescription(
648648
key=DeviceControlKey.VPD_LOW_TRIGGER,
@@ -658,7 +658,7 @@ def __set_value_fn_dynamic_buffer_temp(
658658
suitable_fn=__suitable_fn_device_control_default,
659659
get_value_fn=__get_value_fn_vpd_control,
660660
set_value_fn=__set_value_fn_vpd_control,
661-
at_type=AtType.VPD
661+
at_type_fn=lambda at_type: at_type == AtType.VPD
662662
),
663663
ACInfinityDeviceNumberEntityDescription(
664664
key=DeviceControlKey.VPD_HIGH_TRIGGER,
@@ -674,7 +674,7 @@ def __set_value_fn_dynamic_buffer_temp(
674674
suitable_fn=__suitable_fn_device_control_default,
675675
get_value_fn=__get_value_fn_vpd_control,
676676
set_value_fn=__set_value_fn_vpd_control,
677-
at_type=AtType.VPD
677+
at_type_fn=lambda at_type: at_type == AtType.VPD
678678
),
679679
ACInfinityDeviceNumberEntityDescription(
680680
key=DeviceControlKey.TARGET_VPD,
@@ -690,7 +690,7 @@ def __set_value_fn_dynamic_buffer_temp(
690690
suitable_fn=__suitable_fn_device_control_default,
691691
get_value_fn=__get_value_fn_vpd_control,
692692
set_value_fn=__set_value_fn_vpd_control,
693-
at_type=AtType.VPD
693+
at_type_fn=lambda at_type: at_type == AtType.VPD
694694
),
695695
ACInfinityDeviceNumberEntityDescription(
696696
key=DeviceControlKey.AUTO_HUMIDITY_LOW_TRIGGER,
@@ -706,7 +706,7 @@ def __set_value_fn_dynamic_buffer_temp(
706706
suitable_fn=__suitable_fn_device_control_default,
707707
get_value_fn=__get_value_fn_device_control_default,
708708
set_value_fn=__set_value_fn_device_control_default,
709-
at_type=AtType.AUTO
709+
at_type_fn=lambda at_type: at_type == AtType.AUTO
710710
),
711711
ACInfinityDeviceNumberEntityDescription(
712712
key=DeviceControlKey.AUTO_HUMIDITY_HIGH_TRIGGER,
@@ -722,7 +722,7 @@ def __set_value_fn_dynamic_buffer_temp(
722722
suitable_fn=__suitable_fn_device_control_default,
723723
get_value_fn=__get_value_fn_device_control_default,
724724
set_value_fn=__set_value_fn_device_control_default,
725-
at_type=AtType.AUTO
725+
at_type_fn=lambda at_type: at_type == AtType.AUTO
726726
),
727727
ACInfinityDeviceNumberEntityDescription(
728728
key=DeviceControlKey.TARGET_HUMI,
@@ -738,7 +738,7 @@ def __set_value_fn_dynamic_buffer_temp(
738738
suitable_fn=__suitable_fn_device_control_default,
739739
get_value_fn=__get_value_fn_device_control_default,
740740
set_value_fn=__set_value_fn_device_control_default,
741-
at_type=AtType.AUTO
741+
at_type_fn=lambda at_type: at_type == AtType.AUTO
742742
),
743743
ACInfinityDeviceNumberEntityDescription(
744744
key=DeviceControlKey.AUTO_TEMP_LOW_TRIGGER,
@@ -754,7 +754,7 @@ def __set_value_fn_dynamic_buffer_temp(
754754
suitable_fn=__suitable_fn_device_control_default,
755755
get_value_fn=__get_value_fn_device_control_default,
756756
set_value_fn=__set_value_fn_temp_auto_low,
757-
at_type=AtType.AUTO
757+
at_type_fn=lambda at_type: at_type == AtType.AUTO
758758
),
759759
ACInfinityDeviceNumberEntityDescription(
760760
key=DeviceControlKey.AUTO_TEMP_HIGH_TRIGGER,
@@ -770,7 +770,7 @@ def __set_value_fn_dynamic_buffer_temp(
770770
suitable_fn=__suitable_fn_device_control_default,
771771
get_value_fn=__get_value_fn_device_control_default,
772772
set_value_fn=__set_value_fn_temp_auto_high,
773-
at_type=AtType.AUTO
773+
at_type_fn=lambda at_type: at_type == AtType.AUTO
774774
),
775775
ACInfinityDeviceNumberEntityDescription(
776776
key=DeviceControlKey.TARGET_TEMP,
@@ -786,7 +786,7 @@ def __set_value_fn_dynamic_buffer_temp(
786786
suitable_fn=__suitable_fn_device_control_default,
787787
get_value_fn=__get_value_fn_device_control_default,
788788
set_value_fn=__set_value_fn_target_temp,
789-
at_type=AtType.AUTO
789+
at_type_fn=lambda at_type: at_type == AtType.AUTO
790790
),
791791
ACInfinityDeviceNumberEntityDescription(
792792
# F - native value 0-20
@@ -803,7 +803,7 @@ def __set_value_fn_dynamic_buffer_temp(
803803
suitable_fn=__suitable_fn_device_setting_temp_f,
804804
get_value_fn=__get_value_fn_dynamic_transition_temp,
805805
set_value_fn=__set_value_fn_dynamic_transition_temp,
806-
at_type=None
806+
at_type_fn=lambda at_type: True
807807
),
808808
ACInfinityDeviceNumberEntityDescription(
809809
# C - native value 0-10
@@ -820,7 +820,7 @@ def __set_value_fn_dynamic_buffer_temp(
820820
suitable_fn=__suitable_fn_device_setting_temp_c,
821821
get_value_fn=__get_value_fn_dynamic_transition_temp,
822822
set_value_fn=__set_value_fn_dynamic_transition_temp,
823-
at_type=None
823+
at_type_fn=lambda at_type: True
824824
),
825825
ACInfinityDeviceNumberEntityDescription(
826826
key=AdvancedSettingsKey.DYNAMIC_TRANSITION_HUMIDITY,
@@ -836,7 +836,7 @@ def __set_value_fn_dynamic_buffer_temp(
836836
suitable_fn=__suitable_fn_device_setting_default,
837837
get_value_fn=__get_value_fn_device_setting_default,
838838
set_value_fn=__set_value_fn_device_setting_default,
839-
at_type=None
839+
at_type_fn=lambda at_type: True
840840
),
841841
ACInfinityDeviceNumberEntityDescription(
842842
key=AdvancedSettingsKey.DYNAMIC_TRANSITION_VPD,
@@ -852,7 +852,7 @@ def __set_value_fn_dynamic_buffer_temp(
852852
suitable_fn=__suitable_fn_device_setting_default,
853853
get_value_fn=__get_value_fn_vpd_setting,
854854
set_value_fn=__set_value_fn_vpd_setting,
855-
at_type=None
855+
at_type_fn=lambda at_type: True
856856
),
857857
ACInfinityDeviceNumberEntityDescription(
858858
# F - native value 0-20
@@ -869,7 +869,7 @@ def __set_value_fn_dynamic_buffer_temp(
869869
suitable_fn=__suitable_fn_device_setting_temp_f,
870870
get_value_fn=__get_value_fn_dynamic_buffer_temp,
871871
set_value_fn=__set_value_fn_dynamic_buffer_temp,
872-
at_type=None
872+
at_type_fn=lambda at_type: True
873873
),
874874
ACInfinityDeviceNumberEntityDescription(
875875
# C - native value 0-10
@@ -886,7 +886,7 @@ def __set_value_fn_dynamic_buffer_temp(
886886
suitable_fn=__suitable_fn_device_setting_temp_c,
887887
get_value_fn=__get_value_fn_dynamic_buffer_temp,
888888
set_value_fn=__set_value_fn_dynamic_buffer_temp,
889-
at_type=None
889+
at_type_fn=lambda at_type: True
890890
),
891891
ACInfinityDeviceNumberEntityDescription(
892892
key=AdvancedSettingsKey.DYNAMIC_BUFFER_HUMIDITY,
@@ -902,7 +902,7 @@ def __set_value_fn_dynamic_buffer_temp(
902902
suitable_fn=__suitable_fn_device_setting_default,
903903
get_value_fn=__get_value_fn_device_setting_default,
904904
set_value_fn=__set_value_fn_device_setting_default,
905-
at_type=None
905+
at_type_fn=lambda at_type: True
906906
),
907907
ACInfinityDeviceNumberEntityDescription(
908908
key=AdvancedSettingsKey.DYNAMIC_BUFFER_VPD,
@@ -918,7 +918,7 @@ def __set_value_fn_dynamic_buffer_temp(
918918
suitable_fn=__suitable_fn_device_setting_default,
919919
get_value_fn=__get_value_fn_vpd_setting,
920920
set_value_fn=__set_value_fn_vpd_setting,
921-
at_type=None
921+
at_type_fn=lambda at_type: True
922922
),
923923
ACInfinityDeviceNumberEntityDescription(
924924
key=AdvancedSettingsKey.SUNRISE_TIMER_DURATION,
@@ -934,7 +934,7 @@ def __set_value_fn_dynamic_buffer_temp(
934934
suitable_fn=__suitable_fn_device_setting_default,
935935
get_value_fn=__get_value_fn_device_setting_default,
936936
set_value_fn=__set_value_fn_device_setting_default,
937-
at_type=None
937+
at_type_fn=lambda at_type: True
938938
),
939939
]
940940

@@ -980,7 +980,7 @@ def __init__(
980980
device: ACInfinityDevice,
981981
) -> None:
982982
super().__init__(
983-
coordinator, device, description.enabled_fn, description.suitable_fn, description.at_type, description.key, Platform.NUMBER
983+
coordinator, device, description.enabled_fn, description.suitable_fn, description.at_type_fn, description.key, Platform.NUMBER
984984
)
985985
self.entity_description = description
986986

custom_components/ac_infinity/select.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def __set_value_fn_device_load_type(
270270
suitable_fn=__suitable_fn_device_control_default,
271271
get_value_fn=__get_value_fn_active_mode,
272272
set_value_fn=__set_value_fn_active_mode,
273-
at_type=None
273+
at_type_fn=lambda at_type: True
274274
),
275275
ACInfinityDeviceSelectEntityDescription(
276276
key=DeviceControlKey.SETTING_MODE,
@@ -280,7 +280,7 @@ def __set_value_fn_device_load_type(
280280
suitable_fn=__suitable_fn_device_control_default,
281281
get_value_fn=__get_value_fn_setting_mode,
282282
set_value_fn=__set_value_fn_setting_mode,
283-
at_type=AtType.AUTO,
283+
at_type_fn=lambda at_type: at_type == AtType.AUTO,
284284
),
285285
ACInfinityDeviceSelectEntityDescription(
286286
key=DeviceControlKey.VPD_SETTING_MODE,
@@ -290,7 +290,7 @@ def __set_value_fn_device_load_type(
290290
suitable_fn=__suitable_fn_device_control_default,
291291
get_value_fn=__get_value_fn_setting_mode,
292292
set_value_fn=__set_value_fn_setting_mode,
293-
at_type=AtType.VPD,
293+
at_type_fn=lambda at_type: at_type == AtType.VPD,
294294
),
295295
ACInfinityDeviceSelectEntityDescription(
296296
key=AdvancedSettingsKey.DEVICE_LOAD_TYPE,
@@ -300,7 +300,7 @@ def __set_value_fn_device_load_type(
300300
suitable_fn=__suitable_fn_device_setting_basic_controller,
301301
get_value_fn=__get_value_fn_device_load_type,
302302
set_value_fn=__set_value_fn_device_load_type,
303-
at_type=None
303+
at_type_fn=lambda at_type: True
304304
),
305305
ACInfinityDeviceSelectEntityDescription(
306306
key=AdvancedSettingsKey.DYNAMIC_RESPONSE_TYPE,
@@ -310,7 +310,7 @@ def __set_value_fn_device_load_type(
310310
suitable_fn=__suitable_fn_device_setting_basic_controller,
311311
get_value_fn=__get_value_fn_dynamic_response_type,
312312
set_value_fn=__set_value_fn_dynamic_response_type,
313-
at_type=None
313+
at_type_fn=lambda at_type: True
314314
),
315315
]
316316

@@ -357,7 +357,7 @@ def __init__(
357357
description: ACInfinityDeviceSelectEntityDescription,
358358
device: ACInfinityDevice,
359359
) -> None:
360-
super().__init__(coordinator, device, description.enabled_fn, description.suitable_fn, description.at_type, description.key, Platform.SELECT)
360+
super().__init__(coordinator, device, description.enabled_fn, description.suitable_fn, description.at_type_fn, description.key, Platform.SELECT)
361361
self.entity_description = description
362362

363363
@property

0 commit comments

Comments
 (0)