Removed unneeded friendly_name fields

This commit is contained in:
rospogrigio
2020-09-15 23:31:33 +02:00
parent 400ad57e01
commit c99cc1f077
8 changed files with 25 additions and 18 deletions

View File

@@ -50,8 +50,6 @@ 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({})

View File

@@ -32,7 +32,6 @@ NO_ADDITIONAL_PLATFORMS = "no_additional_platforms"
USER_SCHEMA = vol.Schema(
{
vol.Required(CONF_NAME): str,
vol.Required(CONF_FRIENDLY_NAME): str,
vol.Required(CONF_HOST): str,
vol.Required(CONF_DEVICE_ID): str,
vol.Required(CONF_LOCAL_KEY): str,
@@ -77,8 +76,6 @@ async def validate_input(hass: core.HomeAssistant, data):
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({})

View File

@@ -84,7 +84,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
dps[device_config[CONF_ID]] = None
covers.append(
LocaltuyaCover(
TuyaCache(device),
TuyaCache(device, config_entry.data[CONF_FRIENDLY_NAME]),
device_config[CONF_FRIENDLY_NAME],
device_config[CONF_ID],
device_config.get(CONF_OPEN_CMD),
@@ -107,11 +107,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class TuyaCache:
"""Cache wrapper for pytuya.TuyaDevice"""
def __init__(self, device):
def __init__(self, device, friendly_name):
"""Initialize the cache."""
self._cached_status = ""
self._cached_status_time = 0
self._device = device
self._friendly_name = friendly_name
self._lock = Lock()
@property
@@ -202,7 +203,7 @@ class LocaltuyaCover(CoverEntity):
# Serial numbers are unique identifiers within a specific domain
("LocalTuya", f"local_{self._device.unique_id}")
},
"name": self._device._device.friendly_name,
"name": self._device._friendly_name,
"manufacturer": "Tuya generic",
"model": "SmartCover",
"sw_version": "3.3",

View File

@@ -63,7 +63,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for device_config in entities_to_setup:
lights.append(
LocaltuyaLight(
TuyaCache(device),
TuyaCache(device, config_entry.data[CONF_FRIENDLY_NAME]),
device_config[CONF_FRIENDLY_NAME],
device_config[CONF_ID],
)
@@ -80,11 +80,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class TuyaCache:
"""Cache wrapper for pytuya.TuyaDevices"""
def __init__(self, device):
def __init__(self, device, friendly_name):
"""Initialize the cache."""
self._cached_status = ""
self._cached_status_time = 0
self._device = device
self._friendly_name = friendly_name
self._lock = Lock()
@property
@@ -147,6 +148,19 @@ class LocaltuyaLight(LightEntity):
self._color_temp = 127
self._bulb_id = bulbid
@property
def device_info(self):
return {
"identifiers": {
# Serial numbers are unique identifiers within a specific domain
("LocalTuya", f"local_{self._device.unique_id}")
},
"name": self._device._friendly_name,
"manufacturer": "Tuya generic",
"model": "SmartLight",
"sw_version": "3.3",
}
def state(self):
self._device.state()

View File

@@ -173,7 +173,7 @@ payload_dict = {
class TuyaDevice(object):
def __init__(self, dev_id, address, local_key, friendly_name, name = "", connection_timeout=10):
def __init__(self, dev_id, address, local_key, connection_timeout=10):
"""
Represents a Tuya device.
@@ -189,8 +189,6 @@ class TuyaDevice(object):
self.id = dev_id
self.address = address
self.local_key = local_key.encode('latin1')
self.friendly_name = friendly_name
self.name = name
self.connection_timeout = connection_timeout
self.version = 3.1
self.dev_type = 'type_0a'

View File

@@ -16,7 +16,6 @@
"description": "Fill in the basic details and pick device type. The name entered here will be used to identify the integration itself (as seen in the `Integrations` page). You will name each sub-device in the following steps.",
"data": {
"name": "Name",
"friendly_name": "Friendly name",
"host": "Host",
"device_id": "Device ID",
"local_key": "Local key",

View File

@@ -101,7 +101,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for device_config in entities_to_setup:
switches.append(
LocaltuyaSwitch(
TuyaCache(device),
TuyaCache(device, config_entry.data[CONF_FRIENDLY_NAME]),
device_config[CONF_FRIENDLY_NAME],
device_config[CONF_ID],
device_config.get(CONF_CURRENT),
@@ -121,11 +121,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class TuyaCache:
"""Cache wrapper for pytuya.TuyaDevice"""
def __init__(self, device):
def __init__(self, device, friendly_name):
"""Initialize the cache."""
self._cached_status = ""
self._cached_status_time = 0
self._device = device
self._friendly_name = friendly_name
self._lock = Lock()
@property
@@ -220,7 +221,7 @@ class LocaltuyaSwitch(SwitchEntity):
# Serial numbers are unique identifiers within a specific domain
("LocalTuya", f"local_{self._device.unique_id}")
},
"name": self._device._device.friendly_name,
"name": self._device._friendly_name,
"manufacturer": "Tuya generic",
"model": "SmartSwitch",
"sw_version": "3.3",

View File

@@ -15,7 +15,6 @@
"description": "Fill in the basic details and pick device type. The name entered here will be used to identify the integration itself (as seen in the `Integrations` page). You will add entities and give them names in the following steps.",
"data": {
"name": "Name",
"friendly_name": "Friendly name",
"host": "Host",
"device_id": "Device ID",
"local_key": "Local key",