From 22ccd5192686be13fe52331089954dccf9bdb3bc Mon Sep 17 00:00:00 2001 From: rospogrigio Date: Tue, 15 Sep 2020 09:24:53 +0200 Subject: [PATCH] Fixed TuyaDevice init calls --- custom_components/localtuya/__init__.py | 2 ++ custom_components/localtuya/config_flow.py | 6 +++++- custom_components/localtuya/pytuya/__init__.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/custom_components/localtuya/__init__.py b/custom_components/localtuya/__init__.py index bebbba2..888c5e3 100644 --- a/custom_components/localtuya/__init__.py +++ b/custom_components/localtuya/__init__.py @@ -50,6 +50,8 @@ def prepare_setup_entities(config_entry, platform): config_entry.data[CONF_DEVICE_ID], config_entry.data[CONF_HOST], config_entry.data[CONF_LOCAL_KEY], + config_entry.data[CONF_FRIENDLY_NAME], + config_entry.data[CONF_NAME], ) device.set_version(float(config_entry.data[CONF_PROTOCOL_VERSION])) device.set_dpsUsed({}) diff --git a/custom_components/localtuya/config_flow.py b/custom_components/localtuya/config_flow.py index 0cece50..0135e80 100644 --- a/custom_components/localtuya/config_flow.py +++ b/custom_components/localtuya/config_flow.py @@ -74,7 +74,11 @@ def strip_dps_values(user_input, dps_strings): async def validate_input(hass: core.HomeAssistant, data): """Validate the user input allows us to connect.""" pytuyadevice = pytuya.TuyaDevice( - data[CONF_DEVICE_ID], data[CONF_HOST], data[CONF_LOCAL_KEY] + data[CONF_DEVICE_ID], + data[CONF_HOST], + data[CONF_LOCAL_KEY], + data[CONF_FRIENDLY_NAME], + data[CONF_NAME], ) pytuyadevice.set_version(float(data[CONF_PROTOCOL_VERSION])) pytuyadevice.set_dpsUsed({}) diff --git a/custom_components/localtuya/pytuya/__init__.py b/custom_components/localtuya/pytuya/__init__.py index e27098b..b7468ae 100644 --- a/custom_components/localtuya/pytuya/__init__.py +++ b/custom_components/localtuya/pytuya/__init__.py @@ -173,7 +173,7 @@ payload_dict = { class TuyaDevice(object): - def __init__(self, dev_id, address, local_key=None, connection_timeout=10): + def __init__(self, dev_id, address, local_key, friendly_name, name = "", connection_timeout=10): """ Represents a Tuya device.