Fields Mysensors



  • Hello
    discovering MyController2
    I'm trying to understand how to get the data back
    of Mysensors in the dashboard.

    the question is :
    how to differentiate my sensors in the Widgets?

    in the example of the pdf file https://nsmf01.casimages.com/f/2022/03/24//2203240203102387089992.pdf
    I have two V_TEMP and two V_HUM

    a test by renaming Name :V_TEMP to V_TEMP1 gave nothing, TEMP1 comes back as TEMP

    in short it is the fog

    how do we use the labels?
    I didn't find any doc on the subject with Mysensors

    Thanks



  • I found it 😉

    in Resource Filters

    Key : sourceid
    Value : 2

    (I update my pdf)

    yeah the doc on the use of
    "Resource Filters" with "Key" "Value"
    values would be nice

    it's really a pity that you can't modify your previous post, too short delay, minimum one month 🙂



  • Hello
    a tutorial / help for the structure
    (the skeleton) of a MySensors sketch.

    to go back automatically to MyController
    the nodes and sensors

    here is an example in image (pdf)
    texte du lien

    and the sketch (Mysensors parts only )

    // ------ Mysensors V2 ------- //
    
      #define MY_NODE_ID 32   /*Node ID static*/
      #define CHILD_ID_R 3    /*Id  Relay*/
      #define CHILD_ID_B 4    /*Id  Door*/
        
      MyMessage msg(CHILD_ID_R,V_STATUS);  
      MyMessage msg1(CHILD_ID_B,V_TRIPPED);  
    
      void setup() { .... }
    
      void presentation()   {
      sendSketchInfo("DiDo node 32", "2.0");  /* version sketch*/
    
    //Mysenors save Child and Gw
      present(CHILD_ID_R, S_BINARY);  /*output digital*/
      present(CHILD_ID_B, S_DOOR);    /*input digital*/  
    
      request(CHILD_ID_R, V_STATUS);    /*request value of the controller*/
      request(CHILD_ID_B, V_STATUS); 
    ... }
    
     void loop()  { ...
           
    //  send(msg.set(value==HIGH ? 1 : 0));      /*Relay 
        send(msg1.set(value==HIGH ? 1 : 0));     /*Door 
    ...}
      
    void receive(const MyMessage &message)  {
    
       if (message.type == V_STATUS) 
       {
       state = message.getBool ();
       digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);  /*Change relay state*/
    
       if (message.getType()==V_STATUS) 
       {
       //digitalWrite(message.getSensor() - RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
    ... }
    
    

    a question : I don't understand the use of
    "message.getType" and "message.getBool" ?

    one instruction too many ??

    thanks


  • Plugin Developer

    @JeeLet can you add send(msg.set(value==HIGH ? 1 : 0)); // Relay in your setup(){} function?



  • Hello jkandasa

    I spent the day on the Mysensors website copying/translating some parts of the "serial_api_20" doc
    (I have no more eyes 🙂 )

    yes I will add it soon
    send(msg.set(value==HIGH ? 1 : 0)); // Relay

    you mas understood, I try to write well the code of the sckech
    so that MyCrontroller goes up cleanly the sensors 🙂

    Merci



  • exit status 1 : 'value' was not declared in this scope

    but why in the setup ?
    you have to put it in Loop () ?

    //-----------Mars.2022------- Node 32 --------- MySensors DI DO MyController -----------------//
      // #define MY_DEBUG                  /*Enable debug prints to serial monitor*/
      //  #define   MY_DEBUG_OTA_DISABLE_ECHO  //envoyer des messages sans demander à la destination de renvoyer le message
    // Mysensors advanced settings
      //  #define MY_TRANSPORT_WAIT_READY_MS 3000 /*Tempo d'attente de mis en Com, des millisecondes - à placer avant Mysensors.h*/ 
      //  #define  MY_SPLASH_SCREEN_DISABLED /*désactive écran de démarrage MySensors (économie 120oct. en flash)*/
     
        #define MY_NODE_ID 32                   /*Node en ID static*/
      
    /* ----- Module TTL-RS485 ----*/
      #define MY_RS485                  /*Apl du transport RS485 (protocol?)*/
      #define MY_RS485_DE_PIN 2         /*Cmd DE pin*/
      #define MY_RS485_BAUD_RATE 9600   /*Set RS485 baud rate to use*/
      #define MY_REPEATER_FEATURE       /*Activer fonctionnalité de répéteur du nœud*/
      
      #include <MySensors.h>
      #include <Bounce2.h>
    
    // ------ objet ------
      #define RELAY_PIN   7    /*Pin Relay-DO*/
      #define BBUTTON_PIN 6    /*Pin boton-DI*/
      
      #define CHILD_ID_R 3    /*Id du Relay*/
      #define CHILD_ID_B 4    /*Id du bouton poussoir*/
    
      #define RELAY_ON 1
      #define RELAY_OFF 0   
    
    //----- Instancier objet Bounce ------
        Bounce debouncer = Bounce(); 
        int oldValue=0;
        
        bool state;
       
    // ------ Mysensors -------
    
      MyMessage msg(CHILD_ID_R,V_STATUS);   /*Relay*/
      MyMessage msg1(CHILD_ID_B,V_TRIPPED);  /*Boton*/
    
     void setup()  {
    
        pinMode (RELAY_PIN,OUTPUT);         /*config pin relay*/
        digitalWrite(RELAY_PIN, RELAY_OFF); /*désactive Relay au démarrage*/ 
    
        pinMode(BBUTTON_PIN,INPUT_PULLUP) ;   /*Configure Pin en input et Active pull-up interne*/
        debouncer.attach(BBUTTON_PIN);        /*configurez l'instance Bounce*/
        debouncer.interval(5);                /*interval in ms*/    
    
     //  send(msg.set(value==HIGH ? 1 : 0));      /*Relay 
      }
    
     void presentation() {
      sendSketchInfo("DiDo node 32", "2.0");  /*info version sketch à la passerelle*/
    
    /*Mysenors Enregistre Child and Gw*/
      present(CHILD_ID_R, S_BINARY);    /*Relay*/
      present(CHILD_ID_B, S_DOOR);      /*Boton*/  
      
    /* requetes/demandes à un noeud ou GW une variable*/
      request(CHILD_ID_R, V_STATUS);   /*Relay*/
      request(CHILD_ID_B, V_STATUS);  /*Boton*/  
     }
    
     void loop()  {
    
    /*Vérifie un changement d'etat sur les entrées numérique et envoye la nouvelle valeur*/
        debouncer.update();             /*Update the Bounce instances*/
        int value = debouncer.read();   /*Get the updated value*/
    
    /*Relay*/
    //    if (valueR != oldValueR) {   
    //    send(msg.set(valueR==HIGH ? 1 : 0));   /*Envoyer la nouvelle valeur*/
    //    Serial.println ("Changement d'etat bouton A");
    //    oldValueR = valueR;
    //    }
      
    /*bouton*/
        if (value != oldValue) {
         send(msg1.set(value==HIGH ? 1 : 0));    // Envoyer la nouvelle valeur
         Serial.println ("Changement d'etat bouton ");
         oldValue = value;
        }
     }
     
      void receive(const MyMessage &message) {
      // attente qu'un seul type de message du contrôleur , vérifier.
        if (message.isAck()) {
        Serial.println("Ceci est un accusé de réception de la passerelle");
        }
      
        if (message.type == V_STATUS) //V_STATUS ancien V_LIGHT
        {
        state = message.getBool ();
        digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);  // Changer l'état du relais
    
    //if (message.getType()==V_STATUS) {
        // Change relay state
      //  digitalWrite(message.getSensor() - RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
       
      } 
      
     }
    // -------------------- END PGM --------------------------- 
    

  • Plugin Developer

    @JeeLet the value, you have to set.
    V_STATUS is not available in MyController, since it is not reported yet.
    adding in setup sends the data only once. If you would like to retain the old status from MyController in your node, remove the send(msg.set(value==HIGH ? 1 : 0)); from your setup and create V_STATUS manually in MyController

    • add new field in Resources >> Fields >> Add,
      b817c854-f8da-45e6-b28c-b66a6fb29c2b-image.png


  • can be the good solution to put everything back to MyController

    without doing anything 🙂

     bool info;
    
    Void setup  {......
      //info send to gateway
       send(msg.set(info)); 
       send(msgx.set(info)); //pour d'autres  
    ...}
    

    to be seen later


Log in to reply
 

Suggested Topics

  • 9
  • 1
  • 4
  • 2
  • 5

81
Online

10.6k
Users

10.8k
Topics

111.0k
Posts