Skip to content

Commit

Permalink
feat: rename maintenance settings -> installer settings
Browse files Browse the repository at this point in the history
  • Loading branch information
bj00rn committed Nov 15, 2024
1 parent a32ca02 commit 37e0907
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 74 deletions.
26 changes: 17 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,24 @@ Switch | Description | State attributes

## Services

### Normal operation

Control normal operation of the unit
Name | Description | Fields
-- | -- | --
`set_cooling_mode` | Set cooling mode | device: `str` target device, value: `integer` (0=On, 1=Off)
`set_fireplace_mode` | Set fireplace mode | device: `str` target device, value: `integer` (0=On, 1=Off)
`set_temperature_mode` | Set temperature mode | device: `str` target device, value: `integer` (0=Normal,1=Economy,2=Cool)
`set_ventilation_mode` | Set ventilation mode | device: `str` target device, value: `integer` (0=Home,1=Away,2=Boost)
`set_system_active_mode` | Set system active mode. (Maintenance settings must be enabled) | device: `str` target device, value: `integer` (0=Off,1=On,2=Reset)
`set_target_temperature_normal` | Set target temperature for normal temperature mode. (Maintenance settings must be enabled) | device: `str` target device, value: `number` (temperature 10-30 degrees celcius)
`set_target_temperature_cool` | Set target temperature for cool temperature mode. (Maintenance settings must be enabled) | device: `str` target device, value: `number` (temperature 10-30 degrees celcius)
`set_target_temperature_economy` | Set target temperature for economy temperature mode. (Maintenance settings must be enabled) | device: `str` target device, value: `number` (temperature 10-30 degrees celcius)

### Installer settings
Alter installer settings of the unit, Installer settings must be enabled.
Name | Description | Fields
-- | -- | --
`set_system_active_mode` | Set system active mode`*`| device: `str` target device, value: `integer` (0=Off,1=On,2=Reset)
`set_target_temperature_normal` | Set target temperature for normal temperature mode`*`| device: `str` target device, value: `number` (temperature 10-30 degrees celcius)
`set_target_temperature_cool` | Set target temperature for cool temperature mode`*`| device: `str` target device, value: `number` (temperature 10-30 degrees celcius)
`set_target_temperature_economy` | Set target temperature for economy temperature mode`*`| device: `str` target device, value: `number` (temperature 10-30 degrees celcius)

## Experimental features

Expand Down Expand Up @@ -134,8 +142,8 @@ Setting | Description | Default
Name | System name. Must be unique. |
Websocket IP | IP adress of the HRV system on the local WIFI network |
Port | Port number for websocket connection | 3001
Enable maintenance settings | Enable altering HRV system configuration set by the installer from Home Assistant. Don't alter these settings unless you know what you are doing | False
Maintenance password | Maintenance password. Required for maintenance settings |
Enable installer settings | Altering HRV system configuration set by the installer from Home Assistant. Don't alter these settings unless you know what you are doing | False
Installer password | Installer password. Required for installer settings |

## Troubleshooting

Expand All @@ -146,9 +154,9 @@ Maintenance password | Maintenance password. Required for maintenance settings
* Confirm websocket port by connecting to the UI using a browser and take note of websocket port using debug console in browser.
* The system HRV can only handle a few connected clients. Shut down any additional clients/browsers and try again.

### I can't modify maintenance settings
* Ensure maintenance settings are enabled in integration configuration
* Ensure maintenace password is correct
### I can't modify installer settings
* Ensure installer settings are enabled in integration configuration
* Ensure installer password is correct

### Contributing

Expand Down
51 changes: 34 additions & 17 deletions custom_components/saleryd_hrv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
type SalerydLokeConfigurationEntry = ConfigEntry[SalerydLokeDataUpdateCoordinator]

from .const import (
CONF_ENABLE_MAINTENANCE_SETTINGS,
CONF_MAINTENANCE_PASSWORD,
CONF_ENABLE_INSTALLER_SETTINGS,
CONF_INSTALLER_PASSWORD,
CONF_VALUE,
CONF_WEBSOCKET_IP,
CONF_WEBSOCKET_PORT,
CONFIG_VERSION,
DEFAULT_NAME,
DEPRECATED_CONF_ENABLE_MAINTENANCE_SETTINGS,
DEPRECATED_CONF_MAINTENANCE_PASSWORD,
DOMAIN,
LOGGER,
PLATFORMS,
Expand Down Expand Up @@ -61,8 +63,8 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if entry.version is None or entry.version < 2:
new_data = entry.data.copy()
new_data |= {
CONF_ENABLE_MAINTENANCE_SETTINGS: False,
CONF_MAINTENANCE_PASSWORD: None,
CONF_ENABLE_INSTALLER_SETTINGS: False,
CONF_INSTALLER_PASSWORD: None,
}

LOGGER.info("Upgrading entry to version 2")
Expand All @@ -77,6 +79,21 @@ async def async_migrate_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unique_id=unique_id,
)

if entry.version is None or entry.version < 4:
new_data = entry.data.copy()
new_data[CONF_ENABLE_INSTALLER_SETTINGS] = new_data.pop(
DEPRECATED_CONF_ENABLE_MAINTENANCE_SETTINGS
)
new_data[CONF_INSTALLER_PASSWORD] = new_data.pop(
DEPRECATED_CONF_MAINTENANCE_PASSWORD
)

hass.config_entries.async_update_entry(
entry,
new_data,
version=4,
)

return True


Expand All @@ -103,15 +120,21 @@ def _get_entry_from_service_data(
def setup_hass_services(hass: HomeAssistant) -> None:
"""Register ingegration services."""

async def control_request(call: ServiceCall, key, authenticate=False):
async def control_request(call: ServiceCall, key, installer_setting=False):
"""Helper for system control calls"""
entry = _get_entry_from_service_data(hass, call.data)
value = call.data.get(CONF_VALUE)
device = call.data.get(CONF_DEVICE)
coordinator: SalerydLokeDataUpdateCoordinator = entry.runtime_data
if authenticate:
maintenance_password = entry.data.get(CONF_MAINTENANCE_PASSWORD)
LOGGER.debug("Unlock maintenance settings control request")
await coordinator.client.send_command("IP", maintenance_password)
if installer_setting:
installer_settings_enabled = entry.data.get(CONF_ENABLE_INSTALLER_SETTINGS)
if not installer_settings_enabled:
raise HomeAssistantError(
"Installer settings not enabled for device %s", device
)
installer_password = entry.data.get(CONF_INSTALLER_PASSWORD)
LOGGER.debug("Sending unlock installer settings control request")
await coordinator.client.send_command("IP", installer_password)

LOGGER.debug("Sending control request %s with payload %s", key, value)
await coordinator.client.send_command(key, value)
Expand Down Expand Up @@ -155,21 +178,15 @@ async def set_target_temperature_economy(call: ServiceCall):
SERVICE_SET_TEMPERATURE_MODE: set_temperature_mode,
}

maintenance_services = {
installer_services = {
SERVICE_SET_SYSTEM_ACTIVE_MODE: set_system_active_mode,
SERVICE_SET_TARGET_TEMPERATURE_COOL: set_target_temperature_cool,
SERVICE_SET_TARGET_TEMPERATURE_ECONOMY: set_target_temperature_economy,
SERVICE_SET_TARGET_TEMPERATURE_NORMAL: set_target_temperature_normal,
}

# register services
for key, fn in services.items():
if hass.services.has_service(DOMAIN, key):
continue
hass.services.async_register(DOMAIN, key, fn)

# register maintenance services
for key, fn in maintenance_services.items():
for key, fn in (services | installer_services).items():
if hass.services.has_service(DOMAIN, key):
continue
hass.services.async_register(DOMAIN, key, fn)
Expand Down
12 changes: 6 additions & 6 deletions custom_components/saleryd_hrv/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import voluptuous as vol

from .const import (
CONF_ENABLE_MAINTENANCE_SETTINGS,
CONF_MAINTENANCE_PASSWORD,
CONF_ENABLE_INSTALLER_SETTINGS,
CONF_INSTALLER_PASSWORD,
CONF_WEBSOCKET_IP,
CONF_WEBSOCKET_PORT,
CONFIG_VERSION,
Expand All @@ -25,8 +25,8 @@
RECONFIG_DATA = {
vol.Required(CONF_WEBSOCKET_IP): str,
vol.Required(CONF_WEBSOCKET_PORT): int,
vol.Optional(CONF_ENABLE_MAINTENANCE_SETTINGS): vol.Coerce(bool),
vol.Optional(CONF_MAINTENANCE_PASSWORD): str,
vol.Optional(CONF_ENABLE_INSTALLER_SETTINGS): vol.Coerce(bool),
vol.Optional(CONF_INSTALLER_PASSWORD): str,
}

CONFIG_DATA = {
Expand Down Expand Up @@ -81,8 +81,8 @@ async def async_step_user(self, user_input=None):
CONF_NAME: DEFAULT_NAME,
CONF_WEBSOCKET_IP: "192.168.1.151",
CONF_WEBSOCKET_PORT: 3001,
CONF_ENABLE_MAINTENANCE_SETTINGS: False,
CONF_MAINTENANCE_PASSWORD: "",
CONF_ENABLE_INSTALLER_SETTINGS: False,
CONF_INSTALLER_PASSWORD: "",
}

return self.async_show_form(
Expand Down
11 changes: 7 additions & 4 deletions custom_components/saleryd_hrv/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ISSUE_URL = "https://github.com/bj00rn/ha-saleryd-ftx/issues"
SUPPORTED_FIRMWARES = ["4.1.5"]
UNSUPPORTED_FIRMWARES = ["4.1.1"]
CONFIG_VERSION = 3
CONFIG_VERSION = 4

# Icons
ICON = "mdi:format-quote-close"
Expand All @@ -26,8 +26,8 @@
CONF_ENABLED = "enabled"
CONF_WEBSOCKET_IP = "websocket_ip"
CONF_WEBSOCKET_PORT = "websocket_port"
CONF_MAINTENANCE_PASSWORD = "maintenance_password"
CONF_ENABLE_MAINTENANCE_SETTINGS = "enable_maintenance_settings"
CONF_INSTALLER_PASSWORD = "installer_password"
CONF_ENABLE_INSTALLER_SETTINGS = "enable_installer_settings"
CONF_VALUE = "value"

# Defaults
Expand Down Expand Up @@ -71,10 +71,13 @@
SERVICE_SET_COOLING_MODE = "set_cooling_mode"
SERVICE_SET_VENTILATION_MODE = "set_ventilation_mode"
SERVICE_SET_TEMPERATURE_MODE = "set_temperature_mode"
SERVICE_UNLOCK_MAINTENANCE_SETTINGS = "unlock_maintenance_settings"
SERVICE_SET_SYSTEM_ACTIVE_MODE = "set_system_active_mode"
SERVICE_SET_TARGET_TEMPERATURE_COOL = "set_target_temperature_cool"
SERVICE_SET_TARGET_TEMPERATURE_NORMAL = "set_target_temperature_normal"
SERVICE_SET_TARGET_TEMPERATURE_ECONOMY = "set_target_temperature_economy"

LOGGER: Logger = getLogger(__package__)

# Deprecated constants kept for migrations
DEPRECATED_CONF_MAINTENANCE_PASSWORD = "maintenance_password"
DEPRECATED_CONF_ENABLE_MAINTENANCE_SETTINGS = "enable_maintenance_settings"
19 changes: 0 additions & 19 deletions custom_components/saleryd_hrv/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,6 @@ set_system_active_mode:
min: 0
max: 2
mode: slider
unlock_maintenance_settings:
name: Unlock maintenance settings
description: Unlock maintenance settings
fields:
device:
name: Device
description: Target device
required: True
selector:
device:
integration: saleryd_hrv
value:
name: Value
description: Maintenance password
example: "6666"
required: true
selector:
text:
type: password
set_target_temperature_normal:
name: Set normal target temperature
description: Set target temperature for normal temperature mode
Expand Down
20 changes: 10 additions & 10 deletions custom_components/saleryd_hrv/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
"config": {
"step": {
"user": {
"description": "Follow instructions in manual to connect the HRV unit to local network and enter connection details below.",
"description": "Follow instructions in manual to connect the HRV unit to local network and enter connection details below",
"data": {
"name": "Name",
"websocket_ip": "IP adress",
"websocket_port": "Port",
"enable_maintenance_settings": "Enable maintenance settings?",
"maintenance_password": "Maintenance password"
"enable_installer_settings": "Enable installer settings?",
"installer_password": "Installer password"
},
"data_description": {
"websocket_ip": "IP adress of the HRV system on the local network",
"websocket_port": "Port. Default is 3001",
"enable_maintenance_settings": "Enable altering HRV system configuration from Home Assistant. Don't alter maintenance settings unless you know what you are doing",
"maintenance_password": "Required for maintenance settings"
"enable_installer_settings": "Enable installer settings?",
"installer_password": "Installer password"
}
},
"reconfigure": {
"description": "Follow instructions in manual to connect the HRV unit to local network and enter connection details below.",
"description": "Follow instructions in manual to connect the HRV unit to local network and enter connection details below",
"data": {
"name": "Name",
"websocket_ip": "IP adress",
"websocket_port": "Port",
"enable_maintenance_settings": "Enable maintenance settings?",
"maintenance_password": "Maintenance password"
"enable_installer_settings": "Enable installer settings?",
"installer_password": "Installer password"
},
"data_description": {
"websocket_ip": "IP adress of the HRV system on the local network",
"websocket_port": "Port. Default is 3001",
"enable_maintenance_settings": "Enable altering HRV system configuration from Home Assistant. Don't alter maintenance settings unless you know what you are doing",
"maintenance_password": "Required for maintenance settings"
"enable_installer_settings": "Alter installer settings from Home Assistant. Don't alter installer settings unless you know what you are doing",
"installer_password": "Required for installer settings"
}
}
},
Expand Down
18 changes: 9 additions & 9 deletions custom_components/saleryd_hrv/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@
"name": "Name",
"websocket_ip": "IP adress",
"websocket_port": "Port",
"enable_maintenance_settings": "Enable maintenance settings?",
"maintenance_password": "Maintenance password"
"enable_installer_settings": "Enable installer settings?",
"installer_password": "Installer password"
},
"data_description": {
"websocket_ip": "IP adress of the HRV system on the local network",
"websocket_port": "Port. Default is 3001",
"enable_maintenance_settings": "Enable altering HRV system configuration from Home Assistant. Don't alter maintenance settings unless you know what you are doing",
"maintenance_password": "Required for maintenance settings"
"enable_installer_settings": "Enable installer settings?",
"installer_password": "Installer password"
}
},
"reconfigure": {
"description": "Follow instructions in manual to connect the HRV unit to local network and enter connection details below.",
"description": "Follow instructions in manual to connect the HRV unit to local network and enter connection details below",
"data": {
"name": "Name",
"websocket_ip": "IP adress",
"websocket_port": "Port",
"enable_maintenance_settings": "Enable maintenance settings?",
"maintenance_password": "Maintenance password"
"enable_installer_settings": "Enable installer settings?",
"installer_password": "Installer password"
},
"data_description": {
"websocket_ip": "IP adress of the HRV system on the local network",
"websocket_port": "Port. Default is 3001",
"enable_maintenance_settings": "Enable altering HRV system configuration from Home Assistant. Don't alter maintenance settings unless you know what you are doing",
"maintenance_password": "Required for maintenance settings"
"enable_installer_settings": "Alter installer settings from Home Assistant. Don't alter installer settings unless you know what you are doing",
"installer_password": "Required for installer settings"
}
}
},
Expand Down

0 comments on commit 37e0907

Please sign in to comment.