logo elektroda
logo elektroda
X
logo elektroda

Grundlegende Fragen zu OpenBeken: UI-Labels, Werte speichern, MQTT und Skripting

Frank579 1896 10
Best answers LABEL_AI_GENERATED

Wie kann ich in OpenBeken UI-Labels sauber beschriften, eigene Channel-Werte speichern, MQTT-Topics mit Labels statt Kanalnummern nutzen und warum springen meine Change-Handler im Script manchmal doppelt oder unregelmäßig an?

Für die UI-Beschriftung wurden die fehlenden Labels für die Bedienelemente per PR #1327 und zusätzlich für den unlabeled Dimmer per PR #1329 nachgezogen; die Änderungen wurden später gemerged [#21199497] [#21200723] [#21201161] Für MQTT gibt es einen Ansatz, bei dem statt der Kanalnummer der Channel-Label als Topic verwendet wird: Dazu wurde `SetChannelLabel` um die Werte `2/3` erweitert, wobei `2` bzw. `3` das Label als Topic nutzt und gleichzeitig das Toggle-/Prefix-Verhalten steuert [#21210661] Dabei werden Labels validiert und unerwünschte Zeichen durch `_` ersetzt; außerdem muss Home-Assistant-Discovery mit angepasst werden, und die Änderung sollte nicht standardmäßig aktiviert werden, weil sonst bestehende Pairings brechen könnten [#21202574] [#21210661] Die Frage nach dem Speichern eigener Schalter-/Dimmerwerte wurde im Thread nicht beantwortet, und auch das unregelmäßige Triggern der Change-Handler wurde dort nicht abschließend geklärt [#21199497]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT
  • OpenBeken UI labels, value persistence, MQTT and scripting questions

    #1 21196652
    Frank579
    Level 2  
    Posts: 7
    Hallo Zusammen,

    Ich versuche gerade an einer Leuchte etwas zu Skripten. Da ich noch recht neu bei OpenBeken bin habe ich ein paar Grundlegende Fragen :)

    Fangen wir mal an.

    A: Label auf der UI
    Ich habe mir ein Paar Bedienelemente angelegt Button, Textfeld, Dimmer1000, wie bekomme ich die jetzt noch schön beschriftet, siehe Bild
    zu 1. Das ON/OFF hätte ich gerne weg den Status sieht man ha an der Farbe, analog zu Toggle Light.
    zu 2. Da hätte ich gerne nur einen Namen stehen, wenn ich es über
     SetChannelLabel 28 Laufzeit 
    versuche ändert sich nur das "Channel 28 " der Rest
    bleibt stehen, hätte ich aber auch gerne weg.
    zu 3. Da hätte ich auch gerne eine Bezeichnung zum Dimmer stehen, aber egal was ich Versuche führt nicht zum Ziel.

    User interface with buttons for lighting control.

    B: Werte Speichern.
    Wenn ich meine Selbst angelegten Schalter / dimmer einschalte / Einstelle und das gerät neu starte sind die Werte weg. gibt es eine Möglichkeit das die werte gepeichert
    werden, analog zu den werten der LED (EIN/AUS , Farbe )

    C: MQTT
    die werte der LED (ein/aus, Farbe , Dimmer ) muss ich im Topic
     Command topic: cmnd/OpenBK/Lampe-06/[Command] 
    ändern, sie reagieren nicht auf
    eine Änderung in
     Receive data topic: OpenBK/Lampe-06/[Channel]/set 
    . Bei den Selbst angelegten Ist es genau anders herum. habe ich hier was falsch
    eingestellt oder soll das so sein ???

    D: Skripting
    Ich habe mal zum anfang ein kleines Testkript geschieben um die Taster mal zu testen. Nicht wundern versuche erst mal zu verstehen was ich mache :)

    
    SetChannelLabel 29 Automatic 1
    //SetChannelLabel 28 Laufzeit
    addChangeHandler Channel29 == 1 backlog stopAllScripts; startScript LSC_Flood.bat Test1
    addChangeHandler Channel29 == 0 backlog stopAllScripts; startScript LSC_Flood.bat Test2
    Test1:
    echo "Automatik Ein"
    return
    Test2:
    echo "Automatik AUS"
    return
    


    Dann habe ich den Buttton immer wieder geschaltet über die UI. dabei ist mir im Log etwas seltsames aufgefallen. er scheint des Öfteren mal was zu "verschlucken"
    Normalerweise hätte ich erwartet Automatic Ein -Aus -Ein -Aus ..... es kommt manchmal aber auch Ein-Ein -Aus-Ein also einmal Aus vergessen oder auch mal Ein, ohne System
    Info:EVENT:EventHandlers_ProcessVariableChange_Integer: executing command backlog stopAllScripts; startScript LSC_Flood.bat Test2
    Info:CMD:CMD_StartScript: started LSC_Flood.bat at label Test2
    Info:CMD:"Automatik AUS"
    Info:CMD:CMD_Return: thread will return
    Info:EVENT:EventHandlers_ProcessVariableChange_Integer: executing command backlog stopAllScripts; startScript LSC_Flood.bat Test1
    Info:CMD:CMD_StartScript: started LSC_Flood.bat at label Test1
    Info:CMD:"Automatik Ein"
    Info:CMD:CMD_Return: thread will return
    Info:EVENT:EventHandlers_ProcessVariableChange_Integer: executing command backlog stopAllScripts; startScript LSC_Flood.bat Test1
    Info:CMD:CMD_StartScript: started LSC_Flood.bat at label Test1
    Info:CMD:"Automatik Ein"
    Info:CMD:CMD_Return: thread will return
    Info:EVENT:EventHandlers_ProcessVariableChange_Integer: executing command backlog stopAllScripts; startScript LSC_Flood.bat Test2
    Info:CMD:CMD_StartScript: started LSC_Flood.bat at label Test2
    Info:CMD:"Automatik AUS"
    Info:CMD:CMD_Return: thread will return
    Info:EVENT:EventHandlers_ProcessVariableChange_Integer: executing command backlog stopAllScripts; startScript LSC_Flood.bat Test1
    Info:CMD:CMD_StartScript: started LSC_Flood.bat at label Test1
    Info:CMD:"Automatik Ein"
    Info:CMD:CMD_Return: thread will return
    Info:EVENT:EventHandlers_ProcessVariableChange_Integer: executing command backlog stopAllScripts; startScript LSC_Flood.bat Test2
    Info:CMD:CMD_StartScript: started LSC_Flood.bat at label Test2
    Info:CMD:"Automatik AUS"
    Info:CMD:CMD_Return: thread will return
    Info:EVENT:EventHandlers_ProcessVariableChange_Integer: executing command backlog stopAllScripts; startScript LSC_Flood.bat Test1
    Info:CMD:CMD_StartScript: started LSC_Flood.bat at label Test1
    Info:CMD:"Automatik Ein"
    



    Vielen Dank fürs Lesen und vielleicht hat ja jemand zu dem ein oder anderen Punkt eine Idee :)
    Mir fällt bestimmt nach und nach noch mehr ein.

    Schönen Abend Frank
  • ADVERTISEMENT
  • Helpful post

    PR #1327 adds requested UI label support

    #2 21199497
    max4elektroda
    Level 24  
    Posts: 758
    Help: 49
    Rate: 189
    Hi,

    also, die 1. Bitte kann umgesetzt werden, ich habe dafür einen Pull Request erstellt (PR #1327). Wenn du einen GIT Account hast, kannst du dort unter "Artifacts" eine Version herunterladen:
    Diagnostic screen of the OpenLN882H_C27DD39D device showing status and channel information.

    Die 2. Bitte ist schon sehr speziell, das könnte man natürlich auch programmieren, aber dafür gibt es wahrscheinlich deutlich weniger Nutzer ...

    Dimmer nutze ich nicht - wie hast du das angelegt?

    Zum Abspeichern und den anderen Fragen bin ich leider überfragt...
  • #3 21199892
    Frank579
    Level 2  
    Posts: 7
    Hi,
    max4elektroda wrote:
    ich habe dafür einen Pull Request erstellt (PR #1327)


    WOW Dankeschön werde ich gleich mal testen :)

    max4elektroda wrote:
    Die 2. Bitte ist schon sehr speziell, das könnte man natürlich auch programmieren, aber dafür gibt es wahrscheinlich deutlich weniger Nutzer ...


    Das hat sich auch wahrscheinlich schon erledigt, hab das Feld aktuell schon nicht mehr drin ...

    max4elektroda wrote:
    Dimmer nutze ich nicht - wie hast du das angelegt?


    in der Config unter Channel Types
    Dropdown list with options: Default, Toggle, Dimmer1000

    Vielen Dank für deine Hilfe :)
  • ADVERTISEMENT
  • Helpful post

    Pull request to hide unlabeled dimmer control

    #4 21200723
    max4elektroda
    Level 24  
    Posts: 758
    Help: 49
    Rate: 189
    Ah, verstanden - das ist in der Tat nicht schön, dass der Dimmer ohne Bezeichnung sichtbar ist.

    Auch dafür hab ich einen PullRequest (https://github.com/openshwprojects/OpenBK7231T_App/pull/1329) gemacht (ist für dich schlecht, weil nur jeweils ein Punkt drin ist) aber so könnten die PR's unabhängig voneinander betrachtet und integriert werden...

    User interface screen showing toggles and a dimmer slider.
  • ADVERTISEMENT
  • Helpful post
    #5 21201161
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14771
    Help: 659
    Rate: 12914
    Sure, good idea. Good job, @max4elektroda ! Merged:
    https://github.com/openshwprojects/OpenBK7231...mmit/989ac1eb46258c62c60431889000fce237e586a5

    Is there any other way we can help you as well?
    Helpful post? Buy me a coffee.
  • #6 21201202
    Frank579
    Level 2  
    Posts: 7
    >>21200723
    max4elektroda wrote:
    Auch dafür hab ich einen PullRequest


    WOW nochmals vielen vielen Dank :)

    Dann hoffe ich mal, dass jemand noch ne Idee zu den anderen Punkten hat. werde gleich mal was weiter testen. Versuche gerade alles "Cloudlos" zu bekommen, was geht.

    Hast du evtl. eine Idee, wie ich den Channel Namen im MQTT geben kann? Da werden einige nur mit den Channel NR angezeigt.


    Screenshot showing IoT device configuration details, including firmware version, connection status, IP address, and MQTT topics.


    Gruß Frank
  • Suggests conditional channel-name formatting in MQTT publish function

    #7 21201405
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14771
    Help: 659
    Rate: 12914
    Maybe we could add a command for that... just modify this function I guess?
    Code: C / C++
    Log in, to see the code

    What do you think, @max4elektroda ?

    That part:
    Code: C / C++
    Log in, to see the code

    could be done in a conditional statement...
    Helpful post? Buy me a coffee.
  • Suggesting CHANNEL_GetLabel for MQTT topic names

    #8 21202548
    max4elektroda
    Level 24  
    Posts: 758
    Help: 49
    Rate: 189
    Couldn't we just "ignore" channelNameStr and instead use 'CHANNEL_GetLabel()' here, too?
    That should return the number as a string, if no label is given, otherwise the label.

    // String from channel number
      // sprintf(channelNameStr, "%i", channel);
    
    [...]
    
       return MQTT_PublishMain(mqtt_client, CHANNEL_GetLabel(channel), valueStr, flags, true);
    


    Or maybe first assign CHANNEL_GetLabel() to channelNameStr (with increased lenght).

    Forgive my if that will break something in MQTT, I'm really a noob in this area.
  • ADVERTISEMENT
  • Need to update HASS discovery for special labels

    #9 21202574
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14771
    Help: 659
    Rate: 12914
    What would happen for labels with special characters or spaces? Would that break stuff?

    Futhermore, I think that you would also need to modify the HASS discovery code.

    Still, I could agree for such modification if you put it under a flag that is disabled for default, at least for now. This is important because if you enable it by default, then you'll break many devices HA pairings after OTA.

    Sample snippet that we would need to update as well:
    Code: C / C++
    Log in, to see the code

    The code above is from HASS discovery implementation.
    Helpful post? Buy me a coffee.
  • Clarifying whether labels become MQTT topics

    #10 21203579
    max4elektroda
    Level 24  
    Posts: 758
    Help: 49
    Rate: 189
    So, as someone not using MQTT:
    If I got it right, sending the label instead of the (channel) number means another "topic"?
    So it's not only the display, but all requests (get/set) will need to address this topic. So this topic needs to be advertised and incoming messages need to be parsed and assigned to the channel?

    I maybe find some time to dive into this theme, but for now I'm on vacation and can start earliest in one week...
  • PR proposes publishing labels as MQTT topics

    #11 21210661
    max4elektroda
    Level 24  
    Posts: 758
    Help: 49
    Rate: 189
    O.k., I tried my very best to understand this and made PR #1336 for this.

    I tried to make the test simple:
    - introduce a new "bit-vector" g_PublishChannelLabel (like e.g. g_doNotPublishChannels) which needs to be 1 to publish the label instead of the channel
    - as a quick hack I "extended" the setChannelLabel command: it uses 0/1 to show/hide the prefix "Toggle". Now you can use 2/3 to do the same, but use labels as topic.
    (so instead of calling "SetChannelLabel 30 MeinDimmer 0" you may call "SetChannelLabel 30 MeinDimmer 2" (and "3" instead of "1" to hide the prefix)
    - I also tried to do the proposed change in hass.c, but I'm not sure, if that's the only part of code which needs adjustments...


    If the "toggle" bit is set to 2 or 3, the label will be "validated", unwanted characters are set to '_'.
    It surely would be better to use only letters and numbers anyway, I'm not sure, if this really conversion is sufficient.

    BTW: If I change an existing label, at least my W800 sometimes crashes (with different results: sometimes network seems "gone", but serial log is working, somtimes it just restarts, once I saw "mem_free_debug ptr error!!!!!"

    Info:CMD:[WebApp Cmd 'SetChannelLabel 30 "Mein Dimmer !&%8()=~§?" 0' Result] OK
    Info:MAIN:Time 235, idle 0/s, free 29496, MQTT 1(2), bWifi 1, secondsWithNoPing 1, socks 2/8 
    Info:MAIN:Time 236, idle 0/s, free 29496, MQTT 1(2), bWifi 1, secondsWithNoPing 1, socks 2/8 
    Info:MAIN:Time 237, idle 0/s, free 29496, MQTT 1(2), bWifi 1, secondsWithNoPing 1, socks 2/8 
    mem_free_debug ptr error!!!!!
    err 
    mem_free_debug ptr error!!!!!
    err 
    Info:MAIN:Time 238, idle 0/s, free 29496, MQTT 1(2), bWifi 1, secondsWithNoPing 1, socks 2/8 
    
     user task 
    Entering initLog()...
    


    This also happens with latest release version, even if the label string is "simple" like "mylabel".

Topic summary

LABEL_AI_GENERATED
In a discussion about OpenBeken, a user seeks assistance with scripting for a light fixture, specifically regarding UI labels, saving values, MQTT integration, and dimmer functionality. The user wants to customize UI labels for buttons and dimmers, remove default status indicators, and ensure that custom settings persist after device restarts. Several contributors provide solutions, including creating pull requests to address specific label issues and suggesting modifications to MQTT publishing to allow channel names instead of numbers. The conversation highlights the need for careful handling of labels with special characters and the implications for MQTT topics and device integration.
AI summary based on the discussion. May contain errors.
ADVERTISEMENT