Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. MQTT: publish via Javascript

NEWS

  • UPDATE 31.10.: Amazon Alexa - ioBroker Skill läuft aus ?
    apollon77A
    apollon77
    48
    3
    8.3k

  • Monatsrückblick – September 2025
    BluefoxB
    Bluefox
    13
    1
    1.9k

  • Neues Video "KI im Smart Home" - ioBroker plus n8n
    BluefoxB
    Bluefox
    15
    1
    2.3k

MQTT: publish via Javascript

Scheduled Pinned Locked Moved Skripten / Logik
3 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spacemishka
    wrote on last edited by
    #1

    Hallo ich möchte per Javascript ein Datum an ein MQTT-Objekt schicken. Leider geht es nicht. Es wird auch keine Fehlermeldung ausgegeben.

    Kann mir jemand einen Tipp geben?

    Hier der Code. Im Prinzip kommt von einer Klimastation die Daten (Luftfeuchte, Temperatur und Luftdruck) Wenn die Daten empfangen werden, soll der Iobroker noch Datum und Zeit hinzufügen.

    
    on({id: "mqtt.0.wznode.humi", change: "any"}, function (obj) {
      var value = obj.state.val;
      var oldValue = obj.oldState.val;
    
      try{
      sendTo("mqtt.0", "send", {
         "wznode/lastseen": String(formatDate(new Date(), "YYYY/MM/DD")) +","+ String(formatDate(new Date(), "hh:mm:ss"))
      });
      }
      catch(Exception){
          console.log('lastseen1 failed');
      }
    
    });
    

    Danke

    Peter

    1 Reply Last reply
    0
    • BluefoxB Offline
      BluefoxB Offline
      Bluefox
      wrote on last edited by
      #2

      @spacemishka:

      Hallo ich möchte per Javascript ein Datum an ein MQTT-Objekt schicken. Leider geht es nicht. Es wird auch keine Fehlermeldung ausgegeben.

      Kann mir jemand einen Tipp geben?

      Hier der Code. Im Prinzip kommt von einer Klimastation die Daten (Luftfeuchte, Temperatur und Luftdruck) Wenn die Daten empfangen werden, soll der Iobroker noch Datum und Zeit hinzufügen.

      
      on({id: "mqtt.0.wznode.humi", change: "any"}, function (obj) {
        var value = obj.state.val;
        var oldValue = obj.oldState.val;
      
        try{
        sendTo("mqtt.0", "send", {
           "wznode/lastseen": String(formatDate(new Date(), "YYYY/MM/DD")) +","+ String(formatDate(new Date(), "hh:mm:ss"))
        });
        }
        catch(Exception){
            console.log('lastseen1 failed');
        }
        
      });
      

      Danke

      Peter `

      setState('mqtt.0.wznode.humi', formatDate(new Date(), "YYYY/MM/DD,hh:mm:ss"));
      
      
      1 Reply Last reply
      0
      • S Offline
        S Offline
        spacemishka
        wrote on last edited by
        #3

        Danke!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        Support us

        ioBroker
        Community Adapters
        Donate

        739

        Online

        32.4k

        Users

        81.4k

        Topics

        1.3m

        Posts
        Community
        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
        ioBroker Community 2014-2025
        logo
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Home
        • Recent
        • Tags
        • Unread 0
        • Categories
        • Unreplied
        • Popular
        • GitHub
        • Docu
        • Hilfe