Skip to content

Commit 77a542a

Browse files
committedMay 3, 2024·
Add switch stop for covers #215
1 parent 371c688 commit 77a542a

File tree

8 files changed

+14
-111
lines changed

8 files changed

+14
-111
lines changed
 

‎custom_components/localtuya/const.py

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
CONF_POSITIONING_MODE = "positioning_mode"
106106
CONF_CURRENT_POSITION_DP = "current_position_dp"
107107
CONF_SET_POSITION_DP = "set_position_dp"
108+
CONF_STOP_SWITCH_DP = "stop_switch_dp"
108109
CONF_POSITION_INVERTED = "position_inverted"
109110
CONF_SPAN_TIME = "span_time"
110111

‎custom_components/localtuya/core/ha_entities/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ class DPCode(StrEnum):
551551
SWITCH_SAVE_ENERGY = "switch_save_energy"
552552
SWITCH_SOUND = "switch_sound" # Voice switch
553553
SWITCH_SPRAY = "switch_spray" # Spraying switch
554+
SWITCH_STOP = "switch_stop"
554555
SWITCH_TYPE_1 = "switch_type_1"
555556
SWITCH_TYPE_2 = "switch_type_2"
556557
SWITCH_TYPE_3 = "switch_type_3"

‎custom_components/localtuya/cover.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
CONF_POSITIONING_MODE,
2424
CONF_SET_POSITION_DP,
2525
CONF_SPAN_TIME,
26+
CONF_STOP_SWITCH_DP,
2627
)
2728

2829

@@ -78,6 +79,7 @@ def flow_schema(dps):
7879
vol.Optional(CONF_SPAN_TIME, default=DEFAULT_SPAN_TIME): vol.All(
7980
vol.Coerce(float), vol.Range(min=1.0, max=300.0)
8081
),
82+
vol.Optional(CONF_STOP_SWITCH_DP): _col_to_select(dps, is_dps=True),
8183
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
8284
}
8385

@@ -100,6 +102,7 @@ def __init__(self, device, config_entry, switchid, **kwargs):
100102
self._current_cover_position = 0
101103
self._current_state_action = STATE_STOPPED # Default.
102104
self._set_new_position = int | None
105+
self._stop_switch = self._config.get(CONF_STOP_SWITCH_DP, None)
103106

104107
@property
105108
def supported_features(self):
@@ -230,7 +233,10 @@ async def async_close_cover(self, **kwargs):
230233
async def async_stop_cover(self, **kwargs):
231234
"""Stop the cover."""
232235
self.debug("Launching command %s to cover ", self._stop_cmd)
233-
await self._device.set_dp(self._stop_cmd, self._dp_id)
236+
command = {self._dp_id: self._stop_cmd}
237+
if self._stop_switch is not None:
238+
command[self._stop_switch] = True
239+
await self._device.set_dps(command)
234240
self.update_state(STATE_STOPPED)
235241

236242
def status_restored(self, stored_state):

‎custom_components/localtuya/translations/ar.json

+1-110
Original file line numberDiff line numberDiff line change
@@ -139,116 +139,7 @@
139139
"data": {
140140
"templates": "اختيار القالب"
141141
}
142-
},
143-
"configure_entity": {
144-
"title": "Configure entity",
145-
"description": "Please fill out the details for {entity} with type {platform}. All settings (except for `Type` and `ID`) can be changed from the `Configure` page later.",
146-
"data": {
147-
"id": "DP ID",
148-
"friendly_name": "Friendly name for Entity",
149-
"current": "Current",
150-
"current_consumption": "Current Consumption",
151-
"voltage": "Voltage",
152-
"commands_set": "Open_Close_Stop Commands Set",
153-
"positioning_mode": "Positioning mode",
154-
"current_position_dp": "Current Position (for *position* mode only)",
155-
"set_position_dp": "Set Position (for *position* mode only)",
156-
"position_inverted": "Invert 0-100 position (for *position* mode only)",
157-
"span_time": "Full opening time, in secs. (for *timed* mode only)",
158-
"unit_of_measurement": "(Optional) Unit of Measurement",
159-
"device_class": "(Optional) Device Class",
160-
"state_class": "(Optional) State Class",
161-
"scaling": "(Optional) Scaling Factor",
162-
"state_on": "On Value",
163-
"state_off": "Off Value",
164-
"powergo_dp": "Power DP (usually 25 or 2)",
165-
"idle_status_value": "Idle Status (comma-separated)",
166-
"returning_status_value": "Returning Status (comma-separated)",
167-
"docked_status_value": "Docked Status (comma-separated)",
168-
"fault_dp": "Fault DP (usually 11)",
169-
"battery_dp": "Battery status DP (usually 14)",
170-
"mode_dp": "Mode DP (usually 27)",
171-
"modes": "Modes list",
172-
"return_mode": "Return home mode",
173-
"fan_speed_dp": "(Optional) Fan speeds DP",
174-
"fan_speeds": "Fan speeds list (comma-separated)",
175-
"clean_time_dp": "Clean Time DP (usually 33)",
176-
"clean_area_dp": "Clean Area DP (usually 32)",
177-
"clean_record_dp": "Clean Record DP (usually 34)",
178-
"locate_dp": "Locate DP (usually 31)",
179-
"pause_dp":"Pause DP",
180-
"paused_state": "Pause state (pause, paused, etc)",
181-
"stop_status": "Stop status",
182-
"brightness": "Brightness (only for white color)",
183-
"brightness_lower": "Brightness Lower Value",
184-
"brightness_upper": "Brightness Upper Value",
185-
"color_temp": "Color Temperature",
186-
"color_temp_reverse": "Reverse Color Temperature?",
187-
"color": "Color",
188-
"color_mode": "Color Mode aka Work Mode",
189-
"color_temp_min_kelvin": "Minimum Color Temperature in K",
190-
"color_temp_max_kelvin": "Maximum Color Temperature in K",
191-
"music_mode": "Music mode available?",
192-
"scene": "Scene",
193-
"scene_values": "(Optional) Scene values",
194-
"select_options": "Select options values",
195-
"fan_speed_control": "Fan Speed Control DP",
196-
"fan_oscillating_control": "Fan Oscillating Control DP",
197-
"fan_speed_min": "minimum fan speed integer",
198-
"fan_speed_max": "maximum fan speed integer",
199-
"fan_speed_ordered_list": "Fan speed list (overrides speed min/max), separate entries by comma ','",
200-
"fan_direction":"Fan Direction DP",
201-
"fan_direction_forward": "Forward DP string",
202-
"fan_direction_reverse": "Reverse DP string",
203-
"fan_dps_type": "DP value type",
204-
"current_temperature_dp": "Current Temperature",
205-
"target_temperature_dp": "Target Temperature",
206-
"temperature_step": "(Optional) Temperature Step",
207-
"min_temperature": "Min Temperature",
208-
"max_temperature": "Max Temperature",
209-
"precision": "Precision (optional, for DPs values)",
210-
"target_precision": "Target Precision (optional, for DP values)",
211-
"temperature_unit": "(Optional) Temperature Unit",
212-
"hvac_mode_dp": "(Optional) HVAC Mode DP",
213-
"hvac_mode_set": "(Optional) HVAC Modes",
214-
"hvac_add_off": "(Optional) Include `OFF` in HVAC Modes",
215-
"hvac_action_dp": "(Optional) HVAC Current Action DP",
216-
"hvac_action_set": "(Optional) HVAC Actions",
217-
"preset_dp": "(Optional) Presets DP",
218-
"preset_set": "(Optional) Presets",
219-
"fan_speed_list": "(Optional) Fan supported speeds, separate entries by comma ','",
220-
"eco_dp": "(Optional) Eco DP",
221-
"eco_value": "(Optional) Eco value",
222-
"heuristic_action": "(Optional) Enable heuristic action",
223-
"dps_default_value": "(Optional) Default value when un-initialised",
224-
"restore_on_reconnect": "Restore the last value set in Home Assistant after lost connection?",
225-
"min_value": "Minimum Value",
226-
"max_value": "Maximum Value",
227-
"step_size": "Minimum increment between numbers",
228-
"is_passive_entity": "Passive entity? (requires integration to send initialisation value)",
229-
"entity_category": "Show the entity in this category",
230-
"humidifier_available_modes": "(Optional) Available modes in the device",
231-
"humidifier_current_humidity_dp": "(Optional) Current Humidity DP",
232-
"humidifier_mode_dp": "(Optional) Set mode DP",
233-
"humidifier_set_humidity_dp": "(Optional) Set Humidity DP",
234-
"min_humidity": "Set the minimum supported humidity",
235-
"max_humidity": "Set the maximum supported humidity",
236-
"alarm_supported_states": "States supported by the device",
237-
"receive_dp":"Receiving signals DP. (default is 202)",
238-
"key_study_dp":"(Optional) Key Study DP (usually 7)"
239-
},
240-
"data_description": {
241-
"hvac_mode_set":"Each line represents [ hvac_mode: device_value ] [Supported HVAC Modes](https://developers.home-assistant.io/docs/core/entity/climate/#hvac-modes)",
242-
"hvac_action_set":"Each line represents [ hvac_action: device_value ] [Supported HVAC Actions](https://developers.home-assistant.io/docs/core/entity/climate/#hvac-action)",
243-
"preset_set":"Each line represents [ device_value: friendly name ]",
244-
"scene_values":"Each line represents [ device_value: friendly name ]",
245-
"select_options":"Each line represents [ device_value: friendly name ]",
246-
"alarm_supported_states":"Each line represents [ supported state: device value ] [Supported States](https://developers.home-assistant.io/docs/core/entity/alarm-control-panel/#states)",
247-
"humidifier_available_modes":"Each line represents [ device_value: friendly name ]",
248-
"device_class": "Find out more about [Device Classes](https://www.home-assistant.io/docs/configuration/customizing-devices/#device-class)",
249-
"state_class": "Find out more about [State Classes](https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes)"
250-
}
251-
}
142+
}
252143
}
253144
},
254145
"title": "LocalTuya"

‎custom_components/localtuya/translations/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"positioning_mode": "Positioning mode",
158158
"current_position_dp": "Current Position (for *position* mode only)",
159159
"set_position_dp": "Set Position (for *position* mode only)",
160+
"stop_switch_dp": "(Optional) Stop switch (if the cover has continue command?)",
160161
"position_inverted": "Invert 0-100 position (for *position* mode only)",
161162
"span_time": "Full opening time, in secs. (for *timed* mode only)",
162163
"unit_of_measurement": "(Optional) Unit of Measurement",

‎custom_components/localtuya/translations/it.json

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
"positioning_mode": "Positioning mode",
153153
"current_position_dp": "Current Position (for *position* mode only)",
154154
"set_position_dp": "Set Position (for *position* mode only)",
155+
"stop_switch_dp": "(Optional) Stop switch (if the cover has continue command?)",
155156
"position_inverted": "Invert 0-100 position (for *position* mode only)",
156157
"span_time": "Full opening time, in secs. (for *timed* mode only)",
157158
"unit_of_measurement": "(Optional) Unit of Measurement",

‎custom_components/localtuya/translations/pl.json

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
"positioning_mode": "Tryb pozycjonowania",
158158
"current_position_dp": "Bieżąca pozycja (tylko dla trybu *pozycjonowania*)",
159159
"set_position_dp": "Ustaw pozycję (tylko dla trybu *pozycjonowania*)",
160+
"stop_switch_dp": "(Optional) Stop switch (if the cover has continue command?)",
160161
"position_inverted": "Odwróć pozycję 0-100 (tylko dla trybu *pozycjonowania*)",
161162
"span_time": "Pełny czas otwarcia, w sekundach. (tylko dla trybu *czasowego*)",
162163
"unit_of_measurement": "Jednostka miary (opcjonalnie)",

‎custom_components/localtuya/translations/pt-BR.json

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
"positioning_mode": "Positioning mode",
153153
"current_position_dp": "Current Position (for *position* mode only)",
154154
"set_position_dp": "Set Position (for *position* mode only)",
155+
"stop_switch_dp": "(Optional) Stop switch (if the cover has continue command?)",
155156
"position_inverted": "Invert 0-100 position (for *position* mode only)",
156157
"span_time": "Full opening time, in secs. (for *timed* mode only)",
157158
"unit_of_measurement": "(Optional) Unit of Measurement",

0 commit comments

Comments
 (0)
Please sign in to comment.