Skip to content

Commit

Permalink
Merge pull request #29 from grimmpp/feature-branch
Browse files Browse the repository at this point in the history
Added MGW support
  • Loading branch information
grimmpp authored May 23, 2024
2 parents 648246a + f61b7c4 commit 47d4fe2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log

## v0.1.22 Support for MGW Gateway
## v0.1.23 Support for MGW Gateway
* Added support for [MGW Gateway](https://www.piotek.de/PioTek-MGW-POE) (ESP3 over LAN)

## v0.1.21 EEP representation bug fixes
Expand Down
21 changes: 18 additions & 3 deletions eo_man/controller/serial_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,18 @@ def establish_serial_connection(self, serial_port:str, device_type:str) -> None:
delay_message=delay_message,
auto_reconnect=False)
self._serial_bus.start()
self._serial_bus.is_serial_connected.wait(timeout=10)
self._serial_bus.is_serial_connected.wait(timeout=2)

if not self._serial_bus.is_active():
self._serial_bus.stop()

if self._serial_bus.is_active():
self.connected_gateway_type = device_type
self.app_bus.fire_event(AppBusEventType.LOG_MESSAGE, {'msg': f"Serial connection established. serial port: {serial_port}, baudrate: {baudrate}", 'color':'green'})
if device_type == GDN[GDT.LAN]:
msg = f"TCP to Serial connection established. Server: {serial_port}:5100"
else:
msg = f"Serial connection established. serial port: {serial_port}, baudrate: {baudrate}"
self.app_bus.fire_event(AppBusEventType.LOG_MESSAGE, {'msg': msg, 'color':'green'})

if device_type == GDN[GDT.EltakoFAM14]:

Expand All @@ -248,11 +252,22 @@ def run():
AppBusEventType.CONNECTION_STATUS_CHANGE,
{'serial_port': serial_port, 'baudrate': baudrate, 'connected': self._serial_bus.is_active()})

else:
self.app_bus.fire_event(AppBusEventType.CONNECTION_STATUS_CHANGE, {'serial_port': serial_port, 'baudrate': baudrate, 'connected': False})
if device_type == GDN[GDT.LAN]:
msg = f"Couldn't establish connection to {serial_port}:5100! Try to restart device."
else:
msg = f"Establish connection for {device_type} on port {serial_port} failed! Device not ready."
self.app_bus.fire_event(AppBusEventType.LOG_MESSAGE, {'msg': msg, 'log-level': 'ERROR', 'color': 'red'})

except Exception as e:
self._serial_bus.stop()
self.connected_gateway_type = None
self.app_bus.fire_event(AppBusEventType.CONNECTION_STATUS_CHANGE, {'serial_port': serial_port, 'baudrate': baudrate, 'connected': False})
msg = f"Establish connection for {device_type} on port {serial_port} failed!!!"
if device_type == GDN[GDT.LAN]:
msg = f"Establish connection for {device_type} to {serial_port}:5100 failed! Retry later."
else:
msg = f"Establish connection for {device_type} on port {serial_port} failed!"
self.app_bus.fire_event(AppBusEventType.LOG_MESSAGE, {'msg': msg, 'log-level': 'ERROR', 'color': 'red'})
logging.exception(msg, exc_info=True)

Expand Down
2 changes: 1 addition & 1 deletion eo_man/data/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def is_esp2_gateway(cls, dev_type) -> bool:
GatewayDeviceType.EltakoFAMUSB: 'FAM-USB (ESP2)',
GatewayDeviceType.USB300: 'ESP3 Gateway',
GatewayDeviceType.ESP3: 'ESP3 Gateway',
GatewayDeviceType.LAN: 'MGW LAN/Wifi',
GatewayDeviceType.LAN: 'LAN Gateway (ESP3)',
}

def get_display_names():
Expand Down
4 changes: 2 additions & 2 deletions eo_man/view/serial_communication_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, main: Tk, app_bus:AppBus, data_manager:DataManager, serial_co
l = Label(f, text="Gateway Type: ")
l.pack(side=tk.LEFT, padx=(0, 5), pady=5)

self.cb_device_type = ttk.Combobox(f, state="readonly", width="12")
self.cb_device_type = ttk.Combobox(f, state="readonly", width="18")
self.cb_device_type.pack(side=tk.LEFT, padx=(0, 5), pady=5)
self.cb_device_type['values'] = get_display_names() # ['FAM14', 'FGW14-USB', 'FAM-USB', 'USB300', 'LAN Gateway']
self.cb_device_type.set(self.cb_device_type['values'][0])
Expand All @@ -45,7 +45,7 @@ def __init__(self, main: Tk, app_bus:AppBus, data_manager:DataManager, serial_co
l = ttk.Label(f, text="Serial Port: ")
l.pack(side=tk.LEFT, padx=(0, 5), pady=5)

self.cb_serial_ports = ttk.Combobox(f, state="readonly", width="10")
self.cb_serial_ports = ttk.Combobox(f, state="readonly", width="14")
self.cb_serial_ports.pack(side=tk.LEFT, padx=(0, 5), pady=5)

self.b_connect = ttk.Button(f, text="Connect", state=DISABLED, command=self.toggle_serial_connection_command)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ termcolor==2.4.0
tkinterhtml==0.7
requests==2.31.0
enocean==0.60.1
esp2_gateway_adapter>=0.2.1
esp2_gateway_adapter>=0.2.2
zeroconf==0.132.2
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
license = f.read()

required = ['eltako14bus==0.0.53', 'requests==2.31.0', 'enocean==0.60.1', 'pyserial', 'pyserial-asyncio', 'aiocoap',
'esp2_gateway_adapter==0.2.1',
'esp2_gateway_adapter==0.2.2',
# 'homeassistant',
'zeroconf==0.132.2',
'pyyaml',
Expand All @@ -27,7 +27,7 @@

setup(
name='eo_man',
version='0.1.22',
version='0.1.23',
package_dir={'eo_man':"eo_man"},
# packages=find_packages("./eo-man"),
#package_data={'': ['*.png']},
Expand Down

0 comments on commit 47d4fe2

Please sign in to comment.