### Create wpa_supplicant.conf for Wi‑Fi Setup Source: https://github.com/nebhead/pifire/wiki/3.-Software-Setup No description ```conf country=US ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="your_real_wifi_ssid" scan_ssid=1 psk="your_real_password" key_mgmt=WPA-PSK } ``` -------------------------------- ### Run Automatic PiFire Installation via wget Source: https://github.com/nebhead/pifire/wiki/3.-Software-Setup Downloads the install script first, then executes it locally. Useful when pipe-to-bash fails. Execute as the 'pi' user. ```bash wget https://raw.githubusercontent.com/nebhead/pifire/main/auto-install/install.sh ./install.sh ``` -------------------------------- ### Launch raspi-config for Initial System Setup Source: https://github.com/nebhead/pifire/wiki/3.-Software-Setup Opens the Raspberry Pi configuration utility to set locale, timezone, hostname, and enable I2C. Run after first SSH login. No extra packages needed. ```bash sudo raspi-config ``` -------------------------------- ### Run Automatic PiFire Installation via curl Source: https://github.com/nebhead/pifire/wiki/3.-Software-Setup Downloads and executes the install script in a single command. Requires network access and execution permissions; runs as the 'pi' user. ```bash curl https://raw.githubusercontent.com/nebhead/pifire/main/auto-install/install.sh | bash ``` -------------------------------- ### Reboot Raspberry Pi to Apply Configuration Changes Source: https://github.com/nebhead/pifire/wiki/3.-Software-Setup Restarts the system so that changes to /boot/config.txt and other settings take effect. Use after editing configuration files. ```bash sudo reboot ``` -------------------------------- ### HTML Template for Wizard Install Progress Source: https://github.com/nebhead/pifire/blob/main/blueprints/wizard/templates/wizard/wizard-finish.html This HTML template defines the structure for the wizard installation page. It includes placeholders for title, timer, content, and control panel scripts. The main content area displays the installation status, progress bar, and a text area for detailed output. ```html {% extends 'base.html' %} {% block title %}Wizard Configuration Install{% endblock %} {% block timer_bar %}{% endblock %} {% block content %} Starting Install... ------------------- _This operation may take several minutes._   Show Output {% endblock %} {% block controlpanel %}{% endblock %} {% block controlpanel_scripts %}{% endblock %} ``` -------------------------------- ### Configure /tmp as RAM‑backed tmpfs Source: https://github.com/nebhead/pifire/wiki/3.-Software-Setup Adds a tmpfs entry to /etc/fstab so that the /tmp directory resides in memory, improving performance and reducing SD‑card wear. Edit with root privileges and if needed. ```conf tmpfs /tmp tmpfs defaults,noatime 0 0 ``` -------------------------------- ### JavaScript for Real-time Install Status Update Source: https://github.com/nebhead/pifire/blob/main/blueprints/wizard/templates/wizard/wizard-finish.html This JavaScript code runs on document ready to poll the server for installation status updates. It uses jQuery's AJAX to fetch data from '/wizard/installstatus' and updates the UI elements like status text, progress bar width, and the output log. It also handles redirection to reboot or restart the server upon completion. ```javascript // On Document Ready $(document).ready(function() { var output = ""; installStatus = setInterval(function(){ // Get Dash Data req = $.ajax({ url : '/wizard/installstatus', type : 'GET' }); req.done(function(data) { // Update Status $('#status').html(data.status); document.getElementById("percent").style.width = data.percent + "%»; if(output != data.output) { var textArea = document.getElementById("installOutput"); textArea.value += data.output + '\r\n'; textArea.scrollTop = textArea.scrollHeight; //$('#installOutput').append(data.output); output = data.output; } if (data.percent > 100) { clearInterval(installStatus); setTimeout(function() {console.log('Done!')}, 5000); // 2-second delay if (data.percent == 142) { location.href = '/admin/reboot'; // Server Reboot } else { location.href = '/admin/restart'; // Server Restart } }; }); }, 250); // Update every 0.25 second }); ``` -------------------------------- ### SSH into Raspberry Pi from Linux or macOS Source: https://github.com/nebhead/pifire/wiki/3.-Software-Setup Connects to the Pi over the network using the default 'pi' user. Requires the Pi to be powered on, Wi‑Fi configured, and SSH enabled via the empty 'ssh' file in the boot partition. ```bash ssh pi@192.168.10.xxx ``` -------------------------------- ### Increase I2C Bus Baudrate to 400 kHz Source: https://github.com/nebhead/pifire/wiki/3.-Software-Setup Improves I2C performance adding a dtparam entry to /boot/config.txt. Requires editing the file with root privileges. ```conf dtparam=i2c_arm=on,i2c_baudrate=400000 ``` -------------------------------- ### JSON Controller Settings Configuration Source: https://github.com/nebhead/pifire/blob/main/controller/readme.md Shows the structure of controller settings with selected controller name and configuration data. Includes example PID controller parameters with proportional band, derivative time, integral time, and center values. ```json { "controller": { "config": { "fuzzy": {}, "pid": { "PB": 60.0, "Td": 45.0, "Ti": 180.0, "center": 0.5 } }, "selected": "pid" } } ``` -------------------------------- ### Render Startup Mode Metrics in Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/metrics/templates/metrics/_macro_metrics.html This macro formats and displays detailed metrics for the 'Startup' mode of a grill. It includes start/end times, time in mode, auger on time, estimated pellet usage, and smart start profile data. It assumes the 'metric' input is a dictionary containing these values. ```Jinja2 {% macro render_startup(metric, units) %} **{{ metric['mode'] }} Mode** Metric Value Converted Start Time {{ metric['starttime'] }} {{ metric['starttime_c'] }} End Time {{ metric['endtime'] }} {{ metric['endtime_c'] }} Time in Mode {% if metric['endtime'] == 0 %} -- {% else %} {{ metric['endtime'] - metric['starttime'] }} {% endif %} {{ metric['timeinmode'] }} Auger On Time {{ metric['augerontime'] }} {{ metric['augerontime_c'] }} Estimated Pellet Usage {{ metric['estusage_m'] }} {{ metric['estusage_i'] }} Smart Start Profile {{ metric['smart_start_profile'] }} {{ metric['smart_start_profile'] }} Smart Startup Temp {{ metric['startup_temp'] }} {{ metric['startup_temp'] }}{{ units }} P Mode {{ metric['p_mode'] }} {{ metric['p_mode'] }} Auger Cycle Time {{ metric['auger_cycle_time'] }} {{ metric['auger_cycle_time'] }}s Raw Data {{ metric }} {% endmacro %} ``` -------------------------------- ### Render Wizard Card Macro Import Source: https://github.com/nebhead/pifire/blob/main/blueprints/wizard/templates/wizard/wizard.html Imports the wizard card rendering macro from the wizard macro template. This macro is used to display configuration cards for different hardware modules in the PiFire setup wizard. ```Jinja2 {% from 'wizard/_macro_wizard_card.html' import render_wizard_card %} ``` -------------------------------- ### Fix VPU Core Frequency for Stable I2C Timing Source: https://github.com/nebhead/pifire/wiki/3.-Software-Setup Sets a fixed VPU core frequency to prevent I2C clock drift on Pi 3/Zero models. Add the line to /boot/config.txt and reboot. ```conf core_freq=250 ``` -------------------------------- ### Render metrics page with operational modes Source: https://github.com/nebhead/pifire/blob/main/blueprints/metrics/templates/metrics/index.html Main template structure that conditionally displays metrics data or a prompt to start the grill. Uses Jinja2 macro imports to render different operational modes. Depends on metrics_data and settings variables. Renders different UI components based on the mode of operation. ```html {% extends 'base.html' %} {% from "metrics/\_macro\_metrics.html" import render\_startup, render\_stop, render\_smoke, render\_hold, render\_shutdown, render\_reignite, render\_manual, render\_monitor %} {% block title %}Metrics{% endblock %} {% block timer\_bar %}{% endblock %} {% block content %} {% if metrics\_data == \[\] %} No Data ------- _Start the grill to begin populating metrics._ {% else %} [Download CSV Data](/metrics/export) {% for item in metrics\_data %} {% if item\['mode'\] == 'Stop' %} {{ render\_stop(item, settings\['globals'\]\['units'\]) }} {% elif item\['mode'\] == 'Startup' %} {{ render\_startup(item, settings\['globals'\]\['units'\]) }} {% elif item\['mode'\] == 'Reignite' %} {{ render\_reignite(item, settings\['globals'\]\['units'\]) }} {% elif item\['mode'\] == 'Smoke' %} {{ render\_smoke(item, settings\['globals'\]\['units'\]) }} {% elif item\['mode'\] == 'Hold' %} {{ render\_hold(item, settings\['globals'\]\['units'\]) }} {% elif item\['mode'\] == 'Shutdown' %} {{ render\_shutdown(item, settings\['globals'\]\['units'\]) }} {% elif item\['mode'\] == 'Error' %} {{ render\_stop(item, settings\['globals'\]\['units'\]) }} {% elif item\['mode'\] == 'Monitor' %} {{ render\_monitor(item, settings\['globals'\]\['units'\]) }} {% elif item\['mode'\] == 'Manual' %} {{ render\_manual(item, settings\['globals'\]\['units'\]) }} {% else %} {{ render\_reignite(item, settings\['globals'\]\['units'\]) }} {% endif %} {% endfor %} {% endif %} {% endblock %} ``` -------------------------------- ### GET /api/settings Source: https://context7.com/nebhead/pifire/llms.txt Fetches all system settings and configurations for the PiFire controller, including global settings, probe configurations, cycle data, and safety parameters. This endpoint allows users to review and understand the current setup of the grill system. It is essential for customization and troubleshooting. ```APIDOC ## GET /api/settings ### Description This endpoint retrieves the complete settings structure for the PiFire system, covering globals, probes, cycles, and safety features. ### Method GET ### Endpoint /api/settings ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example No request body required. ### Response #### Success Response (200) - **settings** (object) - Full configuration data including globals, probes, cycles, and safety #### Response Example { "settings": { "globals": { "grill_name": "MyTraeger", "units": "F", "debug_mode": false, "augerrate": 0.3 }, "probe_settings": { "probe_map": {...}, "probe_profiles": {...} }, "cycle_data": { "PMode": 2, "HoldCycleTime": 25, "SmokeOnCycleTime": 15 }, "safety": { "maxtemp": 550, "reigniteretries": 1 } } } ``` -------------------------------- ### Installed Python Modules List in Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/admin/templates/admin/index.html Loops to display pip-installed modules and versions. Purpose: Inventory software dependencies. Depends on pip_list; inputs: list of dicts with name, version; outputs table with download link. Limitations: Assumes pip_list is populated; empty if none. ```jinja2 #####   Installed Python Modules {% for module in pip_list %} {% endfor %} Module Version {{ module['name'] }} {{ module['version'] }}   Download installed python modules list ('pip_list.json') ``` -------------------------------- ### Start recipe via API with curl Source: https://context7.com/nebhead/pifire/llms.txt Command to initiate a stored recipe through the PiFire REST API. Requires network access to the grill controller. ```shell curl http://pifire.local/api/cmd/recipe/start/brisket ``` -------------------------------- ### System Platform and Hardware Info in Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/admin/templates/admin/index.html Lists hardware details like model, CPU info, RAM. Purpose: Provide device specifications overview. Depends on system_info['hardware_info']; inputs: cpu_info dict, total_ram, available_ram; outputs bulleted HTML list. Limitations: Assumes nested dictionary structure. ```jinja2 #####   System Information **Platform Info:** * System Model: {{ system_info['hardware_info']['cpu_info']['model'] }} * CPU Model: {{ system_info['hardware_info']['cpu_info']['model_name'] }} * CPU Hardware: {{ system_info['hardware_info']['cpu_info']['hardware'] }} * CPU Cores: {{ system_info['hardware_info']['cpu_info']['cores'] }} * CPU Frequency: {{ system_info['hardware_info']['cpu_info']['frequency'] }} * Total Ram: {{ system_info['hardware_info']['total_ram'] }} * Available Ram: {{ system_info['hardware_info']['available_ram'] }} ``` -------------------------------- ### Render Recipe Page in Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/recipes/templates/recipes/_recipe_view.html This Jinja2 template renders a complete recipe page by displaying metadata like title, author, rating, prep/cook times, and difficulty. It lists ingredients with quantities and images, provides step-by-step instructions with associated ingredients and assets, and uses imported macros to render program steps (startup, active, or generic modes). Dependencies include Jinja2 for templating, imported macros from '_macro_recipes.html', and static file serving via url_for. Inputs are a dictionary 'recipe_data' with metadata, recipe ingredients, instructions, and steps. Outputs are HTML elements for web display; limitations include reliance on external image files and macro functions, with no error handling for missing data. ```Jinja2 {% from 'recipes/_macro_recipes.html' import render_recipe_step_startup, render_recipe_step_active, render_recipe_step_generic %} ###   **{{ recipe_data['metadata']['title'] }}** {% if recipe_data['metadata']['image'] != '' %} ![Recipe Image]({{ url_for('static', filename='img/tmp/'+recipe_data['metadata']['id']+'/'+recipe_data['metadata']['image']) }}) {% else %} ![Recipe Image]({{ url_for('static', filename='img/pifire-cf-thumb.png') }}) {% endif %}   About This Recipe Author {{ recipe_data['metadata']['author'] }} Rating {% for star in range(0, recipe_data['metadata']['rating']) %} {% endfor %}   ({{ recipe_data['metadata']['rating'] }}) Prep Time {{ recipe_data['metadata']['prep_time'] }}m Cook Time {{ recipe_data['metadata']['cook_time'] }}m Difficulty {% if recipe_data['metadata']['difficulty'] == 'Easy' %} ##### Easy {% elif recipe_data['metadata']['difficulty'] == 'Intermediate' %} ##### Intermediate {% elif recipe_data['metadata']['difficulty'] == 'Hard' %} ##### Hard {% elif recipe_data['metadata']['difficulty'] == 'Advanced' %} ##### Advanced {% else %} ##### {{ recipe_data['metadata']['difficulty'] }} {% endif %} Food Probes {{ recipe_data['metadata']['food_probes'] }}   Description {{ recipe_data['metadata']['description'] }}   Ingredients {% for ingredient in recipe_data['recipe']['ingredients'] %} {% endfor %} # Quantity Ingredient {{ loop.index0 }} {{ ingredient['quantity'] }} {{ ingredient['name'] }} {% set outerindex = loop.index0 %} {% for asset in ingredient['assets'] %} ![thumbnail]({{ url_for('static', filename='img/tmp/'+recipe_data['metadata']['id']+'/'+asset) }}) {% endfor %}   Instructions {% for item in recipe_data['recipe']['instructions'] %} {% endfor %} Direction Ingredients Used Program Step {{ item['text'] }} {% set outerindex = loop.index0 %} {% for asset in item['assets'] %} ![thumbnail]({{ url_for('static', filename='img/tmp/'+recipe_data['metadata']['id']+'/'+asset) }}) {% endfor %} {% for ingredient in item['ingredients'] %}* {{ ingredient }} {% endfor %} {% if item['step'] == 0 %} Prep {% else %} Step {{ item['step'] }} {% endif %}   Program Steps {% for step in recipe_data['recipe']['steps'] %} {% if step['mode'] == 'Startup' %} {{ render_recipe_step_startup(step, loop.index0, True) }} {% elif step['mode'] in ['Hold', 'Smoke']%} {{ render_recipe_step_active(step, loop.index0, recipe_data, True) }} {% else %} {{ render_recipe_step_generic(step, loop.index0, True) }} {% endif %} {% endfor %} ``` -------------------------------- ### Render Recipe Step Startup Macro - Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/recipes/templates/recipes/_macro_recipes.html Macro to render a startup step in a recipe, displaying the step number and mode, with transition condition on successful startup. Requires step_data dict with 'mode', step_number int, and active bool. Outputs HTML for simplified step display without triggers or timers. Does not handle active states or notifications. ```jinja2 {% macro render_recipe_step_startup(step_data, step_number, active) %} ### **Step {{ step_number }}** **Mode:** {{ step_data['mode'] }} **Transition to the next step after:** * Startup completes successfully. {% endmacro %} ``` -------------------------------- ### GET /api/cmd/* Source: https://context7.com/nebhead/pifire/llms.txt This endpoint handles various control commands for the grill, such as starting modes, switching between smoke/hold/manual, enabling features, shutdown, priming the auger, and setting probe notifications. Commands are specified via path segments. Responses typically confirm execution without detailed body. ```APIDOC ## GET /api/cmd/start/startup ### Description Starts the grill in Startup mode to initialize heating. ### Method GET ### Endpoint /api/cmd/start/startup ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example curl http://pifire.local/api/cmd/start/startup ### Response #### Success Response (200) Command executed successfully. #### Response Example {"result": "success"} ## GET /api/cmd/mode/smoke ### Description Switches the grill to Smoke mode for low-temperature smoking. ### Method GET ### Endpoint /api/cmd/mode/smoke ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example curl http://pifire.local/api/cmd/mode/smoke ### Response #### Success Response (200) Mode switched successfully. #### Response Example {"result": "success"} ## GET /api/cmd/mode/hold/{setpoint} ### Description Switches to Hold mode with a specified temperature setpoint in degrees. ### Method GET ### Endpoint /api/cmd/mode/hold/{setpoint} ### Parameters #### Path Parameters - **setpoint** (integer) - Required - Target temperature for hold mode. #### Query Parameters None #### Request Body None ### Request Example curl http://pifire.local/api/cmd/mode/hold/225 ### Response #### Success Response (200) Mode and setpoint updated. #### Response Example {"result": "success"} ## GET /api/cmd/s_plus/on ### Description Enables the Smoke Plus feature for enhanced smoke production. ### Method GET ### Endpoint /api/cmd/s_plus/on ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example curl http://pifire.local/api/cmd/s_plus/on ### Response #### Success Response (200) Feature enabled. #### Response Example {"result": "success"} ## GET /api/cmd/shutdown ### Description Initiates a safe shutdown of the grill operations. ### Method GET ### Endpoint /api/cmd/shutdown ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example curl http://pifire.local/api/cmd/shutdown ### Response #### Success Response (200) Shutdown initiated. #### Response Example {"result": "success"} ## GET /api/cmd/prime/{grams} ### Description Primes the auger with a specified amount of pellets in grams. ### Method GET ### Endpoint /api/cmd/prime/{grams} ### Parameters #### Path Parameters - **grams** (integer) - Required - Amount of pellets to prime. #### Query Parameters None #### Request Body None ### Request Example curl http://pifire.local/api/cmd/prime/60 ### Response #### Success Response (200) Priming started. #### Response Example {"result": "success"} ## GET /api/set/notify/{probe}/{temp}/{action} ### Description Sets a notification for a probe reaching a temperature, with an action like shutdown. ### Method GET ### Endpoint /api/set/notify/{probe}/{temp}/{action} ### Parameters #### Path Parameters - **probe** (string) - Required - Probe identifier (e.g., probe1). - **temp** (integer) - Required - Target temperature. - **action** (string) - Required - Action on reach (e.g., shutdown). #### Query Parameters None #### Request Body None ### Request Example curl http://pifire.local/api/set/notify/probe1/165/shutdown ### Response #### Success Response (200) Notification set. #### Response Example {"result": "success"} ``` -------------------------------- ### OS Information Display in Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/admin/templates/admin/index.html Shows OS name, version, codename, architecture. Purpose: Display operating system details. Depends on system_info['os_info']; inputs: PRETTY_NAME, VERSION, VERSION_CODENAME, BITS, ARCHITECTURE; outputs nested HTML list. Limitations: Static formatting for OS data. ```jinja2 **OS Info:** * **{{ system_info['os_info']['PRETTY_NAME'] }}** * Version: {{ system_info['os_info']['VERSION'] }} * Codename: {{ system_info['os_info']['VERSION_CODENAME'] }} * Architecture: {{ system_info['os_info']['BITS'] }} ({{ system_info['os_info']['ARCHITECTURE'] }}) ``` -------------------------------- ### Dynamic supervisor link generation Source: https://github.com/nebhead/pifire/blob/main/auto-install/nginx/server_error.html JavaScript code that dynamically builds a supervisor WebUI link using the current hostname and default port 9001. Useful for server management when installed. ```JavaScript const supervisorLink = document.getElementById('supervisorLink'); const currentHostname = window.location.hostname; const supervisorPort = "9001"; supervisorLink.href = `http://${currentHostname}:${supervisorPort}`; ``` -------------------------------- ### GET /api/wled_discover Source: https://context7.com/nebhead/pifire/llms.txt Discovers WLED devices on the local network and returns their names and IP addresses. Use the optional timeout query parameter to control the discovery duration. ```APIDOC ## GET /api/wled_discover ### Description Discovers WLED devices on the local network. Returns a list of reachable WLED devices with their names and IP addresses. ### Method GET ### Endpoint /api/wled_discover ### Parameters #### Query Parameters - **timeout** (integer) - Optional - Time in seconds to wait for device responses. ### Request Example GET /api/wled_discover?timeout=10 ### Response #### Success Response (200) - **result** (string) - Result status, e.g., "success". - **count** (integer) - Number of devices found. - **devices** (array) - List of device objects. #### Response Example { "result": "success", "count": 2, "devices": [ {"name": "WLED-Device1", "ip": "192.168.1.100"}, {"name": "WLED-Device2", "ip": "192.168.1.101"} ] } ``` -------------------------------- ### Render Recipe Edit Instructions Macro - Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/recipes/templates/recipes/_macro_recipes.html Macro to render the instructions editing section for a recipe, showing directions, used ingredients, and program steps. Requires recipe_data dict with instructions and ingredients. Outputs detailed HTML with loops; maps instructions to ingredients and steps. Complex rendering but static; does not support editing directly in the snippet provided. ```jinja2 {% macro render_recipe_edit_instructions(recipe_data) %} Instructions {% for item in recipe_data['recipe']['instructions'] %} {% endfor %} Direction Ingredients Used Program Step Actions {{ item['text'] }} {% for ingredient in recipe_data['recipe']['ingredients'] %} {{ ingredient['name'] }} {% endfor %} {% for step in recipe_data['recipe']['steps'] %} {% if loop.index0 == 0 %} Prep {% else %} Step {{ loop.index0 }} {% endif %} {% endfor %} {% endmacro %} ``` -------------------------------- ### Render Wizard Card Macro (Jinja2) Source: https://github.com/nebhead/pifire/blob/main/blueprints/wizard/templates/wizard/_macro_wizard_card.html Renders a complete wizard card with module information, including image, name, description, notes, and configuration settings. It iterates through dependencies and configuration items to display options and their details. Dependencies: url_for. ```Jinja2 {% macro render_wizard_card(moduleData, moduleSection, moduleSettings) %} ![]({{ url_for('static', filename='img/wizard/' + moduleData['image']) }}) ##### {{ moduleData['friendly_name'] }} {{ moduleData['description'] }} {% if moduleData['notes'] %} NOTE: _{{ moduleData['notes'] }}_ {% endif %} {% if moduleData['settings_dependencies'] != {} or (moduleData['config'] is defined and moduleData['config'] != []) %} {% for setting in moduleData['settings_dependencies'] %} {% endfor %} {% if moduleData['config'] is defined %} {% for config_item in moduleData['config'] %} {% endfor %} {% endif %} Setting Options Description {{ moduleData['settings_dependencies'][setting]['friendly_name'] }} {% for option in moduleData['settings_dependencies'][setting]['options'] %} {{ moduleData['settings_dependencies'][setting]['options'][option] }} {% endfor %} {{ moduleData['settings_dependencies'][setting]['description'] }} {{ config_item['option_friendly_name'] }} {% if config_item['option_type'] == 'list' %} {{ render_option_list(moduleSection, config_item['option_name'], config_item['default'], config_item['list_values'], config_item['list_labels']) }} {% elif config_item['option_type'] == 'string' %} {{ render_option_string(moduleSection, config_item['option_name'], config_item['default']) }} {% endif %} {{ config_item['option_description'] }} {% endif %} {% endmacro %} ``` -------------------------------- ### GET /api/sys/* Source: https://context7.com/nebhead/pifire/llms.txt System commands for managing the underlying Raspberry Pi and PiFire services, including reboot, restart, and other maintenance tasks. These endpoints trigger system-level operations. Use with caution as they affect availability. ```APIDOC ## GET /api/sys/reboot ### Description Reboots the Raspberry Pi hosting the PiFire system. ### Method GET ### Endpoint /api/sys/reboot ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example curl http://pifire.local/api/sys/reboot ### Response #### Success Response (200) Reboot initiated. #### Response Example {"result": "success"} ## GET /api/sys/restart ### Description Restarts the PiFire services without rebooting the hardware. ### Method GET ### Endpoint /api/sys/restart ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example curl http://pifire.local/api/sys/restart ### Response #### Success Response (200) Services restarted. #### Response Example {"result": "success"} ``` -------------------------------- ### Define grill recipe in Python Source: https://context7.com/nebhead/pifire/llms.txt Creates a structured recipe for smoking brisket with multiple temperature phases. Includes metadata and step-by-step instructions with durations, target temperatures, and probe configurations. ```python recipe_data = { 'metadata': { 'title': 'Smoked Brisket', 'description': 'Low and slow brisket recipe', 'duration': 720 # Total minutes }, 'steps': [ { 'mode': 'Startup', 'duration': 10, # minutes 'message': 'Starting up the grill' }, { 'mode': 'Smoke', 'duration': 180, 'hold_temp': 180, 's_plus': True, 'message': 'Smoking at 180°F with Smoke Plus' }, { 'mode': 'Hold', 'duration': 360, 'hold_temp': 225, 'probe_name': 'probe1', 'probe_target': 165, 'trigger_temps': True, # Advance when probe reaches target 'message': 'Holding at 225°F until probe reaches 165°F' }, { 'mode': 'Hold', 'duration': 120, 'hold_temp': 250, 'probe_name': 'probe1', 'probe_target': 203, 'trigger_temps': True, 'message': 'Final push to 203°F' }, { 'mode': 'Shutdown', 'duration': 10, 'message': 'Shutting down' } ] } ``` ```python import json with open('./recipes/brisket.json', 'w') as f: json.dump(recipe_data, f) ``` -------------------------------- ### GET /api/hopper Source: https://context7.com/nebhead/pifire/llms.txt Retrieves the current hopper level and pellet type information for monitoring fuel status. This is useful for ensuring sufficient pellets before long cooks. Returns JSON with percentage level and pellet details. ```APIDOC ## GET /api/hopper ### Description Fetches the hopper's current pellet level and type from the pellet database. ### Method GET ### Endpoint /api/hopper ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example curl http://pifire.local/api/hopper ### Response #### Success Response (200) - **hopper_level** (integer) - Percentage of hopper filled. - **hopper_pellets** (string) - Name of current pellets. #### Response Example { "hopper_level": 75, "hopper_pellets": "Traeger Hickory" } ``` -------------------------------- ### Initialize UI and Navigation in JavaScript Source: https://github.com/nebhead/pifire/blob/main/blueprints/settings/templates/settings/index.html This JavaScript code initializes the page's UI on document ready, enabling navigation link clicks to collapse the settings menu. It depends on jQuery for DOM manipulation and assumes a Bootstrap-based navbar with ID 'settingsNav'. Inputs are user clicks; outputs are UI state changes. Limitations include reliance on jQuery and specific element IDs. ```javascript var dc_fan_enabled = "{{ settings['platform']['dc_fan'] }}"; $(document).ready(function() { $('#settingsNav .nav-link').on('click', function() { $('#settingsNav').collapse('hide'); }); }); ``` -------------------------------- ### Flask Web Server Setup - PiFire Source: https://context7.com/nebhead/pifire/llms.txt Initialize Flask web application with SocketIO support and register modular blueprints for API endpoints. Runs independently on port 80 to serve user interface and REST API. ```python # app.py - Flask Web Server (Runs independently on port 80) from flask import Flask from flask_socketio import SocketIO app = Flask(__name__) socketio = SocketIO(app, cors_allowed_origins="*") # Register all blueprints for modular routing app.register_blueprint(api_bp, url_prefix='/api') app.register_blueprint(dash_bp, url_prefix='/dash') app.register_blueprint(settings_bp, url_prefix='/settings') # ... 15 more blueprints if __name__ == '__main__': socketio.run(app, host='0.0.0.0') ``` -------------------------------- ### Render Controller Configuration Macro in Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/settings/templates/settings/_macro_settings.html This macro generates HTML for displaying a selected controller's image, metadata (description, author, link, contributors, attributions), and configuration options based on the provided metadata and settings. It supports various input types (float/int, bool, list/numlist, string) via sub-macros and includes a table for cycle settings recommendations like cycle time, min/max ratios. Dependencies include Jinja2 environment with url_for for static files; inputs are selected controller key, metadata dict, settings dict, cycle_data; outputs HTML snippet; limitations include reliance on predefined metadata structure and no validation for missing keys. ```jinja2 {% macro render_controller_config(selected, metadata, settings, cycle_data) %} {% if metadata[selected]['image'] != "" %} ![]({{ url_for('static', filename='img/controller/' + metadata[selected]['image']) }}) {% else %} ![]({{ url_for('static', filename='img/controller/none.jpg') }}) {% endif %} **Description:** {{ metadata[selected]['description'] }} **Original Author:** {{ metadata[selected]['author'] }} {% if metadata[selected]['link'] != "" %} **Link to Homepage:** [{{ metadata[selected]['link'] }}]({{ metadata[selected]['link'] }}) {% endif %} {% if metadata[selected]['contributors'] != [] %} **Contributors:** {% for contributor in metadata[selected]['contributors'] %}{% if loop.index0 != 0 %}, {% endif %}{{ contributor }}{% endfor %} {% endif %} {% if metadata[selected]['attributions'] != [] %} **Attributions:** {% for attribution in metadata[selected]['attributions'] %} {% if loop.index0 != 0 %}, {% endif %} {{ attribution }} {% endfor %} {% endif %} {% if metadata[selected]['config'] != [] %} {% for option in metadata[selected]['config'] %} {% endfor %} Option Setting Description {{ option['option_friendly_name'] }} {% if option['option_type'] == 'float' or option['option_type'] == 'int' %} {{ render_input_float_int(option['option_friendly_name'], option['option_name'], settings['config'][selected][option['option_name']], option['option_min'], option['option_max'], option['option_step']) }} {% elif option['option_type'] == 'bool' %} {{ render_input_bool(option['option_friendly_name'], option['option_name'], value=settings['config'][selected][option['option_name']]) }} {% elif option['option_type'] == 'list' or option['option_type'] == 'numlist' %} {{ render_input_list(option['option_friendly_name'], option['option_name'], settings['config'][selected][option['option_name']], option['option_list'], option['option_list_labels']) }} {% else %} {{ render_input_string(option['option_friendly_name'], option['option_name'], settings['config'][selected][option['option_name']]) }} {% endif %} {{ option['option_description'] }} {% else %} _**Note:** No configuration options are exposed for this controller._ {% endif %} Controller Cycle Settings _For each controller, you can set certain cycle settings, like the cycle time (length of time between controller sampling temperature and adjusting the amount of auger ON time). To use the recommended values for the currently selected controller, click on the button in the recommended column._ Setting Value Default Description Cycle Time (s) {{ metadata[selected]['recommendations']['cycle']['cycle_time'] }} Amount of seconds for a complete cycle. At the beginning of each cycle, the controller will check the current temperature and set point to determine the cycle ratio (auger ON time / auger OFF time). [Default={{ metadata[selected]['recommendations']['cycle']['cycle_time'] }}] Min Cycle Ratio {{ metadata[selected]['recommendations']['cycle']['cycle_ratio_min'] }} Minimum percentage of cycle where the auger is on. This is to prevent flame-out which can happen with a cycle ratio of less than 0.1. (0.0 - 0.99) [Default={{ metadata[selected]['recommendations']['cycle']['cycle_ratio_min'] }}] Max Cycle Ratio {{ metadata[selected]['recommendations']['cycle']['cycle_ratio_max'] }} Maximum percentage of cycle where the auger is on. This is to minimize possible overshoots, or overcompensation in temperature. (0.0 - 1.0) [Default={{ metadata[selected]['recommendations']['cycle']['cycle_ratio_max'] }}] {% endmacro %} ``` -------------------------------- ### Display recipe images with selection highlighting Source: https://github.com/nebhead/pifire/blob/main/blueprints/recipes/templates/recipes/_recipe_assets.html Jinja2 template loop that iterates through recipe assets to display images with conditional highlighting based on selection status. Each image is rendered with a URL generated by the url_for function, and selection state is determined through conditional template logic. Requires recipe_data context with assets array and selected items list. ```html {% for asset in recipe_data['assets'] %} ![Recipe Image]({{ url_for('static', filename='img/tmp/'+recipe_data['metadata']['id']+'/'+asset['filename']) }}) {% if asset['filename'] in selected %} {% set highlight = 'true' %} {% else %} {% set highlight = 'false' %} {% endif %} {% if highlight == 'true' %} {% else %} {% endif %} {% endfor %} ``` -------------------------------- ### Render Shutdown Mode Metrics in Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/metrics/templates/metrics/_macro_metrics.html This macro formats and displays basic metrics for the 'Shutdown' mode. It primarily shows the 'Start Time' (which in this context represents the shutdown initiation time) and the raw metric data. Assumes 'metric' is a dictionary. ```Jinja2 {% macro render_shutdown(metric, units) %} **Shutdown Mode** Metric Value Converted Start Time {{ metric['starttime'] }} {{ metric['starttime_c'] }} End Time {{ metric['endtime'] }} {{ metric['endtime_c'] }} Time in Mode {% if metric['endtime'] == 0 %} -- {% else %} {{ metric['endtime'] - metric['starttime'] }} {% endif %} {{ metric['timeinmode'] }} Raw Data {{ metric }} {% endmacro %} ``` -------------------------------- ### Render Probe Devices and Ports Source: https://github.com/nebhead/pifire/blob/main/blueprints/wizard/templates/wizard/wizard.html Renders UI components for probe device configuration and port mappings using imported macros. Takes probe mapping data and module information as parameters to generate appropriate configuration interfaces. ```Jinja2 {{ render_probe_devices(wizardInstallInfo['probe_map'], wizardData['modules']['probes']) }} {{ render_probe_ports(wizardInstallInfo['probe_map'], wizardData['modules']['probes']) }} ``` -------------------------------- ### Jinja2 Macro for Rendering Time Elapsed Card Source: https://github.com/nebhead/pifire/blob/main/blueprints/dash/templates/default/_macro_dash_default.html Renders an HTML card displaying elapsed time since start in HH:MM:SS format. No inputs required. Outputs simple HTML markup. Depends on Jinja2 templating. Limitations: Static placeholder '--'; does not compute actual time. ```Jinja2 {% macro render_time_elapsed_card() %}   Time Elapsed Since Start **--** ======= HH:MM:SS {% endmacro %} ``` -------------------------------- ### Import Settings Input Macros Source: https://github.com/nebhead/pifire/blob/main/blueprints/wizard/templates/wizard/wizard.html Imports various input rendering macros for settings configuration including float/int inputs, boolean toggles, lists, and string inputs. These macros provide standardized UI components for different data types. ```Jinja2 {% from 'settings/_macro_settings.html' import render_input_float_int, render_input_bool, render_input_list, render_input_string %} ``` -------------------------------- ### Render conditional image selection instructions Source: https://github.com/nebhead/pifire/blob/main/blueprints/recipes/templates/recipes/_recipe_assets.html Jinja2 template code that displays different instructional text based on the section parameter for recipe image management. Uses conditional statements to show context-specific messages for splash images, ingredients, instructions, or deletion operations. Requires Jinja2 templating engine and appropriate template context variables. ```html {% if section == 'splash' %} Select Image for the Recipe Splash Image. {% elif section == 'ingredients' %} Select Image(s) for the {{ recipe_data['recipe']['ingredients'][section_index]['name'] }} ingredient. {% elif section == 'instructions' %} Select Image(s) for item {{ section_index }} in instructions. {% elif section == 'delete' %} Select Image(s) to delete from "{{ recipe_data['metadata']['title'] }}" ({{ recipe_filename }}). {% else %} Select Image(s). {% endif %} ``` -------------------------------- ### Render Reignite Mode Metrics in Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/metrics/templates/metrics/_macro_metrics.html This macro formats and displays detailed metrics for the 'Reignite' mode of a grill. It includes start/end times, time in mode, auger on time, estimated pellet usage, and smart start profile data, similar to the startup mode. It assumes the 'metric' input is a dictionary. ```Jinja2 {% macro render_reignite(metric, units) %} **{{ metric['mode'] }} Mode** Metric Value Converted Start Time {{ metric['starttime'] }} {{ metric['starttime_c'] }} End Time {{ metric['endtime'] }} {{ metric['endtime_c'] }} Time in Mode {% if metric['endtime'] == 0 %} -- {% else %} {{ metric['endtime'] - metric['starttime'] }} {% endif %} {{ metric['timeinmode'] }} Auger On Time {{ metric['augerontime'] }} {{ metric['augerontime_c'] }} Estimated Pellet Usage {{ metric['estusage_m'] }} {{ metric['estusage_i'] }} Smart Start Profile {{ metric['smart_start_profile'] }} {{ metric['smart_start_profile'] }} Smart Startup Temp {{ metric['startup_temp'] }} {{ metric['startup_temp'] }}{{ units }} P Mode {{ metric['p_mode'] }} {{ metric['p_mode'] }} Auger Cycle Time {{ metric['auger_cycle_time'] }} {{ metric['auger_cycle_time'] }}s Raw Data {{ metric }} {% endmacro %} ``` -------------------------------- ### Import Probe Configuration Macros Source: https://github.com/nebhead/pifire/blob/main/blueprints/wizard/templates/wizard/wizard.html Imports probe device and port configuration macros from the probe configuration macro template. These macros are used to render UI elements for configuring temperature probe devices and their port mappings. ```Jinja2 {% from 'probeconfig/_macro_probes_config.html' import render_probe_devices, render_probe_ports %} ``` -------------------------------- ### Control Recipe Step Mode Selection (JavaScript) Source: https://github.com/nebhead/pifire/blob/main/blueprints/recipes/templates/recipes/_macro_recipes.html This JavaScript code snippet handles the change event for a recipe step mode select element. It dynamically shows or hides the hold group section based on whether the 'Hold' mode is selected. This is crucial for controlling the UI based on user choices in the recipe setup. ```javascript $("#recipe\_step\_mode\_select\_{{ step\_number }}").change(function(){ var recipe\_step\_mode = $("#recipe\_step\_mode\_select\_{{ step\_number }}").find(":selected").val(); if( recipe\_step\_mode == 'Hold') { $("#recipe\_step\_hold\_group\_{{ step\_number }}").slideDown(); } else { $("#recipe\_step\_hold\_group\_{{ step\_number }}").slideUp(); }; }); ``` -------------------------------- ### GPIO Outputs and Inputs Configuration Table in Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/admin/templates/admin/index.html Generates tables for GPIO outputs and inputs using sorted items. Purpose: Display pin assignments. Depends on settings['platform']['outputs'] and ['inputs']; inputs: dict of index to pin; outputs simple HTML tables. Limitations: Empty loops if no data; sorting alphabetical. ```jinja2 #####   GPIO Input/Output Info {% for index, data in settings['platform']['outputs'].items()|sort %} {% endfor %} Output Name Output Pin {{ index }} {{ settings['platform']['outputs'][index] }} {% for index, data in settings['platform']['inputs'].items()|sort %} {% endfor %} Input Name Input Pin {{ index }} {{ settings['platform']['inputs'][index] }} ``` -------------------------------- ### Render Smoke Mode Metrics in Jinja2 Source: https://github.com/nebhead/pifire/blob/main/blueprints/metrics/templates/metrics/_macro_metrics.html This macro formats and displays metrics for the 'Smoke' mode. It includes start/end times, time in mode, auger on time, estimated pellet usage, smoke plus status, and smart start profile. It handles conditional display for 'Smoke Plus' status. Assumes 'metric' is a dictionary. ```Jinja2 {% macro render_smoke(metric, units) %} **Smoke Mode** Metric Value Converted Start Time {{ metric['starttime'] }} {{ metric['starttime_c'] }} End Time {{ metric['endtime'] }} {{ metric['endtime_c'] }} Time in Mode {% if metric['endtime'] == 0 %} -- {% else %} {{ metric['endtime'] - metric['starttime'] }} {% endif %} {{ metric['timeinmode'] }} Auger On Time {{ metric['augerontime'] }} {{ metric['augerontime_c'] }} Estimated Pellet Usage {{ metric['estusage_m'] }} {{ metric['estusage_i'] }} Smoke Plus {{ metric['smokeplus'] }} {% if metric['smokeplus'] == True %} Active {% else %} Disabled {% endif %} Smart Start Profile {{ metric['smart_start_profile'] }} {{ metric['smart_start_profile'] }} Smart Startup Temp {{ metric['startup_temp'] }} {{ metric['startup_temp'] }}{{ units }} P Mode {{ metric['p_mode'] }} {{ metric['p_mode'] }} Auger Cycle Time {{ metric['auger_cycle_time'] }} {{ metric['auger_cycle_time'] }}s Raw Data {{ metric }} {% endmacro %} ``` -------------------------------- ### Discover WLED Devices in JavaScript Source: https://github.com/nebhead/pifire/blob/main/blueprints/settings/templates/settings/index.html This asynchronous function initiates WLED device discovery by updating button state and making a fetch API call to '/api/wled_discover' with a timeout. It depends on a button element for UI feedback and handles responses to display results or errors. Inputs include button clicks; outputs are API calls and UI updates. Limitations include browser fetch support and specific endpoint assumptions. ```javascript function discoverWLEDDevices() { var button = document.getElementById('wled_discover_btn'); var originalText = button.innerHTML; // Show loading state button.disabled = true; button.innerHTML = '  Discovering...'; // Hide previous results hideDiscoveryResults(); // Make API call to discover devices fetch('/api/wled_discover?timeout=15') .then(response => response.json()) .then(data => { if (data.result === 'success') { displayDiscoveredDevices(data.devices); } else { showWLEDError(data.message || 'Failed to discover WLED devices'); } }) .catch(error => { showWLEDError('Network error during WLED discovery: ' + error.message); }) .finally(() => { // Restore button state button.disabled = false; button.innerHTML = originalText; }); } ```