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

Parsing Fehler in ioBroker.hm-rega/regascripts/devices.fn #414

Open
cb0b opened this issue Sep 28, 2023 · 2 comments
Open

Parsing Fehler in ioBroker.hm-rega/regascripts/devices.fn #414

cb0b opened this issue Sep 28, 2023 · 2 comments

Comments

@cb0b
Copy link

cb0b commented Sep 28, 2023

Describe the bug
Das Einlesen der Namen der HM-Devices geht auf meiner ioBroker-Installation schief. Im Log steht nur "error..." gefolgt vom eingelesenen JSON String.

To Reproduce

  1. restart rega instance via Webinterface
  2. watch the logfile for:

2023-09-28 08:47:25.289 | error | Cannot parse answer for devices: {"OEQ1715534":{"Name":"0-CorridorHeating","Interface":"BidCos-RF"}, "OEQ1715534:0":{"Name":"0-CorridorHeating%3A0","Interface":"BidCos-RF"}, .......

Den ganzen JSON-Block markieren/kopieren und in einen JSON Validator (zB https://jsonformatter.curiousconcept.com) einfügen und nach den Fehlermeldungen schauen. Da steht dann: "Expecting closing } at end (code22, structure2183)"

Expected behavior
Das JSON sollte korrekt geparsed werden, so dass die Namen der HM*Devices im ioBroker angezeigt werden können. In den Devicenamen sind weder Umlaute noch Leerzeichen. Der Trenner für die Kanäle ist auf Default (Doppelpunkt).

Screenshots & Logfiles
./.

Versions:

  • hm-rpc version: 1.15.19
  • hm-rega version: 3.0.47
  • JS-Controller version: v18.17.1
  • Node version: v9.6.7
  • Operating system: Debian11x64 (ioBroker rennt im docker)
  • CCU model: raspberry3b+
  • CCU firmware: 3.71.12.20230826(rpi)

Additional context
Ich habe kurzerhand das devices.fn (https://github.com/ioBroker/ioBroker.hm-rega/blob/master/regascripts/devices.fn) kopiert und im Test auf der Raspimatic CCU ausgeführt. Es kommt genau der selbe String wie der aus dem Logfile im ioBroker. Wenn man das dann nimmt und mit einem json validator verifiziert, kommt der Hinweis, dass da ein Komma und eine schließende geschweifte Klammer an Ende fehlen. Ich vermute dass daher auch die Exception kommt. Leider habe ich es nicht hinbekommen, das script so zu verändern, dass es die fehlende Klammer mit ausgibt.

@sw4280
Copy link

sw4280 commented Dec 14, 2023

Hallo,
ich habe heute meine Raspberrymatic und den ioBroker etc. auf die aktuellesten Versionen aktualisiert und hatte promt dasselbe Problem. Nach einiger Analyse lag das Problem bei mir nicht am "devices" rega script, sondern ich hatte noch eine device "Leiche" vom CuX-Daemon. Das script hatte am Ende keine "}" weil es davor abgebrochen wurde und deshalb auch nicht alle devices in der Ausgabe aufgelistet wurden...
Ich bin durch diese Threads im homematic-forum darauf gekommen:
https://homematic-forum.de/forum/viewtopic.php?f=37&t=39299&start=20
https://homematic-forum.de/forum/viewtopic.php?f=37&t=39299&start=10#p389715

Evtl. hilft das ja weiter...

@skleeschulte
Copy link
Contributor

skleeschulte commented Jan 2, 2024

Hallo @cb0b, ich habe ein ähnliches Problem mit functions.fn und rooms.fn (siehe #441 und #442). Falls das Problem noch besteht, versuch es doch mal mit folgender modifizierten Version von devices.fn:

!# devices.fn 1.4
!#
!# Dieses Homematic-Script gibt eine Liste aller Geraete/Kanaele als JSON String aus
!#
!# 3'2013-7'2013 hobbyquaker https://github.com/hobbyquaker
!#

string sDevId;
string sChnId;

Write('{');

boolean dFirst = true;

foreach (sDevId, root.Devices().EnumUsedIDs()) {

    object oDevice   = dom.GetObject(sDevId);
    
    ! Objekt ueberspringen, falls nicht vom Typ DEVICE (17)
    if (oDevice.Type() != 17) { continue; }
    
    boolean bDevReady = oDevice.ReadyConfig();
    string sDevInterfaceId = oDevice.Interface();
    string sDevInterface   = dom.GetObject(sDevInterfaceId).Name();
    
    if (bDevReady) {

        if (dFirst) {
          dFirst = false;
        } else {
          WriteLine(',');
        }

        Write('"' # oDevice.Address() # '":{"Name":"');
        WriteURL(oDevice.Name());
        Write('","Interface":"' # sDevInterface # '"}');
        
        foreach(sChnId, oDevice.Channels()) {
        	object oChannel = dom.GetObject(sChnId);
            
            ! Objekt ueberspringen, falls nicht vom Typ CHANNEL (33)
            if (oChannel.Type() != 33) { continue; }
            
            WriteLine(',');
          	Write('"' # oChannel.Address() # '":{"Name":"');
        	WriteURL(oChannel.Name());
        	Write('","Interface":"' # sDevInterface # '"}');
        }
      
    }
}

Write('}');

Ich habe lediglich die Zeilen if (oDevice.Type() != 17) { continue; } und if (oChannel.Type() != 33) { continue; } hinzugefügt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants