rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.84k stars 546 forks source link

climate error :'LocaltuyaClimate' object has no attribute '_attr_target_temperature_high' #1559

Open mickey50 opened 10 months ago

mickey50 commented 10 months ago

The problem

when setting the climate into HA, it's not work

Environment

{ "home_assistant": { "installation_type": "Home Assistant Supervised", "version": "2023.11.2", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.11.6", "docker": true, "arch": "x86_64", "timezone": "Asia/Shanghai", "os_name": "Linux", "os_version": "4.4.302+", "supervisor": "2023.11.0", "host_os": null, "docker_version": "20.10.23", "chassis": null, "run_as_root": true }, "custom_components": { "ha_cloud_music": { "version": "1.0.0", "requirements": [ "mutagen>=1.46.0", "python-mpd2==3.0.5", "python-vlc==1.1.2" ] }, "saswell": { "version": "1.0.0", "requirements": [] }, "climate_ewelink": { "version": "v0.3.0", "requirements": [] }, "jellyfin": { "version": "1.1.1", "requirements": [ "jellyfin-apiclient-python==1.7.2" ] }, "zhibot": { "version": "1.0.1", "requirements": [] }, "zhimi": { "version": "1.0.1", "requirements": [ "miservice>=2.0.1" ] }, "bus_arrivaltime": { "version": "1.6.0", "requirements": [] }, "xiaomi_miio_airpurifier": { "version": "2023.6.0.0", "requirements": [ "construct==2.10.56", "python-miio>=0.5.12" ] }, "xiaomi_miio_cooker": { "version": "2023.6.0.0", "requirements": [ "construct==2.10.56", "python-miio>=0.5.12" ] }, "xiaomi_miio_raw": { "version": "2023.6.0.0", "requirements": [ "construct==2.10.56", "python-miio>=0.5.12" ] }, "xiaomi_miot": { "version": "0.7.13", "requirements": [ "construct>=2.10.56", "python-miio>=0.5.6", "micloud>=0.3" ] }, "hacs": { "version": "1.33.0", "requirements": [ "aiogithubapi>=22.10.1" ] }, "bemfa": { "version": "1.4.0", "requirements": [ "paho-mqtt==1.6.1" ] }, "sonoff": { "version": "3.5.3", "requirements": [ "pycryptodome>=3.6.6" ] }, "midea_ac_lan": { "version": "v0.3.22", "requirements": [] }, "ikuai": { "version": "1.3", "requirements": [] }, "xiaomi_gateway3": { "version": "3.3.4", "requirements": [ "zigpy>=0.44.1" ] }, "nodered": { "version": "3.1.1", "requirements": [] }, "localtuya": { "version": "5.2.1", "requirements": [] }, "nmc_weather": { "version": "1.0.0", "requirements": [] }, "smartlife": { "version": "0.1.0", "requirements": [ "tuya-device-sharing-sdk==0.1.8" ] } }, "integration_manifest": { "domain": "localtuya", "name": "LocalTuya integration", "codeowners": [ "@rospogrigio", "@postlund" ], "config_flow": true, "dependencies": [], "documentation": "https://github.com/rospogrigio/localtuya/", "iot_class": "local_push", "issue_tracker": "https://github.com/rospogrigio/localtuya/issues", "requirements": [], "version": "5.2.1", "is_built_in": false }, "data": { "device_config": { "friendly_name": "\u667a\u80fd\u6e29\u63a7\u5668", "host": "192.168.1.62", "device_id": "6cd1a1f8214b65b69f1z8b", "local_key": "~!aJ=|u>k!-6UP}?", "protocol_version": "3.4", "enable_debug": false, "model": "\u667a\u80fd\u6e29\u63a7\u5668", "dps_strings": [ "1 (value: True)", "2 (value: auto)", "10 (value: True)", "16 (value: 16)", "19 (value: 35)", "24 (value: 175)", "26 (value: 5)", "27 (value: 0)", "36 (value: close)", "40 (value: True)", "43 (value: in)", "45 (value: 0)", "101 (value: 1)", "102 (value: 52)" ], "entities": [ { "id": 1, "friendly_name": "\u6e29\u63a7\u5668", "target_temperature_dp": 16, "current_temperature_dp": 24, "temperature_step": 1, "max_temperature_dp": 19, "min_temperature_dp": 26, "precision": 0.1, "hvac_mode_dp": 2, "hvac_mode_set": "manual/auto", "hvac_action_dp": 36, "hvac_action_set": "open/close", "preset_dp": 102, "temperature_unit": "celsius", "target_precision": 1, "platform": "climate" } ], "product_key": "a6xsrfsmruiqjsbg" }, "device_cloud_info": { "active_time": 1700155518, "biz_type": 18, "category": "wk", "create_time": 1700140270, "icon": "smart/icon/ay1547110530245tcZgC/a40bb811d49b7949a92905e64e16ef3a.jpg", "model": "ME98", "name": "\u667a\u80fd\u6e29\u63a7\u5668", "online": true, "product_id": "a6xsrfsmruiqjsbg", "product_name": "\u667a\u80fd\u6e29\u63a7\u5668", "status": [ { "code": "switch", "value": true }, { "code": "mode", "value": "auto" }, { "code": "frost", "value": true }, { "code": "temp_set", "value": 16 }, { "code": "upper_temp", "value": 35 }, { "code": "temp_current", "value": 175 }, { "code": "lower_temp", "value": 5 }, { "code": "temp_correction", "value": 0 }, { "code": "valve_state", "value": "close" }, { "code": "factory_reset", "value": false }, { "code": "child_lock", "value": true }, { "code": "sensor_choose", "value": "in" }, { "code": "fault", "value": 0 } ], "sub": false, "time_zone": "+08:00", "uid": "ay1700155392084kVD9z", "update_time": 1700183139, "uuid": "7477a83ad6f41c2c" } } }

Provide Home Assistant traceback/logs

state, attr = self._async_generate_attributes()                                                                                                       
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                       

File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in _async_generate_attributes
attr.update(self.state_attributes or {})
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 330, in state_attributes
hass, self.target_temperature_high, temperature_unit, precision
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 410, in target_temperature_high
return self._attr_target_temperature_high
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'LocaltuyaClimate' object has no attribute '_attr_target_temperature_high'

mickey50 commented 9 months ago

add last two line code ,set attr_target_temperature_high and attr_target_temperature_low value it can works but should set the correct value from control data def __init__( self, device, config_entry, switchid, **kwargs, ): """Initialize a new LocaltuyaClimate.""" super().__init__(device, config_entry, switchid, _LOGGER, **kwargs) self._state = None self._target_temperature = None self._current_temperature = None self._hvac_mode = None self._preset_mode = None self._hvac_action = None self._attr_target_temperature_high = 35.0 self._attr_target_temperature_low = 15.0