#!/usr/bin/env python3 import json import sys # Read flows.json with open('/home/mdares/.node-red/flows.json', 'r') as f: flows = json.load(f) # Read the new Machine cycles function with open('/home/mdares/.node-red/enhanced_machine_cycles_function.js', 'r') as f: machine_cycles_code = f.read() # Read the new Work Order buttons function with open('/home/mdares/.node-red/enhanced_work_order_buttons_function.js', 'r') as f: work_order_buttons_code = f.read() # Update Machine cycles node for node in flows: if node.get('id') == '0d023d87a13bf56f': node['func'] = machine_cycles_code node['outputs'] = 4 print(f"āœ“ Updated Machine cycles function (ID: 0d023d87a13bf56f)") print(f" - Changed outputs from 2 to 4") print(f" - Added time tracking, cycle capping, anomaly detection") elif node.get('id') == '9bbd4fade968036d': node['func'] = work_order_buttons_code node['outputs'] = 5 print(f"āœ“ Updated Work Order buttons function (ID: 9bbd4fade968036d)") print(f" - Changed outputs from 4 to 5") print(f" - Added stop categorization and session management") # Write updated flows with open('/home/mdares/.node-red/flows.json', 'w') as f: json.dump(flows, f, indent=4) print("\nāœ… flows.json updated successfully!") print("Note: You still need to add new nodes and wiring (next step)")