openhab / openhab-webui

Web UIs of openHAB
Eclipse Public License 2.0
214 stars 235 forks source link

HabPanel not switching back to first dashboard #2569

Open chevdor opened 2 months ago

chevdor commented 2 months ago

Background

HabPanel allows OH to control the currently displayed Dashboard using one of the panel settings: image

It is usually defined as an item such as:

String    HabPanel_Screen          "HabPanel Screen"         <screen>         (VirtualSwitch)

The idea is that changing the content of the string, HabPanel will switch to that Dashboard, should the string match an existing Dashboard. Simple, yet very powerful.

Sample use case

I was experimenting with a simple use case that I provide here only to illustrate how I got there.

Let's consider I have 3 dashboards:

Below I will refer to Dasboards A, B and C since what they are does not matter much.

In my case, usually, HabPanel shows Main (A). When a door or window is opened, it will switch to Doors & Windows (B). After N seconds, it will come back to Main (A).

Nice story but that does not work.

The problem

The rule switching A -> B works fine. A window is opened (for instance), OH will update the HabPanel_Screen content and the B Dashboard will be shown.

So far, everthing works as expected.

The issue is related to coming back to Dashboard A. I am using a timer (but that part does not matter) and switching back to A is simply ignored.

Expected behavior

Considering 2 Dashboards both of the following work:

A being the main "default" dashboard.

Steps to reproduce

Your environment

runtimeInfo:
  version: 4.1.2
  buildString: Release Build
locale: en-DE
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 17.0.10
  javaVendor: Debian
  osName: Linux
  osVersion: 6.6.20+rpt-rpi-v8
  osArchitecture: aarch64
  availableProcessors: 4
  freeMemory: 378182888
  totalMemory: 805306368
  uptime: 233700
  startLevel: 70
addons:
  - automation-jsscripting
  - [... some more...]
  - binding-zigbee
  - binding-zwave
  - persistence-influxdb
  - persistence-mapdb
  - persistence-rrd4j
  - transformation-map
  - ui-basic
  - ui-habpanel
  - voice-voicerss
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: true
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: macos
    pixelRatio: 2.200000047683716
    prefersColorScheme: dark
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 10
    language: en-US
    languages:
      - en-US
      - de
      - en-DE
      - en-IE
      - de-DE
      - fr-FR
      - fr
      - en-GB
      - en
    onLine: true
    platform: MacIntel
  screen:
    width: 2560
    height: 1440
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: dark
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
    (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
timestamp: 2024-05-08T08:31:33.304Z

Browser console

n/a : empty

Browser network traffic

n/a : no related traffic

Additional information

It is important to notice that I run into this issue ONLY if A is the first/default dashboard. It you already have a dashboard and create 2 new dashboards for the test, it will be working all fine as it does for me.

chevdor commented 2 months ago

See also https://community.openhab.org/t/habpanel-not-switching-back-to-the-default-dashboard/155869

chevdor commented 2 months ago

I see the issue directly in the browser:

I see the URL changing but the page does not reload with A.

chevdor commented 2 months ago

I could fetch the following error in the console:

vendor.js:119 TypeError: Cannot read properties of undefined (reading 'widget_margin')
    at new DashboardViewController (http://domopi2:8080/habpanel/app/dashboard/dashboard.view.controller.js:14:32)
    at Object.instantiate (http://domopi2:8080/habpanel/vendor/vendor.js:42:109)
    at http://domopi2:8080/habpanel/vendor/vendor.js:91:374
    at Object.link (http://domopi2:8080/habpanel/vendor/vendor.js:332:274)
    at http://domopi2:8080/habpanel/vendor/vendor.js:16:71
    at sa (http://domopi2:8080/habpanel/vendor/vendor.js:82:244)
    at n (http://domopi2:8080/habpanel/vendor/vendor.js:68:6)
    at g (http://domopi2:8080/habpanel/vendor/vendor.js:59:428)
    at http://domopi2:8080/habpanel/vendor/vendor.js:59:67
    at http://domopi2:8080/habpanel/vendor/vendor.js:64:67 <main class="container ng-scope" snap-content="" snap-opt-disable="'right'" snap-opt-hyperextensible="false" ng-view="" ng-class="{ 'image-bg': settings.background_image, kiosk: kioskMode }" ng-style="{ 'background-image': (settings.background_image) ? 'url(' + settings.background_image +')' : '' }">
chevdor commented 2 months ago

I ended up deleting my "first" dashboard as I think it was "corrupted". Surprising though since I built the second dashboard by simply copying all the widgets from A to B and B works just fine. So when I mentioned "First/Default" Dashboard above is NOT relevant. The issue is that somehow, my A Dashboard got corrupted, still loads as default dashboard but does not when switched to.