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

Main UI rule triggers when click edit rule if trigger is set to "when system has reached level 70" #2027

Closed
marioschouten opened this issue Aug 19, 2023 · 8 comments · Fixed by #2203
Assignees
Labels
bug Something isn't working main ui Main UI

Comments

@marioschouten
Copy link

marioschouten commented Aug 19, 2023

The problem

When I'm editing rules in the Main-UI normally when you click on "Execute a given script" it opens the script so you can edit it. This behaviour is different when the rule has the trigger "when the system has reached level 70". In that case it runs the rule and you need to click several times to be able to open the scrip to edit, when you save it, it runs the rule again
image

Expected behavior

When editing /saving a rule it should not start the rule, only when saving or manually starting the rule.

Steps to reproduce

  1. Create a rule with trigger "when the system has reached level 70" in OH 4.0.2

Your environment


runtimeInfo:
  version: 4.0.2
  buildString: Release Build
locale: en-TH
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 17.0.8
  javaVendor: Debian
  osName: Linux
  osVersion: 6.1.0-11-amd64
  osArchitecture: amd64
  availableProcessors: 4
  freeMemory: 307486416
  totalMemory: 1507852288
  startLevel: 70
bindings: null
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: true
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: windows
    pixelRatio: 1
    prefersColorScheme: light
  isSecureContext: true
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: 8
    hardwareConcurrency: 4
    language: en-GB
    languages:
      - en-GB
      - th-TH
      - th
      - nl-NL
      - nl
    onLine: true
    platform: Win32
  screen:
    width: 3440
    height: 1440
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: dark
    filled: true
    pageTransitionAnimation: disabled
    bars: light
    homeNavbar: simple
    homeBackground: standard
    expandableCardAnimation: disabled
  userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
    like Gecko) Chrome/116.0.0.0 Safari/537.36
timestamp: 2023-08-19T04:50:42.334Z

Browser console

Browser network traffic

Additional information

@marioschouten marioschouten added bug Something isn't working main ui Main UI labels Aug 19, 2023
@marioschouten marioschouten changed the title Main UI rule triggerss when click edit/save rule if trigger is set to "when system has reached level 70" Main UI rule triggers when click edit/save rule if trigger is set to "when system has reached level 70" Aug 19, 2023
@rkoshak
Copy link

rkoshak commented Aug 21, 2023

When editing/saving a rule it should not start the rule, only when triggered or manually starting the rule.

To be clear, with the behavior of system started/runlevel triggers in OH 4, the rule will trigger when it's saved. That's expected and correct behavior.

However, merely clicking on the rule or a script action should not trigger the rule. Such rule should only be triggered on saving the rule. That's the bug here. The rule triggers even without changing anything meaning the rule should not be reloaded and therefore should not trigger.

@marioschouten marioschouten changed the title Main UI rule triggers when click edit/save rule if trigger is set to "when system has reached level 70" Main UI rule triggers when click edit rule if trigger is set to "when system has reached level 70" Aug 22, 2023
@marioschouten
Copy link
Author

Thanks, see what you mean and makes sense. Updated accordingly.

@d51x
Copy link
Contributor

d51x commented Sep 29, 2023

image
I encountered the same problem today, clicked the item with phrase "execute a given script" to edit the rule, and script started. after 20 sec (badge RUNNING) after 20 seconds the script editing form opened

@rkoshak
Copy link

rkoshak commented Sep 29, 2023

I encountered the same problem today, clicked the item with phrase "execute a given script" to edit the rule, and script started. after 20 sec (badge RUNNING) after 20 seconds the script editing form opened

The 20 sec issue is known. See openhab/openhab-addons#15600. There is some evidence that using a 64-bit Java will reduce that initial run of the rule down to 2 seconds.

@d51x
Copy link
Contributor

d51x commented Sep 29, 2023

I encountered the same problem today, clicked the item with phrase "execute a given script" to edit the rule, and script started. after 20 sec (badge RUNNING) after 20 seconds the script editing form opened

The 20 sec issue is known. See openhab/openhab-addons#15600. There is some evidence that using a 64-bit Java will reduce that initial run of the rule down to 2 seconds.

the point is not in 20 seconds, but in the fact that the rule is launched instead of editing

@florian-h05
Copy link
Contributor

The problem is, that the script code editor is opened in a new page, before which the UI saves the rule.
With the changed behaviour of the start level trigger, the rule triggers immediate if the start level is already reached.

I guess the only solution would be to make the script editing happening in a way that the rule does not need to be saved.

@rkoshak
Copy link

rkoshak commented Oct 16, 2023

I guess the only solution would be to make the script editing happening in a way that the rule does not need to be saved.

Could it keep track of whether anything has changed (e.g. triggers) and only save if there is something to save? Even better ask if unsaved changes should be saved before opening the code editor.

@florian-h05
Copy link
Contributor

florian-h05 commented Oct 16, 2023

I thought about this issue a bit, and yes, this should be possible.

@florian-h05 florian-h05 self-assigned this Oct 25, 2023
florian-h05 added a commit to florian-h05/openhab-webui that referenced this issue Dec 7, 2023
Fixes openhab#2027.

When a script inside a rule was opened, the UI always saved the rule before navigating to the script editor.
With this fix, the rule is only saved if there is a change to save. If the rule hasn't been changed, no save request is performed.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05 added a commit that referenced this issue Dec 7, 2023
#2203)

Fixes #2027.

When a script inside a rule was opened, the UI always saved the rule
before navigating to the script editor. With this fix, the rule is only
saved if there is a change to save. If the rule hasn't been changed, no
save request is performed.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working main ui Main UI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants