power: loosen bound service requirement

Specifically check against the detected service unit, otherwise
allow a power device to bind to any available service.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-09-23 07:34:11 -04:00 committed by Eric Callahan
parent f22b859a0f
commit be9aff8b5e
1 changed files with 5 additions and 4 deletions

View File

@ -321,11 +321,12 @@ class PowerDevice:
def _setup_bound_service(self) -> None:
if self.bound_service is None:
return
if self.bound_service.startswith("moonraker"):
raise self.server.error(
f"Cannot bind to '{self.bound_service}' "
"service")
machine_cmp: Machine = self.server.lookup_component("machine")
if machine_cmp.unit_name == self.bound_service.split(".", 1)[0]:
raise self.server.error(
f"Power Device {self.name}: Cannot bind to Moonraker "
f"service, {self.bound_service}."
)
sys_info = machine_cmp.get_system_info()
avail_svcs: List[str] = sys_info.get('available_services', [])
if self.bound_service not in avail_svcs: