Fixed postlund's remarks

This commit is contained in:
rospogrigio
2020-10-02 09:48:17 +02:00
committed by rospogrigio
parent d9a9490535
commit dee728d008
4 changed files with 22 additions and 18 deletions

View File

@@ -22,8 +22,8 @@ localtuya:
id: 2 id: 2
open_close_cmds: ["on_off","open_close"] # Optional, default: "on_off" open_close_cmds: ["on_off","open_close"] # Optional, default: "on_off"
positioning_mode: ["none","position","fake"] # Optional, default: "none" positioning_mode: ["none","position","fake"] # Optional, default: "none"
currpos_dps: 3 # Optional, required only for "position" mode currpos_dp: 3 # Optional, required only for "position" mode
setpos_dps: 4 # Optional, required only for "position" mode setpos_dp: 4 # Optional, required only for "position" mode
span_time: 25 # Full movement time: Optional, required only for "fake" mode span_time: 25 # Full movement time: Optional, required only for "fake" mode
- platform: fan - platform: fan

View File

@@ -16,8 +16,8 @@ CONF_VOLTAGE = "voltage"
# cover # cover
CONF_OPENCLOSE_CMDS = "open_close_cmds" CONF_OPENCLOSE_CMDS = "open_close_cmds"
CONF_POSITIONING_MODE = "positioning_mode" CONF_POSITIONING_MODE = "positioning_mode"
CONF_CURRPOS = "currpos_dps" CONF_CURRENT_POSITION_DP = "currpos_dp"
CONF_SETPOS = "setpos_dps" CONF_SET_POSITION_DP = "setpos_dp"
CONF_SPAN_TIME = "span_time" CONF_SPAN_TIME = "span_time"
# sensor # sensor

View File

@@ -17,8 +17,8 @@ from homeassistant.const import CONF_ID
from .const import ( from .const import (
CONF_OPENCLOSE_CMDS, CONF_OPENCLOSE_CMDS,
CONF_CURRPOS, CONF_CURRENT_POSITION_DP,
CONF_SETPOS, CONF_SET_POSITION_DP,
CONF_POSITIONING_MODE, CONF_POSITIONING_MODE,
CONF_SPAN_TIME, CONF_SPAN_TIME,
) )
@@ -47,8 +47,8 @@ def flow_schema(dps):
vol.Optional(CONF_POSITIONING_MODE, default=DEFAULT_POSITIONING_MODE): vol.In( vol.Optional(CONF_POSITIONING_MODE, default=DEFAULT_POSITIONING_MODE): vol.In(
[COVER_MODE_NONE, COVER_MODE_POSITION, COVER_MODE_FAKE] [COVER_MODE_NONE, COVER_MODE_POSITION, COVER_MODE_FAKE]
), ),
vol.Optional(CONF_CURRPOS): vol.In(dps), vol.Optional(CONF_CURRENT_POSITION_DP): vol.In(dps),
vol.Optional(CONF_SETPOS): vol.In(dps), vol.Optional(CONF_SET_POSITION_DP): vol.In(dps),
vol.Optional(CONF_SPAN_TIME, default=DEFAULT_SPAN_TIME): vol.All( vol.Optional(CONF_SPAN_TIME, default=DEFAULT_SPAN_TIME): vol.All(
vol.Coerce(float), vol.Range(min=1.0, max=300.0) vol.Coerce(float), vol.Range(min=1.0, max=300.0)
), ),
@@ -155,8 +155,10 @@ class LocaltuyaCover(LocalTuyaEntity, CoverEntity):
elif self._config[CONF_POSITIONING_MODE] == COVER_MODE_POSITION: elif self._config[CONF_POSITIONING_MODE] == COVER_MODE_POSITION:
converted_position = int(kwargs[ATTR_POSITION]) converted_position = int(kwargs[ATTR_POSITION])
if 0 <= converted_position <= 100 and self.has_config(CONF_SETPOS): if 0 <= converted_position <= 100 and self.has_config(CONF_SET_POSITION_DP):
self._device.set_dps(converted_position, self._config[CONF_SETPOS]) self._device.set_dps(
converted_position, self._config[CONF_SET_POSITION_DP]
)
def open_cover(self, **kwargs): def open_cover(self, **kwargs):
"""Open the cover.""" """Open the cover."""
@@ -176,7 +178,9 @@ class LocaltuyaCover(LocalTuyaEntity, CoverEntity):
def status_updated(self): def status_updated(self):
"""Device status was updated.""" """Device status was updated."""
self._state = self.dps(self._dps_id) self._state = self.dps(self._dps_id)
if self.has_config(CONF_CURRPOS): if self.has_config(CONF_CURRENT_POSITION_DP):
self._current_cover_position = self.dps(self._config[CONF_CURRPOS]) self._current_cover_position = self.dps(
self._config[CONF_CURRENT_POSITION_DP]
)
else: else:
self._current_cover_position = 50 self._current_cover_position = 50

View File

@@ -48,9 +48,9 @@
"voltage": "Voltage", "voltage": "Voltage",
"open_close_cmds": "Open/Close Commands", "open_close_cmds": "Open/Close Commands",
"positioning_mode": "Positioning mode", "positioning_mode": "Positioning mode",
"currpos_dps": "Current Position dps (Required only if Positioning Mode is 'position')", "currpos_dp": "Current Position (when Position mode is *position*)",
"setpos_dps": "Set Position dps (Required only if Positioning Mode is 'position')", "setpos_dp": "Set Position (when Position Mode is *position*)",
"span_time": "Time for full opening, in secs. (Optional, required only if Positioning Mode is 'fake')", "span_time": "Full opening time, in secs. (when Position Mode is fake*)",
"unit_of_measurement": "Unit of Measurement", "unit_of_measurement": "Unit of Measurement",
"device_class": "Device Class", "device_class": "Device Class",
"scaling": "Scaling Factor", "scaling": "Scaling Factor",
@@ -83,9 +83,9 @@
"voltage": "Voltage", "voltage": "Voltage",
"open_close_cmds": "Open/Close Commands", "open_close_cmds": "Open/Close Commands",
"positioning_mode": "Positioning mode", "positioning_mode": "Positioning mode",
"currpos_dps": "Current Position dps (Required only if Positioning Mode is 'position')", "currpos_dp": "Current Position (for *position* mode only)",
"setpos_dps": "Set Position dps (Required only if Positioning Mode is 'position')", "setpos_dp": "Set Position (for *position* mode only)",
"span_time": "Time for full opening, in secs. (Optional, required only if Positioning Mode is 'fake')", "span_time": "Full opening time, in secs. (for *fake* mode only)",
"unit_of_measurement": "Unit of Measurement", "unit_of_measurement": "Unit of Measurement",
"device_class": "Device Class", "device_class": "Device Class",
"scaling": "Scaling Factor", "scaling": "Scaling Factor",