Skip to content

Commit

Permalink
Fix shell in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
pzbitskiy committed Aug 7, 2024
1 parent b523a9a commit d8bc9ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/media_center_kb/ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _initialize_ha_devices(self): # pylint: disable=too-many-locals
rpi_switch_info = SwitchInfo(
name="Power",
device_class="outlet",
unique_id=rpi_device_id + "-switch",
unique_id=rpi_device_id + "-outlet",
device=self._rpi_device_info,
)
rpi_switch_settings = Settings(mqtt=self._mqtt_settings, entity=rpi_switch_info)
Expand Down Expand Up @@ -149,7 +149,7 @@ def _initialize_ha_devices(self): # pylint: disable=too-many-locals

printer_switch_info = SwitchInfo(
name="Power",
device_class="outlet",
device_class="switch",
unique_id=printer_device_id + "-switch",
device=self._printer_device_info,
)
Expand Down
10 changes: 9 additions & 1 deletion src/media_center_kb/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class RestrictedShell: # pylint: disable=too-few-public-methods
]
)

def __init__(self, allowed_cmds=None):
if allowed_cmds is not None:
self._allowed_cmds = allowed_cmds

def __call__(self, cmd: str):
logger.info("system: %s", cmd)
if cmd in self._allowed_cmds:
Expand Down Expand Up @@ -135,7 +139,11 @@ async def main():
gpio = GPio(Pins) if not args.no_gpio else GPioNoOp(Pins)
relays = RelayModule(gpio, logging.getLogger("rly"))
ysp = Ysp4000(verbose=verbose)
shell = RestrictedShell()
if args.no_gpio and args.no_keyboard and args.no_serial:
# looks like running in dev mode
shell = RestrictedShell(allowed_cmds=[])
else:
shell = RestrictedShell()
controller = Controller(relays, ysp, shell)

coros = []
Expand Down

0 comments on commit d8bc9ac

Please sign in to comment.