Changing a node not captured by gateway



  • I'm new to Mysensors but must say that I'm impressed sofar! Great job from the developers. I've made a gateway with ESP8266 that work's just fine. Now to my issue. Made a node with two relays and it show's up as expected in Domoticz and seems to work perfect. When upgrading the node by adding another relay it don't shows the added relay. What do I have to do for gateway to see that a node has changed ?
    Any help appreciated
    Regards



  • Can you please give more background info?
    I don't think it's a development issue but either related to domoticz or to the code on your node. Would you mind posting your sketch?



  • @hakha4
    What mean "don't shows the added relay" .

    Sometimes you do not see your node in "Hardware",
    but in "Devices" child sensors from that node are normally presented.

    No node 254 in list:

    0_1531307266972_2018-07-11-130114_1680x1050_scrot.png

    But its sensors are in devices:

    0_1531307332219_2018-07-11-130234_1680x1050_scrot.png



  • Thankäs for answer. I've find code on internet with two relay's 'A and B'. Just added a third relay 'C'. When first using two relays everything worked ok with two child's registered in Domoticz but when updating the node with relay 'C it don't shows up in Domoticz. So my main question is if gateway recognize changes in an earlier reg. node or if you have to delete some info for a fresh reg. ? I've checked code for typo error but can't see any obvious errors. See code below:

    /*
     * NANO:
     * Radio occupies pin 2,9-13
     * 
     */
    
    
    
    
    
    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define MY_REPEATER_FEATURE
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <Bounce2.h>
    
    #define RELAY_ON 1
    #define RELAY_OFF 0
    
    #define SSR_A_ID 1   // Id of the sensor child pump filter
    #define SSR_B_ID 2   // Id of the sensor child pump waterfall
    #define SSR_C_ID 3   // Id of the sensor child pump waterfall
    
    const int buttonPinA = 3;
    const int buttonPinB = 7;
    const int buttonPinC = 8;
    const int relayPinA = 4; 
    const int relayPinB = 5;
    const int relayPinC = 6;
    int oldValueA = 0;
    int oldValueB = 0;
    int oldValueC = 0;
    bool stateA = false;
    bool stateB = false;
    bool stateC = false;
    
    
    Bounce debouncerA = Bounce();
    Bounce debouncerB = Bounce();
    Bounce debouncerC = Bounce();
    
    MyMessage msgA(SSR_A_ID, V_STATUS);
    MyMessage msgB(SSR_B_ID, V_STATUS);
    MyMessage msgC(SSR_B_ID, V_STATUS);
    
    void setup()
    {
    
      pinMode(buttonPinA, INPUT_PULLUP); // Setup the button Activate internal pull-up
      pinMode(buttonPinB, INPUT_PULLUP); // Setup the button Activate internal pull-up
      pinMode(buttonPinC, INPUT_PULLUP); // Setup the button Activate internal pull-up
    
    // Then set relay pins in output mode
      pinMode(relayPinA, OUTPUT);
      pinMode(relayPinB, OUTPUT);
     pinMode(relayPinC, OUTPUT);
      // After setting up the buttons, setup debouncer
      debouncerA.attach(buttonPinA);
      debouncerA.interval(5);
      debouncerB.attach(buttonPinB);
      debouncerB.interval(5);
      debouncerC.attach(buttonPinC);
      debouncerC.interval(5);
      // Make sure relays are off when starting up
      digitalWrite(relayPinA, RELAY_OFF);
      digitalWrite(relayPinB, RELAY_OFF);
       digitalWrite(relayPinC, RELAY_OFF);
    
        /*--------------------- Added these lines for toggle switch-------------------------*/
      oldValueA = digitalRead(buttonPinA);  // set oldValueA to the current status of the toggle switch
      oldValueB = digitalRead(buttonPinB);  // set oldValueB to the current status of the toggle switch
      oldValueC = digitalRead(buttonPinC);  // set oldValueB to the current status of the toggle switch
    
      send(msgA.set(false)); // Send off state for relayA to ensure controller knows the switch is off
      send(msgB.set(false)); // Send off state for relayB to ensure controller knows the switch is off
      send(msgC.set(false)); // Send off state for relayB to ensure controller knows the switch is off
    
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Pond Controller", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(SSR_A_ID, S_LIGHT);
      present(SSR_B_ID, S_LIGHT);
      present(SSR_C_ID, S_LIGHT);
    }
    
    /*
       Example on how to asynchronously check for new messages from gw
    */
    void loop()
    {
      debouncerA.update();
      // Get the update value
      int valueA = debouncerA.read();
      if (valueA != oldValueA) {
        send(msgA.set(stateA ? false : true), true); // Send new state and request ack back
      oldValueA = valueA;
      }
     
    
      debouncerB.update();
      // Get the update value
      int valueB = debouncerB.read();
      if (valueB != oldValueB) {
        send(msgB.set(stateB ? false : true), true); // Send new state and request ack back
      oldValueB = valueB;
      }
    
      debouncerC.update();
      // Get the update value
      int valueC = debouncerC.read();
      if (valueC != oldValueC) {
        send(msgC.set(stateC ? false : true), true); // Send new state and request ack back
      oldValueC = valueC;
      }
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type == V_STATUS) {
          
        switch (message.sensor) {
          case 1:
            stateA = message.getBool();
            digitalWrite(message.sensor + 4, stateA ? RELAY_ON : RELAY_OFF);
            
            break;
          case 2:
            stateB = message.getBool();
            digitalWrite(message.sensor + 4, stateB ? RELAY_ON : RELAY_OFF);
    
            case 3:
            stateC = message.getBool();
            digitalWrite(message.sensor + 4, stateC ? RELAY_ON : RELAY_OFF);
    
            break;
          
        }
       
          // Write some debug info
        Serial.print("Incoming change for sensor:");
        Serial.println(message.sensor);
        Serial.print("from node:");
        Serial.println(message.sender);
        Serial.print(", New status: ");
        Serial.println(message.getBool());
      }
    }
    

    Regards


  • Mod

    @hakha4 the code looks good to me. What does the device page in Domoticz look like? What do the node and gateway debug logs say?

    Maybe the presentations are putting too much strain on the power supply or radio (the debug output will show whether that is the case). Try adding wait(100) after each presentation statement.



  • I'll try put in a delay and get back if not solved. Thank's



  • The code looks wrong to me

    this

    MyMessage msgC(SSR_B_ID, V_STATUS);

    should probably be

    MyMessage msgC(SSR_C_ID, V_STATUS);



  • You're absolutely right. Should be MyMessage msgC(SSR_C_ID, V_STATUS);
    Sometimes you get blind when looking for typos. Thank's


Log in to reply
 

Suggested Topics

  • 1
  • 1
  • 5
  • 2
  • 10
  • 1

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts