Skip to content

Commit

Permalink
Adds target controls for auto and vpd modes
Browse files Browse the repository at this point in the history
Target Temperature for ACs and Heaters
Target Humidity for Humidifiers
Target VPD for ACs, Heaters, and Humidifiers.
  • Loading branch information
dalinicus committed Sep 10, 2024
1 parent c9ecc7e commit 5ecdda3
Show file tree
Hide file tree
Showing 12 changed files with 409 additions and 25 deletions.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ This is a custom component for [Home Assistant](http://home-assistant.io) that a
- [On Mode](#on-mode)
- [Off Mode](#off-mode)
- [Auto Mode](#auto-mode)
- [Auto Settings Mode](#auto-setting-mode)
- [Target Settings Mode](#target-settings-mode)
- [Timer to On Mode](#timer-to-on-mode)
- [Timer to Off Mode](#timer-to-off-mode)
- [Cycle Mode](#cycle-mode)
- [Schedule Mode](#schedule-mode)
- [VPD Mode](#vpd-mode)
- [Auto Settings Mode](#auto-setting-mode-1)
- [Target Settings Mode](#target-settings-mode-1)
- [Device Settings](#device-settings)
- [Dynamic Response](#dynamic-response)
- [Transition Mode](#transition-mode)
Expand Down Expand Up @@ -183,7 +187,12 @@ Device is always set to the on speed . This mode has no unique controls.
Device is always set to the off speed . This mode has no unique controls.

### Auto Mode
Device toggled based on temperature and/or humidity triggers
Device toggled based on temperature and/or humidity triggers. This mode is split into two sub modes: Auto and Target.

- `Auto Settings Mode`: Swap between `Auto` and `Target` setting mode types. `Target` mode is not valid for some device types.

#### Auto Setting Mode

- `High Temp Enabled`: Enable or disable high temp trigger while in Auto mode
- `High Temp Trigger`: If trigger is enabled, device will be turned on if temp exceeds configured value.
- `Low Temp Enabled`: Enable or disable low temp trigger while in Auto mode
Expand All @@ -193,6 +202,16 @@ Device toggled based on temperature and/or humidity triggers
- `Low Humidity Enabled`: Enable or disable low humidity trigger while in Auto mode
- `Low Humidity Trigger`: If trigger is enabled, device will be turned on if humidity drops below configured value.

#### Target Settings Mode

- `Target Temp Enabled`: Enabled or disable the target temperature target. *
- `Target Temp`: If enabled, target temperature to maintain. *
- `Target Humidity Enabled`: Enable or disable the target humidity target. **
- `Target Humidity`: If enabled, the target humidity to maintain. **

<sub>* Only valid for AC or Heater devices</sub>
<sub>** Only valid for Humidifier devices</sub>

### Timer to On Mode
Device is turned on after a set duration
- `Minutes to On`: Device will be turned on after the configured number of minutes
Expand All @@ -213,7 +232,19 @@ Device is toggled based on a schedule

### VPD Mode
Device is toggled based on VPD triggers

- `VPD Settings Mode`: Swap between `Auto` and `Target` setting mode types. `Target` mode is not valid for some device types.

#### Auto Setting Mode

- `VPD High Enabled`: Enable or disable high VPD trigger while in VPD mode
- `VPD High Trigger`: If trigger is enabled, device will be turned on if VPD exceeds configured value.
- `VPD Low Enabled`: Enable or disable low VPD trigger while in VPD mode
- `VPD Low Trigger`: If trigger is enabled, device will be turned on if VPD drops below configured value.

#### Target Settings Mode

- `Target VPD Enabled`: Enable or disable the target VPD target *
- `Target VPD`: If enabled, the target VPD to maintain *

<sub>* Only valid for AC, Heater, and Humidifier devices</sub>
12 changes: 9 additions & 3 deletions custom_components/ac_infinity/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@ class PortControlKey:
TIMER_DURATION_TO_OFF = "acitveTimerOff"
CYCLE_DURATION_ON = "activeCycleOn"
CYCLE_DURATION_OFF = "activeCycleOff"
VPD_SETTINGS_MODE = "vpdSettingMode"
VPD_HIGH_ENABLED = "activeHtVpd"
VPD_HIGH_TRIGGER = "activeHtVpdNums"
VPD_LOW_ENABLED = "activeLtVpd"
VPD_LOW_TRIGGER = "activeLtVpdNums"
VPD_TARGET_ENABLED = "targetVpdSwitch"
VPD_TARGET = "targetVpd"
AUTO_SETTINGS_MODE = "settingMode"
AUTO_TEMP_HIGH_TRIGGER = "devHt"
AUTO_TEMP_HIGH_TRIGGER_F = "devHtf"
AUTO_TEMP_HIGH_ENABLED = "activeHt"
Expand All @@ -132,9 +136,11 @@ class PortControlKey:
AUTO_TEMP_LOW_ENABLED = "activeLt"
AUTO_HUMIDITY_LOW_TRIGGER = "devLh"
AUTO_HUMIDITY_LOW_ENABLED = "activeLh"
TARGET_HUMIDITY_SWITCH = "targetHumiSwitch"
TARGET_TEMPERATURE_SWITCH = "targetTSwitch"
TARGET_VPD_SWITCH = "targetVpdSwitch"
AUTO_TARGET_TEMP_ENABLED = "targetTSwitch"
AUTO_TARGET_TEMP = "targetTemp"
AUTO_TARGET_TEMP_F = "targetTempF"
AUTO_TARGET_HUMIDITY_ENABLED = "targetHumiSwitch"
AUTO_TARGET_HUMIDITY = "targetHumi"
EC_OR_TDS = "ecOrTds"
VPD_STATUS = "vpdstatus"
VPD_NUMS = "vpdnums"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ac_infinity/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/dalinicus/homeassistant-acinfinity",
"requirements": [],
"version": "1.6.0"
"version": "1.7.0"
}
57 changes: 57 additions & 0 deletions custom_components/ac_infinity/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,21 @@ def __set_value_fn_temp_auto_high(
)


def __set_value_fn_target_temp(
entity: ACInfinityEntity, port: ACInfinityPort, value: int
):
return entity.ac_infinity.update_port_controls(
port.controller.device_id,
port.port_index,
[
# value is received from HA as C
(PortControlKey.AUTO_TARGET_TEMP, value),
# degrees F must be calculated and set in addition to C
(PortControlKey.AUTO_TARGET_TEMP_F, int(round((value * 1.8) + 32, 0))),
],
)


def __get_value_fn_dynamic_transition_temp(
entity: ACInfinityEntity, port: ACInfinityPort
):
Expand Down Expand Up @@ -488,6 +503,20 @@ def __set_value_fn_dynamic_buffer_temp(
get_value_fn=__get_value_fn_vpd_control,
set_value_fn=__set_value_fn_vpd_control,
),
ACInfinityPortNumberEntityDescription(
key=PortControlKey.VPD_TARGET,
device_class=NumberDeviceClass.PRESSURE,
mode=NumberMode.BOX,
native_min_value=0,
native_max_value=9.9,
native_step=0.1,
icon="mdi:water-thermometer-outline",
translation_key="target_vpd",
native_unit_of_measurement=None,
suitable_fn=suitable_fn_port_control_default,
get_value_fn=__get_value_fn_vpd_control,
set_value_fn=__set_value_fn_vpd_control,
),
ACInfinityPortNumberEntityDescription(
key=PortControlKey.AUTO_HUMIDITY_LOW_TRIGGER,
device_class=NumberDeviceClass.HUMIDITY,
Expand Down Expand Up @@ -516,6 +545,20 @@ def __set_value_fn_dynamic_buffer_temp(
get_value_fn=get_value_fn_port_control_default,
set_value_fn=set_value_fn_port_control_default,
),
ACInfinityPortNumberEntityDescription(
key=PortControlKey.AUTO_TARGET_HUMIDITY,
device_class=NumberDeviceClass.HUMIDITY,
mode=NumberMode.AUTO,
native_min_value=0,
native_max_value=100,
native_step=1,
icon="mdi:water-percent",
translation_key="target_humidity",
native_unit_of_measurement=None,
suitable_fn=suitable_fn_port_control_default,
get_value_fn=get_value_fn_port_control_default,
set_value_fn=set_value_fn_port_control_default,
),
ACInfinityPortNumberEntityDescription(
key=PortControlKey.AUTO_TEMP_LOW_TRIGGER,
device_class=NumberDeviceClass.TEMPERATURE,
Expand Down Expand Up @@ -544,6 +587,20 @@ def __set_value_fn_dynamic_buffer_temp(
get_value_fn=get_value_fn_port_control_default,
set_value_fn=__set_value_fn_temp_auto_high,
),
ACInfinityPortNumberEntityDescription(
key=PortControlKey.AUTO_TARGET_TEMP,
device_class=NumberDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
mode=NumberMode.AUTO,
native_min_value=0,
native_max_value=90,
native_step=1,
icon=None,
translation_key="target_temp",
suitable_fn=suitable_fn_port_control_default,
get_value_fn=get_value_fn_port_control_default,
set_value_fn=__set_value_fn_target_temp,
),
ACInfinityPortNumberEntityDescription(
key=AdvancedSettingsKey.DYNAMIC_TRANSITION_TEMP,
device_class=None,
Expand Down
40 changes: 40 additions & 0 deletions custom_components/ac_infinity/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class ACInfinityPortSelectEntityDescription(
6: "Fan",
}

SETTINGS_MODE_OPTIONS = [
"Auto",
"Target",
]


def __get_value_fn_outside_climate(
entity: ACInfinityEntity, controller: ACInfinityController
Expand All @@ -97,6 +102,25 @@ def __set_value_fn_outside_climate(
)


def __get_value_fn_setting_mode(entity: ACInfinityEntity, port: ACInfinityPort):
return SETTINGS_MODE_OPTIONS[
entity.ac_infinity.get_port_control(
port.controller.device_id, port.port_index, entity.entity_description.key
)
]


def __set_value_fn_setting_mode(
entity: ACInfinityEntity, port: ACInfinityPort, value: str
):
return entity.ac_infinity.update_port_control(
port.controller.device_id,
port.port_index,
entity.entity_description.key,
SETTINGS_MODE_OPTIONS.index(value),
)


def __get_value_fn_active_mode(entity: ACInfinityEntity, port: ACInfinityPort):
return MODE_OPTIONS[
# data is 1 based. Adjust to 0 based enum by subtracting 1
Expand Down Expand Up @@ -193,6 +217,22 @@ def __set_value_fn_device_load_type(
get_value_fn=__get_value_fn_active_mode,
set_value_fn=__set_value_fn_active_mode,
),
ACInfinityPortSelectEntityDescription(
key=PortControlKey.AUTO_SETTINGS_MODE,
translation_key="auto_settings_mode",
options=SETTINGS_MODE_OPTIONS,
suitable_fn=suitable_fn_port_control_default,
get_value_fn=__get_value_fn_setting_mode,
set_value_fn=__set_value_fn_setting_mode,
),
ACInfinityPortSelectEntityDescription(
key=PortControlKey.VPD_SETTINGS_MODE,
translation_key="vpd_settings_mode",
options=SETTINGS_MODE_OPTIONS,
suitable_fn=suitable_fn_port_control_default,
get_value_fn=__get_value_fn_setting_mode,
set_value_fn=__set_value_fn_setting_mode,
),
ACInfinityPortSelectEntityDescription(
key=AdvancedSettingsKey.DEVICE_LOAD_TYPE,
translation_key="device_load_type",
Expand Down
24 changes: 24 additions & 0 deletions custom_components/ac_infinity/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,27 @@
"vpd_mode_high_trigger": {
"name": "VPD High Trigger"
},
"target_vpd": {
"name": "Target VPD"
},
"auto_mode_humidity_low_trigger": {
"name": "Humidity Low Trigger"
},
"auto_mode_humidity_high_trigger": {
"name": "Humidity High Trigger"
},
"target_humidity": {
"name": "Target Humidity"
},
"auto_mode_temp_low_trigger": {
"name": "Temperature Low Trigger"
},
"auto_mode_temp_high_trigger": {
"name": "Temperature High Trigger"
},
"target_temp": {
"name": "Target Temperature"
},
"temperature_calibration": {
"name": "Temperature Calibration"
},
Expand Down Expand Up @@ -140,6 +149,12 @@
},
"outside_climate_humidity": {
"name": "Outside Humidity"
},
"auto_settings_mode": {
"name": "Auto Settings Mode"
},
"vpd_settings_mode": {
"name": "VPD Settings Mode"
}
},
"sensor": {
Expand All @@ -166,6 +181,9 @@
"vpd_mode_high_enabled": {
"name": "VPD High Trigger Enabled"
},
"target_vpd_enabled": {
"name": "Target VPD Enabled"
},
"auto_mode_humidity_low_enabled": {
"name": "Humidity Low Trigger Enabled"
},
Expand All @@ -178,6 +196,12 @@
"auto_mode_temp_high_enabled": {
"name": "Temperature High Trigger Enabled"
},
"target_temp_enabled": {
"name": "Target Temperature Enabled"
},
"target_humidity_enabled": {
"name": "Target Humidity Enabled"
},
"schedule_mode_on_time_enabled": {
"name": "Scheduled On-Time Enabled"
},
Expand Down
33 changes: 33 additions & 0 deletions custom_components/ac_infinity/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ def __get_value_fn_schedule_enabled(entity: ACInfinityEntity, port: ACInfinityPo
get_value_fn=get_value_fn_port_control_default,
set_value_fn=set_value_fn_port_control_default,
),
ACInfinityPortSwitchEntityDescription(
key=PortControlKey.VPD_TARGET_ENABLED,
device_class=SwitchDeviceClass.SWITCH,
on_value=1,
off_value=0,
icon=None, # default
translation_key="target_vpd_enabled",
suitable_fn=suitable_fn_port_control_default,
get_value_fn=get_value_fn_port_control_default,
set_value_fn=set_value_fn_port_control_default,
),
ACInfinityPortSwitchEntityDescription(
key=PortControlKey.AUTO_TEMP_HIGH_ENABLED,
device_class=SwitchDeviceClass.SWITCH,
Expand Down Expand Up @@ -141,6 +152,28 @@ def __get_value_fn_schedule_enabled(entity: ACInfinityEntity, port: ACInfinityPo
get_value_fn=get_value_fn_port_control_default,
set_value_fn=set_value_fn_port_control_default,
),
ACInfinityPortSwitchEntityDescription(
key=PortControlKey.AUTO_TARGET_TEMP_ENABLED,
device_class=SwitchDeviceClass.SWITCH,
on_value=1,
off_value=0,
icon=None, # default
translation_key="target_temp_enabled",
suitable_fn=suitable_fn_port_control_default,
get_value_fn=get_value_fn_port_control_default,
set_value_fn=set_value_fn_port_control_default,
),
ACInfinityPortSwitchEntityDescription(
key=PortControlKey.AUTO_TARGET_HUMIDITY_ENABLED,
device_class=SwitchDeviceClass.SWITCH,
on_value=1,
off_value=0,
icon=None, # default
translation_key="target_humidity_enabled",
suitable_fn=suitable_fn_port_control_default,
get_value_fn=get_value_fn_port_control_default,
set_value_fn=set_value_fn_port_control_default,
),
ACInfinityPortSwitchEntityDescription(
key=PortControlKey.SCHEDULED_START_TIME,
device_class=SwitchDeviceClass.SWITCH,
Expand Down
Loading

0 comments on commit 5ecdda3

Please sign in to comment.