Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
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
Brand Logo
  1. Home
  2. Controllers
  3. Home Assistant
  4. NodeManager Relay in Homeassistant

NodeManager Relay in Homeassistant

Scheduled Pinned Locked Moved Home Assistant
6 Posts 4 Posters 1.6k Views 4 Watching
  • 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.
  • M Offline
    M Offline
    Malte Deiseroth
    wrote on last edited by Malte Deiseroth
    #1

    I'm trying to use NodeManager for a node that switches a realy. The problem is, that the HA MySensor component clashes with the way NodeManager handels actuators.

    NodeManager presents the relay to the GW, but never send any message with a value to the GW. However HA needs at least one initial value before the relay is recognized.
    Any idea how to deal with this? Either by forcing NodeManager to send an initial value, or by allowing HA to register the Node and its childs upon presentation and not on first value transmission?

    Here is some code of what I'm trying:

    // before
    void before() {
      // setup the serial port baud rate
      Serial.begin(MY_BAUD_RATE);  
      nodeManager.setReportIntervalSeconds(10);
    
      /*
       * Register below your sensors
      */
      id = nodeManager.registerSensor(SENSOR_RELAY, 3);
      SensorRelay* relay = (SensorRelay*)nodeManager.get(id);
      // A Method to send an intial value for the relay to the GW
     // realy->Send(false);
      /*
       * Register above your sensors
      */
      nodeManager.before();
    }
    

    Or maybe this must be done during the loop with:

    void loop() {
      // call NodeManager loop routine
      nodeManager.loop();
      SensorRelay* relay = (SensorRelay*)nodeManager.get(1);
      //relay->SendValueOnce(false);
    }
    
    1 Reply Last reply
    0
    • gohanG Offline
      gohanG Offline
      gohan
      Mod
      wrote on last edited by
      #2

      is there a way to add a button that turns relay on or off? Or just create a mock sketch that presents the same child ids and then sends a value for each child, then restore the nodemanager sketch: not the ideal solution but I think it could work

      M 1 Reply Last reply
      0
      • gohanG gohan

        is there a way to add a button that turns relay on or off? Or just create a mock sketch that presents the same child ids and then sends a value for each child, then restore the nodemanager sketch: not the ideal solution but I think it could work

        M Offline
        M Offline
        Malte Deiseroth
        wrote on last edited by Malte Deiseroth
        #3

        @gohan hmmmm. Well problem with this is, that I will need to redo this everytime I purge the config of my MySensor network within homeassistant, and I know that will happen almost each time I add a Node, so on the long run this will be annoying.

        I found another suuuper hacky solution.

        Within the NodeManager.cpp I edited the onLoop function of the underlying SensorDigitalOutput. This is the method the SensorRelay inherits from.

        void SensorDigitalOutput::onLoop() {
          // set the value to -1 so to avoid reporting to the gateway during loop
          //_value_int = -1;
          //_last_value_int = -1;
          // if a safeguard is set, check if it is time for it
          if (_safeguard_timer->isRunning()) {
            // update the timer
            _safeguard_timer->update();
            // if the time is over, turn the output off
            if (_safeguard_timer->isOver()) setStatus(OFF);
          }
        }
        
        

        I commented out the _value_int = -1; and the _last_value_int = -1;. Now it reporst the reading once upon a node start. I guess setTrackLastValue is set to true somewhere.

        Maybe it possible to add another method to the SnesorDigitalOutput, that allows to toggle these -1 settings in the loop.

        M 1 Reply Last reply
        0
        • gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #4

          Well, I did say it wasn't the best way 😁

          1 Reply Last reply
          0
          • M Malte Deiseroth

            @gohan hmmmm. Well problem with this is, that I will need to redo this everytime I purge the config of my MySensor network within homeassistant, and I know that will happen almost each time I add a Node, so on the long run this will be annoying.

            I found another suuuper hacky solution.

            Within the NodeManager.cpp I edited the onLoop function of the underlying SensorDigitalOutput. This is the method the SensorRelay inherits from.

            void SensorDigitalOutput::onLoop() {
              // set the value to -1 so to avoid reporting to the gateway during loop
              //_value_int = -1;
              //_last_value_int = -1;
              // if a safeguard is set, check if it is time for it
              if (_safeguard_timer->isRunning()) {
                // update the timer
                _safeguard_timer->update();
                // if the time is over, turn the output off
                if (_safeguard_timer->isOver()) setStatus(OFF);
              }
            }
            
            

            I commented out the _value_int = -1; and the _last_value_int = -1;. Now it reporst the reading once upon a node start. I guess setTrackLastValue is set to true somewhere.

            Maybe it possible to add another method to the SnesorDigitalOutput, that allows to toggle these -1 settings in the loop.

            M Offline
            M Offline
            Michał Szura
            wrote on last edited by
            #5

            @Malte-Deiseroth
            Hi any progress on this? I am looking into documentation and eventually find this thread

            1 Reply Last reply
            0
            • I Offline
              I Offline
              iancu
              wrote on last edited by iancu
              #6

              @Michał-Szura I had problems with relay and HA too. The best solution was to save the state of the relay in the EEPROM and to recall the value after a defined amount of time and send it to HA in loop(). This way you do not have to restart the relay node everytime you restart HA.

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


              23

              Online

              11.7k

              Users

              11.2k

              Topics

              113.1k

              Posts


              Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • MySensors
              • OpenHardware.io
              • Categories
              • Recent
              • Tags
              • Popular