Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration NR to Device Agent #14

Open
3 tasks
MarianRaphael opened this issue Apr 25, 2023 · 1 comment
Open
3 tasks

Migration NR to Device Agent #14

MarianRaphael opened this issue Apr 25, 2023 · 1 comment
Labels
epic A significant feature or piece of work that doesn't easily fit into a single release size:XL - 8 Sizing estimation point

Comments

@MarianRaphael
Copy link

MarianRaphael commented Apr 25, 2023

Description

This epic aims to provide an effortless migration path for Node-RED users to the FlowForge Device Agent by introducing a user interface (UI) for creating and configuring the required device.yml file. The proposed solution will improve the user experience and allow quick onboarding of devices.

Story

As a Node-RED user, I want an effortless migration from Node-RED to the Device Agent. This will ensure a smooth user experience and enable users to quickly onboard their devices.

Background

Currently, the FlowForge Device Agent requires a device.yml file to run a Node-RED instance. As a result, it is challenging to preinstall the device agent on 3rd party devices because shell access for device.yml creation and configuration is necessary.

Goals

  • Detect the absence and presence of a device.yml config file
  • Allow the user to create a device.yml file via UI
  • Implement a switch option to the device agent

Original Issue

FlowFuse/device-agent#75

@MarianRaphael MarianRaphael added the epic A significant feature or piece of work that doesn't easily fit into a single release label Apr 25, 2023
@MarianRaphael MarianRaphael added the size:L - 5 Sizing estimation point label Apr 26, 2023
@MarianRaphael MarianRaphael changed the title device.yml creation for device-agent Migration NR to Device Agent Apr 26, 2023
@MarianRaphael MarianRaphael added size:XL - 8 Sizing estimation point and removed size:L - 5 Sizing estimation point labels Apr 26, 2023
@MarianRaphael MarianRaphael added this to Next 1.8 (08/06/23) in 🧭 Roadmap May 5, 2023
@MarianRaphael MarianRaphael added this to the 1.8 milestone May 5, 2023
@MarianRaphael
Copy link
Author

Implementation path Idea (feel free to change, add comments ...):

  • Add Device Agent as a Dependency

  • UI for device.yml File Creation or Modification

    • Create a new UI within the Node-RED Tools Plugin that allows users to input necessary information for creating a device.yml file. This UI should have fields for all the required options as mentioned in the device.yml file configuration section. If the device.yml file does not exist, the plugin should prompt the user to create one via this UI.
  • Implementing the Creation of device.yml File

    • When the user submits the form on the UI, the Node-RED Tools Plugin should take the user's input and write a new device.yml file
  • UI for Switch Option to Device Agent

    • Implement a UI within the Node-RED Tools Plugin that allows the user to switch to the FlowForge Device Agent from Node-RED. This UI could be a simple button that, when clicked, shuts down the Node-RED instance and starts the FlowForge Device Agent (or just starts the Device Agent).
  • Start Device Agent Programmatically (Option A)

    • To achieve this, we will need to modify the Device Agent to export its main function, so that it can be imported and run from within the nr-tools-plugin
    • If the user clicks the switch button on the UI, the nr-tools-plugin should first ensure that the configuration is valid (we could use the same UI for generating the device.yml file). Then, instead of writing a device.yml file and starting the Device Agent separately, the plugin could also call the Device Agent's main function directly with the configuration object (and in addition creates the device.yml).
    • Starting the device agent programmatically from within the Node-RED instance (via the nr-tools-plugin) means the agent's lifecycle is tied to the Node-RED instance. If we shut down the Node-RED instance, the device agent will likely also be terminated because it's running in the same process.
  • Start Device Agent as a process (Option B)

    • If we want the device agent to run independently, we need to spawn it as a separate process.

      const { spawn } = require('child_process');
      const agent = spawn('./node_modules/.bin/flowforge-device-agent', ['-c', '/path/to/device.yml']);
    • Attaching listeners to the stdout, stderr, and close events of the child process. These will log the output of the command and the exit code when the process terminates. We can use these logs to check if the command is running correctly. The output should be the same as when running the command manually.

  • Option C - Start with UI for Device Agent instead modifying the nr-tools-plugin

@MarianRaphael MarianRaphael removed this from Next 1.8 (08/06/23) in 🧭 Roadmap May 10, 2023
@MarianRaphael MarianRaphael removed this from the 1.8 milestone Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic A significant feature or piece of work that doesn't easily fit into a single release size:XL - 8 Sizing estimation point
Projects
Status: Medium
Development

No branches or pull requests

1 participant