2626from . import TuyaConfigEntry
2727from .const import TUYA_DISCOVERY_NEW , DeviceCategory , DPCode , DPType
2828from .entity import TuyaEntity
29- from .models import IntegerTypeData
29+ from .models import IntegerTypeData , find_dpcode
3030from .util import get_dpcode
3131
3232TUYA_HVAC_TO_HA = {
@@ -153,11 +153,13 @@ def __init__(
153153 self ._attr_temperature_unit = system_temperature_unit
154154
155155 # Figure out current temperature, use preferred unit or what is available
156- celsius_type = self . find_dpcode (
157- (DPCode .TEMP_CURRENT , DPCode .UPPER_TEMP ), dptype = DPType .INTEGER
156+ celsius_type = find_dpcode (
157+ self . device , (DPCode .TEMP_CURRENT , DPCode .UPPER_TEMP ), dptype = DPType .INTEGER
158158 )
159- fahrenheit_type = self .find_dpcode (
160- (DPCode .TEMP_CURRENT_F , DPCode .UPPER_TEMP_F ), dptype = DPType .INTEGER
159+ fahrenheit_type = find_dpcode (
160+ self .device ,
161+ (DPCode .TEMP_CURRENT_F , DPCode .UPPER_TEMP_F ),
162+ dptype = DPType .INTEGER ,
161163 )
162164 if fahrenheit_type and (
163165 prefered_temperature_unit == UnitOfTemperature .FAHRENHEIT
@@ -173,11 +175,11 @@ def __init__(
173175 self ._current_temperature = celsius_type
174176
175177 # Figure out setting temperature, use preferred unit or what is available
176- celsius_type = self . find_dpcode (
177- DPCode .TEMP_SET , dptype = DPType .INTEGER , prefer_function = True
178+ celsius_type = find_dpcode (
179+ self . device , DPCode .TEMP_SET , dptype = DPType .INTEGER , prefer_function = True
178180 )
179- fahrenheit_type = self . find_dpcode (
180- DPCode .TEMP_SET_F , dptype = DPType .INTEGER , prefer_function = True
181+ fahrenheit_type = find_dpcode (
182+ self . device , DPCode .TEMP_SET_F , dptype = DPType .INTEGER , prefer_function = True
181183 )
182184 if fahrenheit_type and (
183185 prefered_temperature_unit == UnitOfTemperature .FAHRENHEIT
@@ -201,8 +203,8 @@ def __init__(
201203 # Determine HVAC modes
202204 self ._attr_hvac_modes : list [HVACMode ] = []
203205 self ._hvac_to_tuya = {}
204- if enum_type := self . find_dpcode (
205- DPCode .MODE , dptype = DPType .ENUM , prefer_function = True
206+ if enum_type := find_dpcode (
207+ self . device , DPCode .MODE , dptype = DPType .ENUM , prefer_function = True
206208 ):
207209 self ._attr_hvac_modes = [HVACMode .OFF ]
208210 unknown_hvac_modes : list [str ] = []
@@ -225,22 +227,26 @@ def __init__(
225227 ]
226228
227229 # Determine dpcode to use for setting the humidity
228- if int_type := self .find_dpcode (
229- DPCode .HUMIDITY_SET , dptype = DPType .INTEGER , prefer_function = True
230+ if int_type := find_dpcode (
231+ self .device ,
232+ DPCode .HUMIDITY_SET ,
233+ dptype = DPType .INTEGER ,
234+ prefer_function = True ,
230235 ):
231236 self ._attr_supported_features |= ClimateEntityFeature .TARGET_HUMIDITY
232237 self ._set_humidity = int_type
233238 self ._attr_min_humidity = int (int_type .min_scaled )
234239 self ._attr_max_humidity = int (int_type .max_scaled )
235240
236241 # Determine dpcode to use for getting the current humidity
237- self ._current_humidity = self . find_dpcode (
238- DPCode .HUMIDITY_CURRENT , dptype = DPType .INTEGER
242+ self ._current_humidity = find_dpcode (
243+ self . device , DPCode .HUMIDITY_CURRENT , dptype = DPType .INTEGER
239244 )
240245
241246 # Determine fan modes
242247 self ._fan_mode_dp_code : str | None = None
243- if enum_type := self .find_dpcode (
248+ if enum_type := find_dpcode (
249+ self .device ,
244250 (DPCode .FAN_SPEED_ENUM , DPCode .LEVEL , DPCode .WINDSPEED ),
245251 dptype = DPType .ENUM ,
246252 prefer_function = True ,
0 commit comments