Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. English
    3. Scripting / Logic
    4. JavaScript
    5. time of the last change of a data point.

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    time of the last change of a data point.

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

      is there a way in javascript (for node-red) to query the time of the last change of a data point.
      The system "knows" this because the time is displayed in the object list.

      paul53 OliverIO 2 Replies Last reply Reply Quote 0
      • paul53
        paul53 @franzda last edited by

        @franzda

        let lc = getState(id).lc;
        // Trigger:
        on(id, function(dp) {
           let lc = dp.state.lc;
        });
        
        F 2 Replies Last reply Reply Quote 0
        • F
          franzda @paul53 last edited by

          @paul53 Hi Paul thank you for very quick response. The question ist how can I access to the ts property. I mien ts is the value I am looking for.

          paul53 1 Reply Last reply Reply Quote 0
          • paul53
            paul53 @franzda last edited by

            @franzda sagte: how can I access to the ts property.

            .ts instead of .lc.

            1 Reply Last reply Reply Quote 0
            • OliverIO
              OliverIO @franzda last edited by

              @franzda

              1. you insert a node "iobroker in"
              2. select your datapoint as topic
              3. select object in payload
              4. then you select a function node with the following code
              msg.payload=msg.payload.lc; //or msg.payload.ts
              return msg;
              

              5 for testing purpose you can connect the function node with a debug node

              F 2 Replies Last reply Reply Quote 0
              • F
                franzda @OliverIO last edited by

                @oliverio Hi Oliver Thank you for quick response. it works

                F 1 Reply Last reply Reply Quote 1
                • F
                  franzda @franzda last edited by

                  @franzda said in time of the last change of a data point.:

                  @oliverio Hi Oliver Thank you for quick response. it works

                  this is my code thank you for helping: (two different formats for testing)

                     // ---  
                    sensor.neulcT = (new Date(msg.payload[i].lc)).toLocaleTimeString();
                    sensor.neulc =  (new Date(msg.payload[i].lc)).toLocaleString();
                    // ---
                  1 Reply Last reply Reply Quote 0
                  • F
                    franzda @OliverIO last edited by

                    @oliverio
                    Hi Oliver Thank you for quick response. it works

                    this is my code thank you for helping: (two different formats for testing)

                       // ---  
                      sensor.neulcT = (new Date(msg.payload[i].lc)).toLocaleTimeString();
                      sensor.neulc =  (new Date(msg.payload[i].lc)).toLocaleString();
                      // ---
                    1 Reply Last reply Reply Quote 0
                    • F
                      franzda @paul53 last edited by

                      @paul53 hi Paul Thank you for quick response. it works

                      this is my code thank you for helping: (two different formats for testing)

                         // ---  
                        sensor.neulcT = (new Date(msg.payload[i].lc)).toLocaleTimeString();
                        sensor.neulc =  (new Date(msg.payload[i].lc)).toLocaleString();
                        // ---
                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post

                      Support us

                      ioBroker
                      Community Adapters
                      Donate

                      411
                      Online

                      31.8k
                      Users

                      80.0k
                      Topics

                      1.3m
                      Posts

                      3
                      9
                      1143
                      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