summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/sound_sensor_server.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/sound_sensor_server.py b/src/sound_sensor_server.py
index 90e5993..c63d14a 100755
--- a/src/sound_sensor_server.py
+++ b/src/sound_sensor_server.py
@@ -19,9 +19,12 @@ server: SoundSensorServer
def get_related_nodes(node_type: MediaNodeType,
sensor_name: str) -> List[str]:
- if sensor_name not in config[f'sensor_to_{node_type.name.lower()}_nodes_relations']:
- raise ValueError(f'unexpected sensor name {sensor_name}')
- return config[f'sensor_to_{node_type.name.lower()}_nodes_relations'][sensor_name]
+ try:
+ if sensor_name not in config[f'sensor_to_{node_type.name.lower()}_nodes_relations']:
+ raise ValueError(f'unexpected sensor name {sensor_name}')
+ return config[f'sensor_to_{node_type.name.lower()}_nodes_relations'][sensor_name]
+ except KeyError:
+ return []
def get_node_config(node_type: MediaNodeType,