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

[MainUI] Create a Rule Template Builder under Developer Tools #3012

Open
rkoshak opened this issue Jan 13, 2025 · 0 comments
Open

[MainUI] Create a Rule Template Builder under Developer Tools #3012

rkoshak opened this issue Jan 13, 2025 · 0 comments
Labels
enhancement New feature or request main ui Main UI

Comments

@rkoshak
Copy link

rkoshak commented Jan 13, 2025

The problem

Creating a rule template is a tedious and error-prone process, and much of it has to be done in public. My typical workflow to create a new rule template is as follows:

  1. Write a rule on my local system and test that it works.
  2. Open the code tab and copy that code to VSCode.
  3. Manually add in the property sections for each of the configuration properties and add in the replacement strings to the rule itself (i.e. the "{{propname}}" stuff).
  4. Create a new post on the marketplace and copy/paste the YAML into the template as required.
  5. Try to install the template and fail due to inevitable typos and mistakes in the properties section. Repeat steps 3-5 as required all the while hoping someone else doesn't try to install it in the meantime (even though it's not published they can still install it if "show unpublished" is enabled.
  6. If you are me, add the published tag. If you are not a moderator wait for some moderator to add the published tag.
  7. Once it seems to be working, move the code to GitHub so it's easier to maintain in the long run.

Updating the rule template process is:

  1. Edit the code of a rule that is created from the template.
  2. Manually insert the changes to the published rule template.
  3. Try to install the rule modified rule template and instantiate a new rule based on the template.
  4. Repeat steps 2-3 as necessary to fix typos and bugs. Again, hope someone doesn't try to install it while you are working on it. If you are me you can reduce that likelihood by removing the published tag. Most users do not have that option.

Your suggestion

Add a tool similar to Developer Tools -> Widgets to create and test out rule templates. The preview pane, if kept, can show how the properties will render or simply removed as unneeded. Must have features:

  • list installed templates
  • ability to see and edit the YAML for a template
  • parse the template and report syntax errors, even if just syntax errors for the properties
  • a template created here should be usable to create new rules from (i.e. they appear in the list of templates same as templates installed from the marketplace for testing

Nice to have features:

  • screen that looks similar to the regular rule editor on MainUI with triggers, actions, and conditions sections with the addition of a section to set properties
  • a wizard or form or something a little more constrained to define properties so one doesn't need to review the developer docs to figure out what is and is not possible; this could be useful for Widgets too. Adding a link to the XML config docs would be helpful at a minimum, though they take a good deal of "translation" to convert from the XML used by bindings to the YAML used by widgets and templates.
  • preview of the form that will render when creating the template
  • preview of the code that will be generated when creating a rule from the template

With this tool, template developers can have some help in developing the code, and the debug loop can be done in private instead of in public. It should also enable the ability to locally develop and use tempaltes.

Your environment

runtimeInfo:
  version: 4.3.1
  buildString: Release Build
locale: en-US
systemInfo:
  configFolder: /openhab/conf
  userdataFolder: /openhab/userdata
  logFolder: /openhab/userdata/logs
  javaVersion: 17.0.13
  javaVendor: Debian
  osName: Linux
  osVersion: 6.8.0-51-generic
  osArchitecture: amd64
  availableProcessors: 4
  freeMemory: 283625608
  totalMemory: 746586112
  uptime: 324084
  startLevel: 70
addons:
  - automation-jsscripting
  - automation-pidcontroller
  - binding-amazonechocontrol
  - binding-astro
  - binding-chromecast
  - binding-http
  - binding-ipcamera
  - binding-mail
  - binding-mqtt
  - binding-network
  - binding-networkupstools
  - binding-openweathermap
  - binding-shelly
  - binding-vesync
  - binding-zigbee
  - binding-zwave
  - misc-openhabcloud
  - persistence-mapdb
  - persistence-rrd4j
  - transformation-basicprofiles
  - transformation-jinja
  - transformation-jsonpath
  - transformation-map
  - transformation-regex
  - ui-basic
  - ui-habot
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    pixelRatio: 0.8999999761581421
    prefersColorScheme: light
  isSecureContext: true
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: 8
    hardwareConcurrency: 16
    language: en-US
    languages:
      - en-US
      - en
    onLine: true
    platform: Linux x86_64
  screen:
    width: 2560
    height: 1600
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
    blocklyRenderer: null
  userAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
    Gecko) Chrome/131.0.0.0 Safari/537.36
timestamp: 2025-01-13T16:52:22.097Z

Additional information

@rkoshak rkoshak added enhancement New feature or request main ui Main UI labels Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

No branches or pull requests

1 participant