Skip to content

Commit

Permalink
added support for mgw lan
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmpp committed May 23, 2024
1 parent e52b662 commit f288f44
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 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 MGW LAN Support
* Added support for [MGW Gateway](https://www.piotek.de/PioTek-MGW-POE) (ESP3 over LAN)

## Version 1.4.4
* Thread sync clean up
* Lazy loading for ESP3 libs to prevent dependency issues
Expand Down
24 changes: 21 additions & 3 deletions custom_components/eltako/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
CONF_BASE_ID: Final = "base_id"
CONF_DEVICE_TYPE: Final = "device_type"
CONF_SERIAL_PATH: Final = "serial_path"
CONF_GATEWAY_ADDRESS: Final = "address"
CONF_CUSTOM_SERIAL_PATH: Final = "custom_serial_path"
CONF_MAX_TARGET_TEMPERATURE: Final = "max_target_temperature"
CONF_MIN_TARGET_TEMPERATURE: Final = "min_target_temperature"
Expand Down Expand Up @@ -77,6 +78,12 @@ class GatewayDeviceType(str, Enum):
GatewayEltakoFGW14USB = 'fgw14usb'
GatewayEltakoFAMUSB = 'fam-usb' # ESP2 transceiver: https://www.eltako.com/en/product/professional-standard-en/three-phase-energy-meters-and-one-phase-energy-meters/fam-usb/
EnOceanUSB300 = 'enocean-usb300' # not yet supported
EltakoFAM14 = 'fam14'
EltakoFGW14USB = 'fgw14usb'
EltakoFAMUSB = 'fam-usb'
USB300 = 'enocean-usb300'
ESP3 = 'esp3-gateway'
LAN = 'mgw-lan'

@classmethod
def find(cls, value):
Expand All @@ -87,19 +94,30 @@ def find(cls, value):

@classmethod
def is_transceiver(cls, dev_type) -> bool:
return dev_type in [GatewayDeviceType.GatewayEltakoFAMUSB, GatewayDeviceType.EnOceanUSB300]
return dev_type in [GatewayDeviceType.GatewayEltakoFAMUSB, GatewayDeviceType.EnOceanUSB300, GatewayDeviceType.USB300, GatewayDeviceType.ESP3]

@classmethod
def is_bus_gateway(cls, dev_type) -> bool:
return dev_type in [GatewayDeviceType.GatewayEltakoFAM14, GatewayDeviceType.GatewayEltakoFGW14USB]
return dev_type in [GatewayDeviceType.GatewayEltakoFAM14, GatewayDeviceType.GatewayEltakoFGW14USB,
GatewayDeviceType.EltakoFAM14, GatewayDeviceType.EltakoFAMUSB, GatewayDeviceType.EltakoFGW14USB]

@classmethod
def is_esp2_gateway(cls, dev_type) -> bool:
return dev_type in [GatewayDeviceType.GatewayEltakoFAM14, GatewayDeviceType.GatewayEltakoFGW14USB, GatewayDeviceType.GatewayEltakoFAMUSB]
return dev_type in [GatewayDeviceType.GatewayEltakoFAM14, GatewayDeviceType.GatewayEltakoFGW14USB, GatewayDeviceType.GatewayEltakoFAMUSB,
GatewayDeviceType.EltakoFAM14, GatewayDeviceType.EltakoFAMUSB, GatewayDeviceType.EltakoFGW14USB]

@classmethod
def is_lan_gateway(cls, dev_type) -> bool:
return dev_type in [GatewayDeviceType.LAN]

BAUD_RATE_DEVICE_TYPE_MAPPING: dict = {
GatewayDeviceType.GatewayEltakoFAM14: 57600,
GatewayDeviceType.GatewayEltakoFGW14USB: 57600,
GatewayDeviceType.GatewayEltakoFAMUSB: 9600,
GatewayDeviceType.EnOceanUSB300: 57600,
GatewayDeviceType.EltakoFAM14: 57600,
GatewayDeviceType.EltakoFGW14USB: 57600,
GatewayDeviceType.EltakoFAMUSB: 9600,
GatewayDeviceType.USB300: 57600,
GatewayDeviceType.ESP3: 57600,
}
3 changes: 3 additions & 0 deletions custom_components/eltako/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def _init_bus(self):

if GatewayDeviceType.is_esp2_gateway(self.dev_type):
self._bus = RS485SerialInterfaceV2(self.serial_path, baud_rate=self.baud_rate, callback=self._callback_receive_message_from_serial_bus)
elif GatewayDeviceType.is_lan_gateway(self.dev_type):
from esp2_gateway_adapter.esp3_tcp_com import TCP2SerialCommunicator
self._bus = TCP2SerialCommunicator(host=self.serial_path, port=5100, callback=self._callback_receive_message_from_serial_bus, esp2_translation_enabled=True)
else:
# lazy import to avoid preloading library
from esp2_gateway_adapter.esp3_serial_com import ESP3SerialCommunicator
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 @@ -9,6 +9,6 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/grimmpp/home-assistant-eltako/issues",
"loggers": ["eltako"],
"requirements": ["eltako14bus==0.0.52", "enocean==0.60.1", "StrEnum", "esp2-gateway-adapter==0.1"],
"requirements": ["eltako14bus==0.0.53", "enocean==0.60.1", "StrEnum", "esp2-gateway-adapter==0.2.2"],
"version": "1.4.4"
}
1 change: 1 addition & 0 deletions custom_components/eltako/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ class GatewaySchema(EltakoPlatformSchema):
vol.Required(CONF_BASE_ID): cv.matches_regex(CONF_ID_REGEX),
vol.Optional(CONF_NAME, default=""): cv.string,
vol.Optional(CONF_SERIAL_PATH): cv.string,
vol.Optional(CONF_GATEWAY_ADDRESS): cv.string,
vol.Optional(CONF_DEVICES): vol.All(vol.Schema({
**BinarySensorSchema.platform_node(),
**LightSchema.platform_node(),
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
aiocoap
pyserial-asyncio
eltako14bus==0.0.52
eltako14bus==0.0.53
enocean==0.60.1
homeassistant
termcolor
StrEnum
esp2-gateway-adapter==0.1
esp2-gateway-adapter==0.2.2

0 comments on commit f288f44

Please sign in to comment.