From ee853ddb832a85777b0b7ff48a9ac86c9990db9d Mon Sep 17 00:00:00 2001 From: rospogrigio Date: Thu, 1 Oct 2020 09:09:12 +0200 Subject: [PATCH] Positioning mode changed from 'yes' to 'position'; removed 'stop' command configuration --- custom_components/localtuya/const.py | 2 +- custom_components/localtuya/cover.py | 14 ++++++-------- custom_components/localtuya/translations/en.json | 8 ++++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/custom_components/localtuya/const.py b/custom_components/localtuya/const.py index 3849deb..7994f2d 100644 --- a/custom_components/localtuya/const.py +++ b/custom_components/localtuya/const.py @@ -21,7 +21,7 @@ CONF_POSITIONING_MODE = "positioning_mode" CONF_CURRPOS = "currpos_dps" CONF_SETPOS = "setpos_dps" CONF_MODE_NONE = "none" -CONF_MODE_YES = "yes" +CONF_MODE_POSITION = "position" CONF_MODE_FAKE = "fake" CONF_SPAN_TIME = "span_time" diff --git a/custom_components/localtuya/cover.py b/custom_components/localtuya/cover.py index b689535..50179fe 100644 --- a/custom_components/localtuya/cover.py +++ b/custom_components/localtuya/cover.py @@ -23,7 +23,7 @@ from .const import ( CONF_SETPOS, CONF_POSITIONING_MODE, CONF_MODE_NONE, - CONF_MODE_YES, + CONF_MODE_POSITION, CONF_MODE_FAKE, CONF_SPAN_TIME, ) @@ -41,14 +41,12 @@ DEFAULT_SPAN_TIME = 25.0 def flow_schema(dps): """Return schema used in config flow.""" return { - vol.Optional(CONF_OPEN_CMD, default=DEFAULT_OPEN_CMD): vol.In( - ["on", "open"] - ), + vol.Optional(CONF_OPEN_CMD, default=DEFAULT_OPEN_CMD): vol.In(["on", "open"]), vol.Optional(CONF_CLOSE_CMD, default=DEFAULT_CLOSE_CMD): vol.In( ["off", "close"] ), vol.Optional(CONF_POSITIONING_MODE, default=DEFAULT_POSITIONING_MODE): vol.In( - [CONF_MODE_NONE, CONF_MODE_YES, CONF_MODE_FAKE] + [CONF_MODE_NONE, CONF_MODE_POSITION, CONF_MODE_FAKE] ), vol.Optional(CONF_CURRPOS): vol.In(dps), vol.Optional(CONF_SETPOS): vol.In(dps), @@ -126,7 +124,7 @@ class LocaltuyaCover(LocalTuyaEntity, CoverEntity): @property def is_open(self): """Return if the cover is open or not.""" - if self._config[CONF_POSITIONING_MODE] != CONF_MODE_YES: + if self._config[CONF_POSITIONING_MODE] != CONF_MODE_POSITION: return None else: return self._current_cover_position == 100 @@ -134,7 +132,7 @@ class LocaltuyaCover(LocalTuyaEntity, CoverEntity): @property def is_closed(self): """Return if the cover is closed or not.""" - if self._config[CONF_POSITIONING_MODE] != CONF_MODE_YES: + if self._config[CONF_POSITIONING_MODE] != CONF_MODE_POSITION: return None else: return self._current_cover_position == 0 @@ -159,7 +157,7 @@ class LocaltuyaCover(LocalTuyaEntity, CoverEntity): self._current_cover_position = 50 _LOGGER.debug("Done") - elif self._config[CONF_POSITIONING_MODE] == CONF_MODE_YES: + elif self._config[CONF_POSITIONING_MODE] == CONF_MODE_POSITION: converted_position = int(kwargs[ATTR_POSITION]) if converted_position in range(0, 101) and self.has_config(CONF_SETPOS): self._device.set_dps(converted_position, self._config[CONF_SETPOS]) diff --git a/custom_components/localtuya/translations/en.json b/custom_components/localtuya/translations/en.json index 83bad7c..88dfe70 100644 --- a/custom_components/localtuya/translations/en.json +++ b/custom_components/localtuya/translations/en.json @@ -49,8 +49,8 @@ "open_cmd": "Open Command", "close_cmd": "Close Command", "positioning_mode": "Positioning mode", - "currpos_dps": "Current Position dps (Required only if Positioning Mode is 'yes')", - "setpos_dps": "Set Position dps (Required only if Positioning Mode is 'yes')", + "currpos_dps": "Current Position dps (Required only if Positioning Mode is 'position')", + "setpos_dps": "Set Position dps (Required only if Positioning Mode is 'position')", "span_time": "Time for full opening, in secs. (Optional, required only if Positioning Mode is 'fake')", "unit_of_measurement": "Unit of Measurement", "device_class": "Device Class", @@ -85,8 +85,8 @@ "open_cmd": "Open Command", "close_cmd": "Close Command", "positioning_mode": "Positioning mode", - "currpos_dps": "Current Position dps (Required only if Positioning Mode is 'yes')", - "setpos_dps": "Set Position dps (Required only if Positioning Mode is 'yes')", + "currpos_dps": "Current Position dps (Required only if Positioning Mode is 'position')", + "setpos_dps": "Set Position dps (Required only if Positioning Mode is 'position')", "span_time": "Time for full opening, in secs. (Optional, required only if Positioning Mode is 'fake')", "unit_of_measurement": "Unit of Measurement", "device_class": "Device Class",