Skip to content

Commit

Permalink
Updated manifest to uhppoted-python_v0.8.9 and enabled TCP/IP connect…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
twystd committed Sep 6, 2024
1 parent afbb2f0 commit cc39125
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 52 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## [0.8.9](https://github.com/uhppoted/uhppoted-app-home-assistant/releases/tag/v0.8.9) - 2024-09-06

### Added
1. Implements support for (optional) TCP connections to controllers.
1. Implements (optional) support for TCP/IP connections to controllers.

### Updated
1. Fixed support for multiple _uhppoted_ instances.
Expand Down
12 changes: 2 additions & 10 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
# TODO

- [x] TCP transport (cf. https://github.com/uhppoted/uhppote-core/issues/17)
- [x] Commonalise config-/options-flow controllers step
- [x] Fix duplicate controllers -> multiple door steps (i.e. clean up options)
- [x] config-flow: duplicate controllers - tick only selected controllers
- [x] Rework coordinators to support multiple uhppoted's
- [x] Rework services to support multiple uhppoted's
- [x] Remove port from config-/options-flow UI
- [x] Move self.controllers into flow superclass
- [x] # FIXME <sigh> self._controllers...

- [ ] TCP transport (cf. https://github.com/uhppoted/uhppote-core/issues/17)
- [ ] (eventually) remove `controllers` from driver
- [ ] (eventually) remove `controllers` from driver

- [ ] DataCoordinator
- [ ] communalize data
Expand Down
2 changes: 1 addition & 1 deletion custom_components/uhppoted/coordinators/coordinators.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __init__(self, hass, options):
lambda evt: self._on_event(hass, evt))

def __del__(self):
self.unload()
self._unload()

def _unload(self):
self._controllers.unload()
Expand Down
4 changes: 2 additions & 2 deletions custom_components/uhppoted/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": [],
"documentation": "https://github.com/uhppoted/uhppoted-app-home-assistant",
"iot_class": "local_polling",
"requirements": [ "uhppoted==0.8.8.1" ],
"version": "0.8.8.1",
"requirements": [ "uhppoted==0.8.9" ],
"version": "0.8.9",
"homekit": {},
"ssdp": [],
"zeroconf": []
Expand Down
79 changes: 41 additions & 38 deletions custom_components/uhppoted/uhppoted.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,56 +25,56 @@ def get_all_controllers(bind, broadcast, listen, debug):
return uhppote.Uhppote(bind, broadcast, listen, debug).get_all_controllers()

def get_controller(self, controller):
(addr, timeout) = self._lookup(controller)
return self._api.get_controller(controller, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.get_controller(c, timeout=self._timeout)

def get_time(self, controller):
(addr, timeout) = self._lookup(controller)
return self._api.get_time(controller, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.get_time(c, timeout=timeout)

def set_time(self, controller, time):
(addr, timeout) = self._lookup(controller)
return self._api.set_time(controller, time, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.set_time(c, time, timeout=timeout)

def get_listener(self, controller):
(addr, timeout) = self._lookup(controller)
return self._api.get_listener(controller, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.get_listener(c, timeout=timeout)

def set_listener(self, controller, address, port):
(addr, timeout) = self._lookup(controller)
return self._api.set_listener(controller, address, port, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.set_listener(c, address, port, timeout=timeout)

def get_door_control(self, controller, door):
(addr, timeout) = self._lookup(controller)
return self._api.get_door_control(controller, door, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.get_door_control(c, door, timeout=timeout)

def set_door_control(self, controller, door, mode, delay):
(addr, timeout) = self._lookup(controller)
return self._api.set_door_control(controller, door, mode, delay, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.set_door_control(c, door, mode, delay, timeout=timeout)

def open_door(self, controller, door):
(addr, timeout) = self._lookup(controller)
return self._api.open_door(controller, door, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.open_door(c, door, timeout=timeout)

def get_status(self, controller):
(addr, timeout) = self._lookup(controller)
return self._api.get_status(controller, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.get_status(c, timeout=timeout)

def get_cards(self, controller):
(addr, timeout) = self._lookup(controller)
return self._api.get_cards(controller, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.get_cards(c, timeout=timeout)

def get_card(self, controller, card):
(addr, timeout) = self._lookup(controller)
return self._api.get_card(controller, card, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.get_card(c, card, timeout=timeout)

def get_card_by_index(self, controller, index):
(addr, timeout) = self._lookup(controller)
return self._api.get_card_by_index(controller, index, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.get_card_by_index(c, index, timeout=timeout)

def put_card(self, controller, card, start_date, end_date, door1, door2, door3, door4, PIN):
(addr, timeout) = self._lookup(controller)
return self._api.put_card(controller,
(c,timeout) = self._lookup(controller)
return self._api.put_card(c,
card,
start_date,
end_date,
Expand All @@ -83,31 +83,34 @@ def put_card(self, controller, card, start_date, end_date, door1, door2, door3,
door3,
door4,
PIN,
dest_addr=addr,
timeout=timeout)

def delete_card(self, controller, card):
(addr, timeout) = self._lookup(controller)
return self.api.delete_card(controller, card, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self.api.delete_card(c, card, timeout=timeout)

def record_special_events(self, controller, enable):
(addr, timeout) = self._lookup(controller)
return self._api.record_special_events(controller, enable, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.record_special_events(c, enable, timeout=timeout)

def get_event(self, controller, index):
(addr, timeout) = self._lookup(controller)
return self._api.get_event(controller, index, dest_addr=addr, timeout=timeout)
(c,timeout) = self._lookup(controller)
return self._api.get_event(c, index, timeout=timeout)

def _lookup(self, controller):
for v in self._controllers:
if controller == v['controller']:
addr = v.get('address', self._broadcast)
addr = v.get('address', None)
port = v.get('port', 60000)
timeout = v.get('timeout', self._timeout)
protocol = v.get('protocol', 'udp')

if f'{addr}:{port}' == f'{self._broadcast}':
return (None, timeout)
if addr is None:
return ((controller, None, 'udp'), timeout)
elif f'{addr}:{port}' == self._broadcast:
return ((controller, None, 'udp'), timeout)
else:
return (f'{addr}:{port}', timeout)
return ((controller, f'{addr}:{port}', protocol), timeout)

return ((controller, None, 'udp'), self._timeout)

return (None, self._timeout)

0 comments on commit cc39125

Please sign in to comment.