Skip to content

Commit

Permalink
Add switch stop for covers #215
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed May 3, 2024
1 parent 371c688 commit 77a542a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 111 deletions.
1 change: 1 addition & 0 deletions custom_components/localtuya/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
CONF_POSITIONING_MODE = "positioning_mode"
CONF_CURRENT_POSITION_DP = "current_position_dp"
CONF_SET_POSITION_DP = "set_position_dp"
CONF_STOP_SWITCH_DP = "stop_switch_dp"
CONF_POSITION_INVERTED = "position_inverted"
CONF_SPAN_TIME = "span_time"

Expand Down
1 change: 1 addition & 0 deletions custom_components/localtuya/core/ha_entities/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ class DPCode(StrEnum):
SWITCH_SAVE_ENERGY = "switch_save_energy"
SWITCH_SOUND = "switch_sound" # Voice switch
SWITCH_SPRAY = "switch_spray" # Spraying switch
SWITCH_STOP = "switch_stop"
SWITCH_TYPE_1 = "switch_type_1"
SWITCH_TYPE_2 = "switch_type_2"
SWITCH_TYPE_3 = "switch_type_3"
Expand Down
8 changes: 7 additions & 1 deletion custom_components/localtuya/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
CONF_POSITIONING_MODE,
CONF_SET_POSITION_DP,
CONF_SPAN_TIME,
CONF_STOP_SWITCH_DP,
)


Expand Down Expand Up @@ -78,6 +79,7 @@ def flow_schema(dps):
vol.Optional(CONF_SPAN_TIME, default=DEFAULT_SPAN_TIME): vol.All(
vol.Coerce(float), vol.Range(min=1.0, max=300.0)
),
vol.Optional(CONF_STOP_SWITCH_DP): _col_to_select(dps, is_dps=True),
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
}

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

@property
def supported_features(self):
Expand Down Expand Up @@ -230,7 +233,10 @@ async def async_close_cover(self, **kwargs):
async def async_stop_cover(self, **kwargs):
"""Stop the cover."""
self.debug("Launching command %s to cover ", self._stop_cmd)
await self._device.set_dp(self._stop_cmd, self._dp_id)
command = {self._dp_id: self._stop_cmd}
if self._stop_switch is not None:
command[self._stop_switch] = True
await self._device.set_dps(command)
self.update_state(STATE_STOPPED)

def status_restored(self, stored_state):
Expand Down
111 changes: 1 addition & 110 deletions custom_components/localtuya/translations/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,116 +139,7 @@
"data": {
"templates": "اختيار القالب"
}
},
"configure_entity": {
"title": "Configure entity",
"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.",
"data": {
"id": "DP ID",
"friendly_name": "Friendly name for Entity",
"current": "Current",
"current_consumption": "Current Consumption",
"voltage": "Voltage",
"commands_set": "Open_Close_Stop Commands Set",
"positioning_mode": "Positioning mode",
"current_position_dp": "Current Position (for *position* mode only)",
"set_position_dp": "Set Position (for *position* mode only)",
"position_inverted": "Invert 0-100 position (for *position* mode only)",
"span_time": "Full opening time, in secs. (for *timed* mode only)",
"unit_of_measurement": "(Optional) Unit of Measurement",
"device_class": "(Optional) Device Class",
"state_class": "(Optional) State Class",
"scaling": "(Optional) Scaling Factor",
"state_on": "On Value",
"state_off": "Off Value",
"powergo_dp": "Power DP (usually 25 or 2)",
"idle_status_value": "Idle Status (comma-separated)",
"returning_status_value": "Returning Status (comma-separated)",
"docked_status_value": "Docked Status (comma-separated)",
"fault_dp": "Fault DP (usually 11)",
"battery_dp": "Battery status DP (usually 14)",
"mode_dp": "Mode DP (usually 27)",
"modes": "Modes list",
"return_mode": "Return home mode",
"fan_speed_dp": "(Optional) Fan speeds DP",
"fan_speeds": "Fan speeds list (comma-separated)",
"clean_time_dp": "Clean Time DP (usually 33)",
"clean_area_dp": "Clean Area DP (usually 32)",
"clean_record_dp": "Clean Record DP (usually 34)",
"locate_dp": "Locate DP (usually 31)",
"pause_dp":"Pause DP",
"paused_state": "Pause state (pause, paused, etc)",
"stop_status": "Stop status",
"brightness": "Brightness (only for white color)",
"brightness_lower": "Brightness Lower Value",
"brightness_upper": "Brightness Upper Value",
"color_temp": "Color Temperature",
"color_temp_reverse": "Reverse Color Temperature?",
"color": "Color",
"color_mode": "Color Mode aka Work Mode",
"color_temp_min_kelvin": "Minimum Color Temperature in K",
"color_temp_max_kelvin": "Maximum Color Temperature in K",
"music_mode": "Music mode available?",
"scene": "Scene",
"scene_values": "(Optional) Scene values",
"select_options": "Select options values",
"fan_speed_control": "Fan Speed Control DP",
"fan_oscillating_control": "Fan Oscillating Control DP",
"fan_speed_min": "minimum fan speed integer",
"fan_speed_max": "maximum fan speed integer",
"fan_speed_ordered_list": "Fan speed list (overrides speed min/max), separate entries by comma ','",
"fan_direction":"Fan Direction DP",
"fan_direction_forward": "Forward DP string",
"fan_direction_reverse": "Reverse DP string",
"fan_dps_type": "DP value type",
"current_temperature_dp": "Current Temperature",
"target_temperature_dp": "Target Temperature",
"temperature_step": "(Optional) Temperature Step",
"min_temperature": "Min Temperature",
"max_temperature": "Max Temperature",
"precision": "Precision (optional, for DPs values)",
"target_precision": "Target Precision (optional, for DP values)",
"temperature_unit": "(Optional) Temperature Unit",
"hvac_mode_dp": "(Optional) HVAC Mode DP",
"hvac_mode_set": "(Optional) HVAC Modes",
"hvac_add_off": "(Optional) Include `OFF` in HVAC Modes",
"hvac_action_dp": "(Optional) HVAC Current Action DP",
"hvac_action_set": "(Optional) HVAC Actions",
"preset_dp": "(Optional) Presets DP",
"preset_set": "(Optional) Presets",
"fan_speed_list": "(Optional) Fan supported speeds, separate entries by comma ','",
"eco_dp": "(Optional) Eco DP",
"eco_value": "(Optional) Eco value",
"heuristic_action": "(Optional) Enable heuristic action",
"dps_default_value": "(Optional) Default value when un-initialised",
"restore_on_reconnect": "Restore the last value set in Home Assistant after lost connection?",
"min_value": "Minimum Value",
"max_value": "Maximum Value",
"step_size": "Minimum increment between numbers",
"is_passive_entity": "Passive entity? (requires integration to send initialisation value)",
"entity_category": "Show the entity in this category",
"humidifier_available_modes": "(Optional) Available modes in the device",
"humidifier_current_humidity_dp": "(Optional) Current Humidity DP",
"humidifier_mode_dp": "(Optional) Set mode DP",
"humidifier_set_humidity_dp": "(Optional) Set Humidity DP",
"min_humidity": "Set the minimum supported humidity",
"max_humidity": "Set the maximum supported humidity",
"alarm_supported_states": "States supported by the device",
"receive_dp":"Receiving signals DP. (default is 202)",
"key_study_dp":"(Optional) Key Study DP (usually 7)"
},
"data_description": {
"hvac_mode_set":"Each line represents [ hvac_mode: device_value ] [Supported HVAC Modes](https://developers.home-assistant.io/docs/core/entity/climate/#hvac-modes)",
"hvac_action_set":"Each line represents [ hvac_action: device_value ] [Supported HVAC Actions](https://developers.home-assistant.io/docs/core/entity/climate/#hvac-action)",
"preset_set":"Each line represents [ device_value: friendly name ]",
"scene_values":"Each line represents [ device_value: friendly name ]",
"select_options":"Each line represents [ device_value: friendly name ]",
"alarm_supported_states":"Each line represents [ supported state: device value ] [Supported States](https://developers.home-assistant.io/docs/core/entity/alarm-control-panel/#states)",
"humidifier_available_modes":"Each line represents [ device_value: friendly name ]",
"device_class": "Find out more about [Device Classes](https://www.home-assistant.io/docs/configuration/customizing-devices/#device-class)",
"state_class": "Find out more about [State Classes](https://developers.home-assistant.io/docs/core/entity/sensor/#available-state-classes)"
}
}
}
}
},
"title": "LocalTuya"
Expand Down
1 change: 1 addition & 0 deletions custom_components/localtuya/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
"positioning_mode": "Positioning mode",
"current_position_dp": "Current Position (for *position* mode only)",
"set_position_dp": "Set Position (for *position* mode only)",
"stop_switch_dp": "(Optional) Stop switch (if the cover has continue command?)",
"position_inverted": "Invert 0-100 position (for *position* mode only)",
"span_time": "Full opening time, in secs. (for *timed* mode only)",
"unit_of_measurement": "(Optional) Unit of Measurement",
Expand Down
1 change: 1 addition & 0 deletions custom_components/localtuya/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
"positioning_mode": "Positioning mode",
"current_position_dp": "Current Position (for *position* mode only)",
"set_position_dp": "Set Position (for *position* mode only)",
"stop_switch_dp": "(Optional) Stop switch (if the cover has continue command?)",
"position_inverted": "Invert 0-100 position (for *position* mode only)",
"span_time": "Full opening time, in secs. (for *timed* mode only)",
"unit_of_measurement": "(Optional) Unit of Measurement",
Expand Down
1 change: 1 addition & 0 deletions custom_components/localtuya/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
"positioning_mode": "Tryb pozycjonowania",
"current_position_dp": "Bieżąca pozycja (tylko dla trybu *pozycjonowania*)",
"set_position_dp": "Ustaw pozycję (tylko dla trybu *pozycjonowania*)",
"stop_switch_dp": "(Optional) Stop switch (if the cover has continue command?)",
"position_inverted": "Odwróć pozycję 0-100 (tylko dla trybu *pozycjonowania*)",
"span_time": "Pełny czas otwarcia, w sekundach. (tylko dla trybu *czasowego*)",
"unit_of_measurement": "Jednostka miary (opcjonalnie)",
Expand Down
1 change: 1 addition & 0 deletions custom_components/localtuya/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
"positioning_mode": "Positioning mode",
"current_position_dp": "Current Position (for *position* mode only)",
"set_position_dp": "Set Position (for *position* mode only)",
"stop_switch_dp": "(Optional) Stop switch (if the cover has continue command?)",
"position_inverted": "Invert 0-100 position (for *position* mode only)",
"span_time": "Full opening time, in secs. (for *timed* mode only)",
"unit_of_measurement": "(Optional) Unit of Measurement",
Expand Down

0 comments on commit 77a542a

Please sign in to comment.