Skip to content

Commit

Permalink
Merge pull request #23 from KiraPC/dev
Browse files Browse the repository at this point in the history
HACS Validation
  • Loading branch information
KiraPC authored Oct 11, 2023
2 parents dbb64f6 + 92d84fb commit ebcf1c0
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 17 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/hacs_check.yaml
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 5 additions & 9 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 4 additions & 2 deletions custom_components/switchbotremote/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
CONF_TEMP_MAX,
CONF_TEMP_STEP,
CONF_HVAC_MODES,
CONF_OVERRIDE_OFF_COMMAND,
)
from .config_flow import DEFAULT_HVAC_MODES

Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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:
Expand All @@ -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}",
Expand Down
2 changes: 2 additions & 0 deletions custom_components/switchbotremote/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
CONF_WITH_TEMPERATURE,
CONF_ON_COMMAND,
CONF_OFF_COMMAND,
CONF_OVERRIDE_OFF_COMMAND,
)

DEFAULT_HVAC_MODES = [
Expand Down Expand Up @@ -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"}}),
Expand Down
1 change: 1 addition & 0 deletions custom_components/switchbotremote/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions custom_components/switchbotremote/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down
3 changes: 2 additions & 1 deletion custom_components/switchbotremote/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion custom_components/switchbotremote/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion custom_components/switchbotremote/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down

0 comments on commit ebcf1c0

Please sign in to comment.