diff --git a/.github/workflows/hacs_check.yaml b/.github/workflows/hacs_check.yaml new file mode 100644 index 0000000..8369e39 --- /dev/null +++ b/.github/workflows/hacs_check.yaml @@ -0,0 +1,17 @@ +name: HACS Action + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + hacs: + name: HACS Action + runs-on: "ubuntu-latest" + steps: + - name: HACS Action + uses: "hacs/action@main" + with: + category: "integration" \ No newline at end of file diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index c422ec3..afbde1a 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -1,18 +1,14 @@ -name: Validate +name: Validate with hassfest on: push: pull_request: schedule: - - cron: "0 0 * * *" - workflow_dispatch: + - cron: '0 0 * * *' jobs: - validate-hacs: + validate: runs-on: "ubuntu-latest" steps: - - uses: "actions/checkout@v3" - - name: HACS validation - uses: "hacs/action@main" - with: - category: "integration" + - uses: "actions/checkout@v3" + - uses: "home-assistant/actions/hassfest@master" \ No newline at end of file diff --git a/custom_components/switchbotremote/climate.py b/custom_components/switchbotremote/climate.py index 574d633..fcfd093 100644 --- a/custom_components/switchbotremote/climate.py +++ b/custom_components/switchbotremote/climate.py @@ -27,6 +27,7 @@ CONF_TEMP_MAX, CONF_TEMP_STEP, CONF_HVAC_MODES, + CONF_OVERRIDE_OFF_COMMAND, ) from .config_flow import DEFAULT_HVAC_MODES @@ -79,6 +80,7 @@ def __init__(self, sb: SupportedRemote, options: dict = {}) -> None: self._max_temp = options.get(CONF_TEMP_MAX, DEFAULT_MAX_TEMP) self._min_temp = options.get(CONF_TEMP_MIN, DEFAULT_MIN_TEMP) self._power_sensor = options.get(CONF_POWER_SENSOR, None) + self._override_off_command = options.get(CONF_OVERRIDE_OFF_COMMAND, True) self._fan_mode = FAN_AUTO self._fan_modes = [ @@ -207,7 +209,7 @@ def set_temperature(self, **kwargs): def set_hvac_mode(self, hvac_mode): """Set new target hvac mode.""" - if hvac_mode == HVACMode.OFF: + if hvac_mode == HVACMode.OFF and self._override_off_command: self.sb.turn("off") self._is_on = False else: @@ -222,7 +224,7 @@ def set_fan_mode(self, fan_mode): self._update_remote() def _update_remote(self): - if (self._hvac_mode != HVACMode.OFF): + if (self._hvac_mode != HVACMode.OFF and self._override_off_command): self.sb.command( "setAll", f"{self.target_temperature},{HVAC_REMOTE_MODES[self.hvac_mode]},{FAN_REMOTE_MODES[self.fan_mode]},{self.power_state}", diff --git a/custom_components/switchbotremote/config_flow.py b/custom_components/switchbotremote/config_flow.py index ba00cc4..b92f623 100644 --- a/custom_components/switchbotremote/config_flow.py +++ b/custom_components/switchbotremote/config_flow.py @@ -42,6 +42,7 @@ CONF_WITH_TEMPERATURE, CONF_ON_COMMAND, CONF_OFF_COMMAND, + CONF_OVERRIDE_OFF_COMMAND, ) DEFAULT_HVAC_MODES = [ @@ -77,6 +78,7 @@ vol.Optional(CONF_POWER_SENSOR, description={"suggested_value": x.get(CONF_POWER_SENSOR)}): selector({"entity": {"filter": {"domain": ["binary_sensor", "input_boolean", "light", "sensor", "switch"]}}}), vol.Optional(CONF_TEMPERATURE_SENSOR, description={"suggested_value": x.get(CONF_TEMPERATURE_SENSOR)}): selector({"entity": {"filter": {"domain": "sensor"}}}), vol.Optional(CONF_HUMIDITY_SENSOR, description={"suggested_value": x.get(CONF_HUMIDITY_SENSOR)}): selector({"entity": {"filter": {"domain": "sensor"}}}), + vol.Optional(CONF_OVERRIDE_OFF_COMMAND, default=x.get(CONF_OVERRIDE_OFF_COMMAND, True)): bool, vol.Optional(CONF_TEMP_MIN, default=x.get(CONF_TEMP_MIN, 16)): int, vol.Optional(CONF_TEMP_MAX, default=x.get(CONF_TEMP_MAX, 30)): int, vol.Optional(CONF_TEMP_STEP, default=x.get(CONF_TEMP_STEP, 1.0)): selector({"number": {"min": 0.1, "max": 2.0, "step": 0.1, "mode": "slider"}}), diff --git a/custom_components/switchbotremote/const.py b/custom_components/switchbotremote/const.py index 12dc041..82cb7e7 100644 --- a/custom_components/switchbotremote/const.py +++ b/custom_components/switchbotremote/const.py @@ -18,6 +18,7 @@ CONF_WITH_TEMPERATURE = "with_temperature" CONF_ON_COMMAND = "on_command" CONF_OFF_COMMAND = "off_command" +CONF_OVERRIDE_OFF_COMMAND = "override_off_command" """Supported Devices""" DIY_AIR_CONDITIONER_TYPE = "DIY Air Conditioner" diff --git a/custom_components/switchbotremote/manifest.json b/custom_components/switchbotremote/manifest.json index 6582151..198ffa6 100644 --- a/custom_components/switchbotremote/manifest.json +++ b/custom_components/switchbotremote/manifest.json @@ -5,12 +5,12 @@ "@KiraPC", "@joshepw" ], - "dependencies": [], - "integration_type": "hub", "config_flow": true, + "dependencies": [], "documentation": "https://github.com/KiraPC/ha-switchbot-remote#readme", - "issue_tracker": "https://github.com/KiraPC/ha-switchbot-remote/issues", + "integration_type": "hub", "iot_class": "cloud_push", + "issue_tracker": "https://github.com/KiraPC/ha-switchbot-remote/issues", "requirements": [ "pyhumps" ], diff --git a/custom_components/switchbotremote/translations/en.json b/custom_components/switchbotremote/translations/en.json index cbbbb6e..48c321e 100644 --- a/custom_components/switchbotremote/translations/en.json +++ b/custom_components/switchbotremote/translations/en.json @@ -49,7 +49,8 @@ "with_brightness": "Enable brightness control buttons", "with_temperature": "Enable temperature color buttons", "on_command": "On/Off button name", - "off_command": "Name of the Off button in case of independent operation" + "off_command": "Name of the Off button in case of independent operation", + "override_off_command": "Override the native 'off' command" } } } diff --git a/custom_components/switchbotremote/translations/es.json b/custom_components/switchbotremote/translations/es.json index f9eecbb..a52a122 100644 --- a/custom_components/switchbotremote/translations/es.json +++ b/custom_components/switchbotremote/translations/es.json @@ -49,7 +49,8 @@ "with_brightness": "Habilitar botones de control brillo", "with_temperature": "Habilitar botones de color de temperatura", "on_command": "Nombre del botón On/Off", - "off_command": "Nombre del botón Off en caso de accionar independiente" + "off_command": "Nombre del botón Off en caso de accionar independiente", + "override_off_command": "Reemplazar el comando de apagado nativo" } } } diff --git a/custom_components/switchbotremote/translations/it.json b/custom_components/switchbotremote/translations/it.json index b939696..c09dacf 100644 --- a/custom_components/switchbotremote/translations/it.json +++ b/custom_components/switchbotremote/translations/it.json @@ -49,7 +49,8 @@ "with_brightness": "Abilita i pulsanti di controllo della luminosità", "with_temperature": "Abilita i pulsanti colorati della temperatura", "on_command": "Nome del pulsante di accensione/spegnimento", - "off_command": "Nome del pulsante Off in caso di funzionamento indipendente" + "off_command": "Nome del pulsante Off in caso di funzionamento indipendente", + "override_off_command": "Ignora il comando di spegnimento nativo" } } }