Initial commit, 90% there
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
|
||||
# Read flows.json
|
||||
with open('/home/mdares/.node-red/flows.json', 'r') as f:
|
||||
flows = json.load(f)
|
||||
|
||||
# Find key nodes
|
||||
work_order_buttons_node = None
|
||||
stop_reason_ui_node = None
|
||||
|
||||
for node in flows:
|
||||
if node.get('id') == '9bbd4fade968036d':
|
||||
work_order_buttons_node = node
|
||||
elif node.get('type') == 'ui_template' and 'Stop Reason' in node.get('name', ''):
|
||||
stop_reason_ui_node = node
|
||||
|
||||
print("Finding nodes...")
|
||||
print(f"Work Order buttons: {work_order_buttons_node['id'] if work_order_buttons_node else 'NOT FOUND'}")
|
||||
print(f"Stop Reason UI: {stop_reason_ui_node['id'] if stop_reason_ui_node else 'NOT FOUND'}")
|
||||
|
||||
if work_order_buttons_node and stop_reason_ui_node:
|
||||
# Wire Work Order buttons Output 2 to Stop Reason UI
|
||||
# Output 2 sends: refresh-work-orders, stop-prompt messages
|
||||
# We need to check existing Output 2 wiring
|
||||
existing_output_2_wires = work_order_buttons_node['wires'][1] if len(work_order_buttons_node['wires']) > 1 else []
|
||||
|
||||
# Add Stop Reason UI to output 2 (keeping existing wires)
|
||||
if stop_reason_ui_node['id'] not in existing_output_2_wires:
|
||||
existing_output_2_wires.append(stop_reason_ui_node['id'])
|
||||
work_order_buttons_node['wires'][1] = existing_output_2_wires
|
||||
|
||||
# Wire Stop Reason UI output back to Work Order buttons input
|
||||
# The UI sends stop-reason action back
|
||||
stop_reason_ui_node['wires'] = [[work_order_buttons_node['id']]]
|
||||
|
||||
print("\n✅ Completed wiring:")
|
||||
print(f" - Work Order buttons Output 2 → Stop Reason UI")
|
||||
print(f" - Stop Reason UI output → Work Order buttons input")
|
||||
print(f" - This creates the stop categorization flow")
|
||||
|
||||
# Write updated flows
|
||||
with open('/home/mdares/.node-red/flows.json', 'w') as f:
|
||||
json.dump(flows, f, indent=4)
|
||||
|
||||
print("\n✅ All wiring complete!")
|
||||
|
||||
else:
|
||||
print("\n❌ Could not find required nodes for wiring")
|
||||
if not work_order_buttons_node:
|
||||
print(" - Work Order buttons node not found")
|
||||
if not stop_reason_ui_node:
|
||||
print(" - Stop Reason UI node not found")
|
||||
Reference in New Issue
Block a user