Skip to content

Commit

Permalink
Add option to config flow/advanced to listen on all ip addresses (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ authored Oct 7, 2024
1 parent e0387f6 commit 615af72
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ hs485d_port:
default: 2000
```
#### Advanced
#### Advanced (optional)
```yaml
program_scan_enabled:
Expand Down Expand Up @@ -234,6 +234,14 @@ enable_system_notifications:
A better option is to solve the communication problems in your environment.
type: integer
default: true
listen_on_all_ip:
required: true
description:
By default the XMLRPC server only listens to the ip address, that is used for the communication to the CCU, because, for security reasons, it's better to only listen on needed ports.
This works for most of the installations, but in rare cases, when double virtualization is used (Docker on Windows/Mac), this doesn't work.
In those cases it is necessary, that the XMLRPC server listens an all ('0.0.0.0') ip addresses.
type: integer
default: false
un_ignore: (Only visible when reconfiguring the integration)
required: false
description:
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Raise exception on set_value, put_paramset
- Remove command queue
- Simplify entity imports
- Add option to config flow/advanced to listen on all ip addresses
- Raise HomeAssistantError on service exception
- Remove periodic master entity update

Expand Down
9 changes: 9 additions & 0 deletions custom_components/homematicip_local/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@
CONF_INSTANCE_NAME,
CONF_INTERFACE,
CONF_JSON_PORT,
CONF_LISTEN_ON_ALL_IP,
CONF_PROGRAM_SCAN_ENABLED,
CONF_SYS_SCAN_INTERVAL,
CONF_SYSVAR_SCAN_ENABLED,
CONF_TLS,
CONF_UN_IGNORE,
CONF_VERIFY_TLS,
DEFAULT_ENABLE_SYSTEM_NOTIFICATIONS,
DEFAULT_LISTEN_ON_ALL_IP,
DEFAULT_PROGRAM_SCAN_ENABLED,
DEFAULT_SYS_SCAN_INTERVAL,
DEFAULT_SYSVAR_SCAN_ENABLED,
Expand Down Expand Up @@ -233,6 +235,12 @@ def get_advanced_schema(data: ConfigType, all_un_ignore_parameters: list[str]) -
CONF_ENABLE_SYSTEM_NOTIFICATIONS, DEFAULT_ENABLE_SYSTEM_NOTIFICATIONS
),
): BOOLEAN_SELECTOR,
vol.Required(
CONF_LISTEN_ON_ALL_IP,
default=data.get(CONF_ADVANCED_CONFIG, {}).get(
CONF_LISTEN_ON_ALL_IP, DEFAULT_LISTEN_ON_ALL_IP
),
): BOOLEAN_SELECTOR,
vol.Optional(
CONF_UN_IGNORE,
default=existing_parameters,
Expand Down Expand Up @@ -532,6 +540,7 @@ def _update_advanced_input(data: ConfigType, advanced_input: ConfigType) -> None
data[CONF_ADVANCED_CONFIG][CONF_ENABLE_SYSTEM_NOTIFICATIONS] = advanced_input[
CONF_ENABLE_SYSTEM_NOTIFICATIONS
]
data[CONF_ADVANCED_CONFIG][CONF_LISTEN_ON_ALL_IP] = advanced_input[CONF_LISTEN_ON_ALL_IP]
if advanced_input.get(CONF_UN_IGNORE):
data[CONF_ADVANCED_CONFIG][CONF_UN_IGNORE] = advanced_input[CONF_UN_IGNORE]

Expand Down
2 changes: 2 additions & 0 deletions custom_components/homematicip_local/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DEFAULT_DEVICE_FIRMWARE_DELIVERING_CHECK_INTERVAL: Final = 3600 # 1h
DEFAULT_DEVICE_FIRMWARE_UPDATING_CHECK_INTERVAL: Final = 300 # 5m
DEFAULT_ENABLE_SYSTEM_NOTIFICATIONS: Final = True
DEFAULT_LISTEN_ON_ALL_IP: Final = False
DEFAULT_PROGRAM_SCAN_ENABLED: Final = True
DEFAULT_SYSVAR_SCAN_ENABLED: Final = True
DEFAULT_SYS_SCAN_INTERVAL: Final = 30
Expand All @@ -28,6 +29,7 @@

CONF_ADVANCED_CONFIG: Final = "advanced_config"
CONF_CALLBACK_HOST: Final = "callback_host"
CONF_LISTEN_ON_ALL_IP: Final = "listen_on_all_ip"
CONF_CALLBACK_PORT: Final = "callback_port"
CONF_ENABLE_SYSTEM_NOTIFICATIONS: Final = "enable_system_notifications"
CONF_EVENT_TYPE: Final = "event_type"
Expand Down
7 changes: 7 additions & 0 deletions custom_components/homematicip_local/control_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
CONF_INSTANCE_NAME,
CONF_INTERFACE,
CONF_JSON_PORT,
CONF_LISTEN_ON_ALL_IP,
CONF_PROGRAM_SCAN_ENABLED,
CONF_SYS_SCAN_INTERVAL,
CONF_SYSVAR_SCAN_ENABLED,
Expand All @@ -72,6 +73,7 @@
DEFAULT_DEVICE_FIRMWARE_DELIVERING_CHECK_INTERVAL,
DEFAULT_DEVICE_FIRMWARE_UPDATING_CHECK_INTERVAL,
DEFAULT_ENABLE_SYSTEM_NOTIFICATIONS,
DEFAULT_LISTEN_ON_ALL_IP,
DEFAULT_PROGRAM_SCAN_ENABLED,
DEFAULT_SYS_SCAN_INTERVAL,
DEFAULT_SYSVAR_SCAN_ENABLED,
Expand Down Expand Up @@ -195,6 +197,7 @@ def _create_central(self) -> CentralUnit:
else None,
central_id=central_id,
client_session=aiohttp_client.async_get_clientsession(self._hass),
listen_ip_addr=IP_ANY_V4 if self._config.listen_on_all_ip else None,
default_callback_port=self._default_callback_port,
host=self._config.host,
interface_configs=interface_configs,
Expand Down Expand Up @@ -603,6 +606,10 @@ def __init__(
self.sys_scan_interval: Final = advanced_config.get(
CONF_SYS_SCAN_INTERVAL, DEFAULT_SYS_SCAN_INTERVAL
)

self.listen_on_all_ip = advanced_config.get(
CONF_LISTEN_ON_ALL_IP, DEFAULT_LISTEN_ON_ALL_IP
)
self.un_ignore: Final = advanced_config.get(CONF_UN_IGNORE, DEFAULT_UN_IGNORE)

def check_config(self) -> None:
Expand Down
2 changes: 2 additions & 0 deletions custom_components/homematicip_local/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"advanced": {
"data": {
"enable_system_notifications": "Enable system notifications",
"listen_on_all_ip": "listen on all ip",
"program_scan_enabled": "enable program scan",
"sysvar_scan_enabled": "enable system variable scan",
"sysvar_scan_interval": "Sysvar/Program scan interval"
Expand Down Expand Up @@ -582,6 +583,7 @@
"advanced": {
"data": {
"enable_system_notifications": "Enable system notifications",
"listen_on_all_ip": "listen on all ip",
"program_scan_enabled": "enable program scan",
"sysvar_scan_enabled": "enable system variable scan",
"sysvar_scan_interval": "Sysvar/Program scan interval",
Expand Down
2 changes: 2 additions & 0 deletions custom_components/homematicip_local/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"advanced": {
"data": {
"enable_system_notifications": "Systembenachrichtigungen aktivieren",
"listen_on_all_ip": "Auf allen IP Adressen lauschen",
"program_scan_enabled": "Programm Scan aktivieren",
"sysvar_scan_enabled": "Systemvariablen Scan aktivieren",
"sysvar_scan_interval": "Sysvar/Program Scan Interval"
Expand Down Expand Up @@ -586,6 +587,7 @@
"advanced": {
"data": {
"enable_system_notifications": "Systembenachrichtigungen aktivieren",
"listen_on_all_ip": "Auf allen IP Adressen lauschen",
"program_scan_enabled": "Programm Scan aktivieren",
"sysvar_scan_enabled": "Systemvariablen Scan aktivieren",
"sysvar_scan_interval": "Sysvar/Program Scan Interval",
Expand Down
2 changes: 2 additions & 0 deletions custom_components/homematicip_local/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"advanced": {
"data": {
"enable_system_notifications": "Enable system notifications",
"listen_on_all_ip": "listen on all ip",
"program_scan_enabled": "enable program scan",
"sysvar_scan_enabled": "enable system variable scan",
"sysvar_scan_interval": "Sysvar/Program scan interval"
Expand Down Expand Up @@ -582,6 +583,7 @@
"advanced": {
"data": {
"enable_system_notifications": "Enable system notifications",
"listen_on_all_ip": "listen on all ip",
"program_scan_enabled": "enable program scan",
"sysvar_scan_enabled": "enable system variable scan",
"sysvar_scan_interval": "Sysvar/Program scan interval",
Expand Down

0 comments on commit 615af72

Please sign in to comment.