Skip to content

Commit

Permalink
Added message-delay for GWs as config parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmpp committed Jul 5, 2024
1 parent 3956d2e commit 005e7ba
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changes and Feature List

## Version 1.5.5 Added message-delay for GWs as config parameter
* Added argument `message_delay` to config distance of bulk messages being translated in the gateway so that buffer overflows can be prevented.

## Version 1.5.4 Cover motion fixed
* changed min movement time from 0 to 1 so that covers won't move completely up or down.

Expand Down
1 change: 1 addition & 0 deletions custom_components/eltako/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
CONF_DEVICE_TYPE: Final = "device_type"
CONF_SERIAL_PATH: Final = "serial_path"
CONF_GATEWAY_ADDRESS: Final = "address"
CONF_GATEWAY_MESSAGE_DELAY: Final = "message_delay"
CONF_GATEWAY_AUTO_RECONNECT: Final = "auto_reconnect"
CONF_GATEWAY_PORT: Final = "port"
CONF_CUSTOM_SERIAL_PATH: Final = "custom_serial_path"
Expand Down
3 changes: 2 additions & 1 deletion custom_components/eltako/eltako_integration_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
port = gateway_config.get(CONF_GATEWAY_PORT, 5100)
auto_reconnect = gateway_config.get(CONF_GATEWAY_AUTO_RECONNECT, True)
gateway_base_id = AddressExpression.parse(gateway_config[CONF_BASE_ID])
message_delay = gateway_config.get(gateway_config[CONF_GATEWAY_MESSAGE_DELAY], None)
LOGGER.debug(f"id: {gateway_id}, device type: {gateway_device_type}, serial path: {gateway_serial_path}, baud rate: {baud_rate}, base id: {gateway_base_id}")
usb_gateway = EnOceanGateway(general_settings, hass, gateway_id, gateway_device_type, gateway_serial_path, baud_rate, port, gateway_base_id, gateway_name, auto_reconnect, config_entry)
usb_gateway = EnOceanGateway(general_settings, hass, gateway_id, gateway_device_type, gateway_serial_path, baud_rate, port, gateway_base_id, gateway_name, auto_reconnect, message_delay, config_entry)

await usb_gateway.async_setup()
set_gateway_to_hass(hass, usb_gateway)
Expand Down
7 changes: 5 additions & 2 deletions custom_components/eltako/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ class EnOceanGateway:
"""

def __init__(self, general_settings:dict, hass: HomeAssistant,
dev_id: int, dev_type: GatewayDeviceType, serial_path: str, baud_rate: int, port: int, base_id: AddressExpression, dev_name: str, auto_reconnect: bool,
config_entry: ConfigEntry):
dev_id: int, dev_type: GatewayDeviceType, serial_path: str, baud_rate: int, port: int, base_id: AddressExpression, dev_name: str, auto_reconnect: bool=True, message_delay:float=None,
config_entry: ConfigEntry = None):
"""Initialize the Eltako gateway."""

self._loop = asyncio.get_event_loop()
self._bus_task = None
self.baud_rate = baud_rate
self._auto_reconnect = auto_reconnect
self._message_delay = message_delay
self.port = port
self._attr_dev_type = dev_type
self._attr_serial_path = serial_path
Expand Down Expand Up @@ -131,7 +132,9 @@ def _init_bus(self):
self._bus = RS485SerialInterfaceV2(self.serial_path,
baud_rate=self.baud_rate,
callback=self._callback_receive_message_from_serial_bus,
delay_message=self._message_delay,
auto_reconnect=self._auto_reconnect)

elif GatewayDeviceType.is_lan_gateway(self.dev_type):
# lazy import to avoid preloading library
from esp2_gateway_adapter.esp3_tcp_com import TCP2SerialCommunicator
Expand Down
2 changes: 1 addition & 1 deletion custom_components/eltako/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"issue_tracker": "https://github.com/grimmpp/home-assistant-eltako/issues",
"loggers": ["eltako"],
"requirements": ["eltako14bus==0.0.53", "enocean==0.60.1", "StrEnum", "esp2-gateway-adapter==0.2.10"],
"version": "1.5.4"
"version": "1.5.5"
}
1 change: 1 addition & 0 deletions custom_components/eltako/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ class GatewaySchema(EltakoPlatformSchema):
vol.Optional(CONF_SERIAL_PATH): cv.string,
vol.Optional(CONF_GATEWAY_AUTO_RECONNECT, default=True): cv.boolean,
vol.Optional(CONF_GATEWAY_ADDRESS): cv.string,
vol.Optional(CONF_GATEWAY_MESSAGE_DELAY, default=0.01): cv.Number,
vol.Optional(CONF_GATEWAY_PORT, default=5100): cv.Number,
vol.Optional(CONF_DEVICES): vol.All(vol.Schema({
**BinarySensorSchema.platform_node(),
Expand Down
1 change: 1 addition & 0 deletions docs/gateway_usage/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ To get familiar with the Eltako Integration configuration check out [Update Home
| `base_id` | enocean address format | Gateways can obviously receive and send messages. To send messages they use a hardcoded range of 128 addresses. The base_id is the first address of this range. Base_ids are used to identify the source of a message and to validate the configuration. |
| `devices` | configuration | Devices grouped by Home Assistant platform types. All devices which are listed here will be represented by this device. Device listed more than one in different devices will be recognized as two independent devices. |
| `serial_path` | optional string | for serial paths which won't be auto detected. Can be also used for serial over tcp. |
| `message_delay` | optional number in seconds | delays messages to prevent buffer overflow in gateways for sending many commands at once. Due to different baud rates for serial connection and RS485 bus, which is slower buffer overflow can happen. Default value is 0.01 seconds = 10ms. |
| `auto_reconnect` | True / False | for disabling auto-reconnect function. If not specified: True |
| `address` | IPv4 or IPv6 | only required for TCP/LAN gateway |
| `port` | Number | only used for TCP/LAN gateway. If not specified: 5100 |
Expand Down

0 comments on commit 005e7ba

Please sign in to comment.