Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Entwicklung
    4. State value

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    State value

    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Singib last edited by

      Hi, guys.

      I'm trying to develop a new adapter and a couple of questions appears. Please help me with understanding:

      1. After calling "adapter.setState(name, value, false)" in my code, MQTT itself performs ACK = TRUE after short time. Is it a correct behavior? I mean It is not necessary to reset ACK to TRUE after command processing in MY code?

      2. Imagine the State Value was 0 (or even was empty). I set a value to 0 by calling "adapter.setState(name, 0, false)" or even through the web interface. In this case the adapter ACK becomes FALSE (and appears as RED in the web interface) and MQTT does not revert it to TRUE. Is this behavior correct?

      Thank you

      1 Reply Last reply Reply Quote 0
      • apollon77
        apollon77 last edited by

        @Singib:

        Hi, guys.

        I'm trying to develop a new adapter and a couple of questions appears. Please help me with understanding: `

        Hi and welcome to the developers 🙂

        @Singib:

        1. After calling "adapter.setState(name, value, false)" in my code, MQTT itself performs ACK = TRUE after short time. Is it a correct behavior? I mean It is not necessary to reset ACK to TRUE after command processing in MY code? `

        Yes. Your code should only react on State-Changes from your own adapter with "ack=false" becaus ethese are the "commands" in ioBroker. After the command got proessed by the adapter, the adapter should update the state values to the "current value after processing the command" with ack=true.

        In the end when your adapter writes info into own states they all should be "final" and so written with "ack=true".

        Does this help?

        @Singib:

        2. Imagine the State Value was 0 (or even was empty). I set a value to 0 by calling "adapter.setState(name, 0, false)" or even through the web interface. In this case the adapter ACK becomes FALSE (and appears as RED in the web interface) and MQTT does not revert it to TRUE. Is this behavior correct? `
        Depends on the use case.

        If you have adapter own state ids that are only used to trigger an action and so itself do not have a "state" (but maybe change other states) then it is ok because the command with ack=false will trigger the "trigger",which does an action.

        MQTT may not be really the best example nbecause it is a communication bridge (as I understand it), so it may be that there are some cases where the ideal way is not implemented …

        If you have real examples for your adapter it may help to give better ideas

        Ingo

        1 Reply Last reply Reply Quote 0
        • S
          Singib last edited by

          Hi, apollon77!

          Let's clarify the first point at the beginning 🙂

          "After the command got processed by the adapter, the adapter should update the state values to the "current value after processing the command" with ack=true."

          Is it the my task?

          Only I know when my command was processed and completed… Ideally, after I processed a command, I should resend to ioBroker engine a command ACK=TRUE. But instead of this, the MQTT background does it without my actions. Probably, I still didn't perform a command, but my setting a value becomes ACK=TRUE by itself. It worries me 🙂

          1 Reply Last reply Reply Quote 0
          • apollon77
            apollon77 last edited by

            I only talked about states from your own adapter that you write!! Please tell more about the mqtt topics … because mqtt is an own adapter and handles all own states like mqtt.0.statenane by its own. So yes for such a State the mqtt adapter is „responsible“ to set ack=true.

            For all states of your adapter (e.g. singib.0.mystate ) you need to do.

            1 Reply Last reply Reply Quote 0
            • S
              Singib last edited by

              I'm sorry for delay..

              I'm trying to develop an adapter for Blynk.cc - nice mobile UI (as I use it). The current implementation is there: https://github.com/Go00oglin/ioBroker.blynk

              After I understand that there is a change in UI on mobile device, I modify a value of state in the adapter (https://github.com/Go00oglin/ioBroker.b … er/main.js - lines 131 an d 136):

              adapter.setState(stateName, newValue, false);

              there are no any code in my adapter to revert ACK to true.

              But my log notifies me:

              blynk.0 2018-02-01 07:56:25.511 info stateChange blynk.0.V10 {"val":16,"ack":true,"ts":1517460985504,"q":0,"from":"system.adapter.mqtt.0","lc":1517460985504}

              blynk.0 2018-02-01 07:56:25.484 info stateChange blynk.0.V10 {"val":"16","ack":false,"ts":1517460985478,"q":0,"from":"system.adapter.blynk.0","lc":1517460985478}

              So, after I set a new value to State with ACK=FALSE, the system.adapter.mqtt.0 reverts it to TRUE mostly immediately itself.

              1 Reply Last reply Reply Quote 0
              • apollon77
                apollon77 last edited by

                And this is completely as intended. Your adapter tells the mqtt adapter that zu want to control this datapoint and that mqtt should set the neue value (ack=false). Mqtt reacts on this and after the change is done he sets the new value (in theory the value could be different) with ack=true to tell all others that there is a new officially set value.

                So it works exactly like that.

                1 Reply Last reply Reply Quote 0
                • S
                  Singib last edited by

                  Thank you, apollon77,

                  let me understand the idea.

                  1. I specified a new command (ack=false) with some value by calling adapter.setState(,false).

                  2. I thought, the my adapter should process this command in a part of my code and then should confirm this change by calling adapter.setState(,true).

                  Instead of this, the ioBroker body (ie mqtt) confirms setting of state on its own. So, the state changing is not a command, but just a value.

                  OK. but how to understand a documentation sentence "States can be written as commands or as statuses…. "?

                  sorry for my stupid questions 🙂

                  1 Reply Last reply Reply Quote 0
                  • Bluefox
                    Bluefox last edited by

                    @Singib:

                    Thank you, apollon77,

                    let me understand the idea.

                    1. I specified a new command (ack=false) with some value by calling adapter.setState(,false).

                    2. I thought, the my adapter should process this command in a part of my code and then should confirm this change by calling adapter.setState(,true).

                    Instead of this, the ioBroker body (ie mqtt) confirms setting of state on its own. So, the state changing is not a command, but just a value.

                    OK. but how to understand a documentation sentence "States can be written as commands or as statuses…. "?

                    sorry for my stupid questions 🙂 `
                    As far as I understand your code: the all values for your virtual pins are updates of the states. Not the commands.

                    You should send it with ack=true.

                    Only If you want to control states of other adapters (not yours) you should set the ack=false.

                    After this line https://github.com/Go00oglin/ioBroker.b … ain.js#L55 is executed, the ack in your adapter must be set to true. Or may be it will be done automatically because the adapter will get the update of the status here: https://github.com/Go00oglin/ioBroker.b ... in.js#L122

                    It took me sometime too to understand the concept of ack, but now it is self-evident. 🙂

                    You update your states always with ack=true,

                    Other adapters controls your states always with ack=false.

                    MQTT is not the body of ioBroker, it is just other adapter. And may be it has some logic on some client that acknowledges the state. ioBroker do not acknowledges the states automatically.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post

                    Support us

                    ioBroker
                    Community Adapters
                    Donate

                    713
                    Online

                    31.7k
                    Users

                    79.8k
                    Topics

                    1.3m
                    Posts

                    3
                    8
                    2217
                    Loading More Posts
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes
                    Reply
                    • Reply as topic
                    Log in to reply
                    Community
                    Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                    The ioBroker Community 2014-2023
                    logo