Open Ovi8392 opened 5 months ago
Need Help.... I understood that you solved the problem of - Two+ units can be added I couldn't figure out how to fix the problem according to your solution. What to copy to my files Thanks
Need Help.... I understood that you solved the problem of - Two+ units can be added I couldn't figure out how to fix the problem according to your solution. What to copy to my files Thanks
I'm new on Git so don't know how things around here works.
https://github.com/Ovi8392/tuya_custom/tree/DavidIlie-/-tuya-smart-ir-ac-/-(edited-by-me)
Files you interested in:
init.py api.py climate.py const.py manifest.json
to add in configuration.yaml
climate:
platform: tuya_smart_ir_ac name: "Name AC 1" sensor: "sensor.temperature_humidity_sensor_temperature" ### Replace with your sensor access_id: "xxxxx" ### from Tuya developer site access_secret: "xxxxx" ### from Tuya developer site remote_id: "xxxxx" ### Smart IR device ac_id: "xxxxx" ### Remote created with Smart IR
platform: tuya_smart_ir_ac name: "Name AC 2" sensor: "sensor.temperature_humidity_sensor_temperature" ### Replace with your sensor access_id: "xxxxx" access_secret: "xxxxx" remote_id: "xxxxx" ac_id: "xxxxx"
logger: default: info logs: custom_components.tuya_smart_ir_ac: debug tuya_hack: debug
end of part to add in configuration.yaml
Remember change in api.py correct server you use
openapi = TuyaOpenAPI("https://openapi.tuyaus.com", access_id, access_secret)
Ignore my project [tuya_custom] and its files, it's my playground, I add Fan with it, but still testing.
Need Help.... I understood that you solved the problem of - Two+ units can be added I couldn't figure out how to fix the problem according to your solution. What to copy to my files Thanks
I'm new on Git so don't know how things around here works.
https://github.com/Ovi8392/tuya_custom/tree/DavidIlie-/-tuya-smart-ir-ac-/-(edited-by-me)
Files you interested in:
init.py api.py climate.py const.py manifest.json
to add in configuration.yaml
climate:
- platform: tuya_smart_ir_ac name: "Name AC 1" sensor: "sensor.temperature_humidity_sensor_temperature" ### Replace with your sensor access_id: "xxxxx" ### from Tuya developer site access_secret: "xxxxx" ### from Tuya developer site remote_id: "xxxxx" ### Smart IR device ac_id: "xxxxx" ### Remote created with Smart IR
- platform: tuya_smart_ir_ac name: "Name AC 2" sensor: "sensor.temperature_humidity_sensor_temperature" ### Replace with your sensor access_id: "xxxxx" access_secret: "xxxxx" remote_id: "xxxxx" ac_id: "xxxxx"
logger: default: info logs: custom_components.tuya_smart_ir_ac: debug tuya_hack: debug
end of part to add in configuration.yaml
Remember change in api.py correct server you use openapi = TuyaOpenAPI("https://openapi.tuyaus.com", access_id, access_secret) Ignore my project [tuya_custom] and its files, it's my playground, I add Fan with it, but still testing.
tanks man this solved my problem, now i can add more then one ac wihtout any problem
All credits goes to ChatGPT, I just tell him what to do.
Fix and improvements made:
Findings over testing:
Status of unit comes from Tuya app remote, if temp adjusted with physical remote control then changes will not reflect on thermostat in HA and will cause further issues.
With log you can see issues, as example for unknown reasons when I try set Fan Only mode it sends '3' but in return: "Failed to send command mode with value 3: {'code': 30100, 'msg': '没有查询到码库', 'success': False, 't': 1717948574454, 'tid': 'cc998e5d267811efb9130e1a774ae1f3'}" I assume issue is because of remote control setup in Tuya app, will test other remotes. To test working modes of unit its possible to change modes in Tuya app and see HA log of status update.
Flowing warning changes if fixed, but anyway replaces wit other warning about HVAC modes, I assume its something in HA, may be gone after they cut it out. "Entity None (<class 'custom_components.tuya_smart_ir_ac.climate.TuyaThermostat'>) implements HVACMode(s): cool, heat, auto, fan_only, dry, off and therefore implicitly supports the turn_on/turn_off methods without setting the proper ClimateEntityFeature. Please report it to the author of the 'tuya_smart_ir_ac' custom integration"
Big thanks to David! Save my started budget smart home project.
Add to configuration.yaml this code too:
logger: default: warning logs: custom_components.tuya_smart_ir_ac: debug tuya_hack: debug
/homeassistant/custom_components/tuya_smart_ir_ac/climate.py `import logging from typing import Any, Dict
import voluptuous as vol from pprint import pformat
from homeassistant.core import HomeAssistant from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.config_validation import PLATFORM_SCHEMA import homeassistant.helpers.config_validation as cv from homeassistant.components.climate.const import HVACMode from homeassistant.const import UnitOfTemperature, STATE_UNKNOWN from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
from .const import VALID_MODES from .api import TuyaAPI
_LOGGER = logging.getLogger("tuya_hack")
Define constants for configuration keys
ACCESS_ID = "access_id" ACCESS_SECRET = "access_secret" REMOTE_ID = "remote_id" AC_ID = "ac_id" NAME = "name" SENSOR = "sensor"
Schema for platform configuration
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { vol.Required(ACCESS_ID): cv.string, vol.Required(ACCESS_SECRET): cv.string, vol.Required(REMOTE_ID): cv.string, vol.Required(AC_ID): cv.string, vol.Required(NAME): cv.string, vol.Required(SENSOR): cv.string, } )
def setup_platform( hass: HomeAssistant, config: ConfigType, add_entities: AddEntitiesCallback, discovery_info: DiscoveryInfoType | None = None, ) -> None: """Set up the Tuya thermostat platform.""" _LOGGER.info("Setting up Tuya thermostat platform") climate_config = { "access_id": config[ACCESS_ID], "access_secret": config[ACCESS_SECRET], "remote_id": config[REMOTE_ID], "ac_id": config[AC_ID], "name": config[NAME], "sensor": config[SENSOR] }
class TuyaThermostat(ClimateEntity): """Representation of a Tuya Thermostat."""
`
/homeassistant/custom_components/tuya_smart_ir_ac/api.py `from tuya_connector import TuyaOpenAPI from .const import VALID_MODES from homeassistant.core import HomeAssistant import logging from pprint import pformat
_LOGGER = logging.getLogger("tuya_hack")
class TuyaAPI: """ Interface to interact with Tuya devices. """
/homeassistant/custom_components/tuya_smart_ir_ac/const.py `from homeassistant.components.climate.const import HVACMode import logging
_LOGGER = logging.getLogger(name)
VALID_MODES = { "0": HVACMode.COOL, "1": HVACMode.HEAT, "2": HVACMode.AUTO, "3": HVACMode.FAN_ONLY, "4": HVACMode.DRY, "5": HVACMode.OFF, }
_LOGGER.debug(f"Valid HVAC modes: {VALID_MODES}")`