Skip to content

Commit

Permalink
show configured callback host and port in re-configure dialog (#706)
Browse files Browse the repository at this point in the history
* show configured callback host and port in re-configure dialog

* Keep optional values in config flow

* Add additional steps to make it work

---------

Co-authored-by: SukramJ <[email protected]>
  • Loading branch information
dotlambda and SukramJ authored Aug 25, 2024
1 parent 496ee6a commit 1ebf1a5
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.6.1
rev: v0.6.2
hooks:
- id: ruff
args:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@ un_ignore:
The JSON-RPC Port is used to fetch names and room information from the CCU. The default value is `80`. But if you enable TLS the port `443` will be used. You only have to enter a custom value here if you have set up the JSON-RPC API to be available on a different port.
If you are using Homegear the names are fetched using metadata available via XML-RPC. Hence the JSON-RPC port is irrelevant for Homegear users.
**This value is always empty when the integration gets reconfigured.**
**To reset the JSON-RPC Port it must be set to 0.**

### callback_host and callback_port

These two options are required for _special_ network environments. If for example Home Assistant is running within a Docker container and detects its own IP to be within the Docker network, the CCU won't be able to establish the connection to Home Assistant. In this case you have to specify which address and port the CCU should connect to. This may require forwarding connections on the Docker host machine to the relevant container.
**These values are always empty when the integration is reconfigured.**

**To reset the callback_host it must be set to one blank character.**
**To reset the callback_port it must be set to 0.**

## System variables

Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version 1.65.0 (2024-08-20)
# Version 1.65.0 (2024-08-25)

- Bump hahomematic to 2024.8.12
- Add additional validation on config parameters
Expand All @@ -14,6 +14,7 @@
- Use only relevant IP for XmlRPC Server listening on
- Add HEATING_COOLING translations
- Clear cache on schema migration
- Keep optional values in config flow
- Load al paramset descriptions into cache
- Make unignore configurable in the UI
- Move mapping access to control config
Expand Down
18 changes: 14 additions & 4 deletions custom_components/homematicip_local/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
NumberSelector(NumberSelectorConfig(mode=NumberSelectorMode.BOX, min=1, max=65535)),
vol.Coerce(int),
)
PORT_SELECTOR_OPTIONAL = vol.All(
NumberSelector(NumberSelectorConfig(mode=NumberSelectorMode.BOX, min=0, max=65535)),
vol.Coerce(int),
)
SCAN_INTERVAL_SELECTOR = vol.All(
NumberSelector(
NumberSelectorConfig(
Expand All @@ -118,9 +122,15 @@ def get_domain_schema(data: ConfigType) -> Schema:
vol.Required(
CONF_VERIFY_TLS, default=data.get(CONF_VERIFY_TLS, False)
): BOOLEAN_SELECTOR,
vol.Optional(CONF_CALLBACK_HOST): TEXT_SELECTOR,
vol.Optional(CONF_CALLBACK_PORT): PORT_SELECTOR,
vol.Optional(CONF_JSON_PORT): PORT_SELECTOR,
vol.Optional(
CONF_CALLBACK_HOST, default=data.get(CONF_CALLBACK_HOST) or UNDEFINED
): TEXT_SELECTOR,
vol.Optional(
CONF_CALLBACK_PORT, default=data.get(CONF_CALLBACK_PORT) or UNDEFINED
): PORT_SELECTOR_OPTIONAL,
vol.Optional(
CONF_JSON_PORT, default=data.get(CONF_JSON_PORT) or UNDEFINED
): PORT_SELECTOR_OPTIONAL,
}
)

Expand Down Expand Up @@ -443,7 +453,7 @@ def _get_ccu_data(data: ConfigType, user_input: ConfigType) -> ConfigType:
CONF_INTERFACE: data.get(CONF_INTERFACE, {}),
CONF_ADVANCED_CONFIG: data.get(CONF_ADVANCED_CONFIG, {}),
}
if callback_host := user_input.get(CONF_CALLBACK_HOST):
if (callback_host := user_input.get(CONF_CALLBACK_HOST)) and callback_host.strip() != "":
ccu_data[CONF_CALLBACK_HOST] = callback_host
if callback_port := user_input.get(CONF_CALLBACK_PORT):
ccu_data[CONF_CALLBACK_PORT] = callback_port
Expand Down
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
async-upnp-client==0.40.0
hahomematic==2024.8.12
homeassistant==2024.8.2
mypy==1.11.1
mypy==1.11.2
mypy-dev==1.11.0a9
pre-commit==3.8.0
pydevccu==0.1.8
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_pre_commit.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bandit==1.7.9
codespell==2.3.0
ruff==0.6.1
ruff==0.6.2
yamllint==1.35.1
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def control_config(hass: HomeAssistant, entry_data_v2) -> ControlConfig:
entry_id=const.CONFIG_ENTRY_ID,
data=entry_data_v2,
default_port=const.DEFAULT_CALLBACK_PORT,
sysvar_registry_enabled=True,
)


Expand Down

0 comments on commit 1ebf1a5

Please sign in to comment.