Domoticz: Relay node doesn't show up in "devices"



  • Hello,
    Topic originally posted in Domoticz section, nut no luck:
    I'm quite new to MySensors, but not to domoticz, I already deployed mysensors based sensors (temperature, etc...) but I'm having a problem my the relay sketch: the relay shows up in domoticz in mysensors gateway setup page, but not in "Devices". I've read that a node should send data in order to show up un devices, but I don't know how to code that. I'm running last version of mysensors library. Please help!
    Thanks in advance, Thierry


  • Hardware Contributor

    @thierryd - a temperature sensors and other needs to send data to be presented, but not a switch if i remember correctly.
    Did you check under "not used"?

    Can you follow the logs in the gw and relay to comfirm that the communication are ok and the relay are presented as it should?



  • Hello @sundberg84, thank you very much for your answer.
    I have not checked the log of the gateway but shouldn't the output of mysensors gateway setup page tell me? As you can see it shows up properly (picture attached, you can see that the "last seen" is yesterday, that's because I didn't leave it plugged as I couldn't get it to work.).
    I've checked in "not used" => nothing, even after hitting the "allow new sensors" button.
    I'll try and plug the gateway to my PC tonight and see if the logs tell me more.
    alt text0_1499086492762_devices.PNG


  • Mod

    Actually all sensors/actuators need to be presented or the controller doesn't know what nodes and sensors are available in the network. Sometimes if you add sensors or relays to the same node, not always domoticz picks up the new items.



  • Hello @gohan , thank you for your answer,
    Could you tell me how to present the relay node? I've tested with the example sketch, which contains the following, but apperently that's not enough for domoticz to propose it under the "devices"

    void presentation()
    {
    // Send the sketch version information to the gateway and Controller
    sendSketchInfo("Relay", "1.0");

    for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
    	// Register all sensors to gw (they will be created as child devices)
    	present(sensor, S_BINARY);
    }
    

    }


  • Mod

    Have you set the number of relays in the beginning of sketch?



  • @gohan Yes: (I actually haven't modified the sample code, which has the number of relays defined allready)

    #define MY_REPEATER_FEATURE
    #include <MySensors.h>
    #define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define CHILD_ID 0
    #define RELAY_ON 1 // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay


  • Mod

    you need to look in the node log if it is actually sending the presentation and if the gateway is actually receiving the presentation. Use https://www.mysensors.org/build/parser if you don't understand the serial logs.



  • @gohan Thank for taking some time. I did that already, and the output seemed ok, but I'll try again when I get back home. But I guess the presentation is well received, as the node appears properly in the gateway setup page (see screenshot a few posts above).
    Just to specify my setup: RPI running Domoticz, with RFLink GW & devices, some wifi devices (ESP8266 based) & now MySensors V2.1.1 Serial GW & nodes. At the moment I didn't yet tinker with the MySensors sketches: I'm running everything with sample sketches


  • Mod

    so you actually have the child relay in Domoticz, you should be able to see in devices, if not try to go in setup>settings and press the Allow for 5 minutes button and restart the node and see if anything shows up



  • So I repeated the whole procedure:
    --> Relay sketch: never appears in devices
    --> Relay with button. pairs fine with the GW, appear in GW setup page, but not in devices. UNTIL... button is pressed. (i waited a few minutes to confirm). Afterwards the relay works as expected.
    I'm 100% sure of the behavior, I reproduced the scenario several times.
    So there's my way of getting a relay to show up in devices, even if it's not straightforward.
    So I guess the "simple relay" sketch needs to send something after it is paired with the GW in order to appear in "Devices". Any piece of code I should try?
    Topic half solved?


  • Mod

    @thierryd great work!

    How about trying to change

    present(sensor, S_BINARY);
    

    to

    present(sensor, S_LIGHT);
    

    ? Maybe Domoticz doesn't like BINARY. (You might need to use a new child id if Domoticz remembers the old id)

    If that doesn't help, just use the relay with button example but don't connect the button and add something like this in start of loop (delete the existing loop function):

    boolean first = true;
    void loop() {
        if(first){
            first=false;
            send(msg.set(loadState(sensor)?RELAY_ON:RELAY_OFF), true);
        }
    }
    


  • Hello, Tried presenting as S_Light, doesn't work, but the piece of code in the loop() work great!
    Nice workaround!
    Thank you very much!



  • Ok I did try something else: in void presentation i replaced S_BINARY by pin (of course I deleted the piece of code in the loop()

    I deleted the device and the node from domotics, cleared eeprom and tried. It works, the relay gets paired and is presented in devices... and works. does it make sense?

    void presentation()
    {
    // Send the sketch version information to the gateway and Controller
    sendSketchInfo("Relay", "1.0");
    for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
    // Register all sensors to gw (they will be created as child devices)
    present(sensor, pin);
    }
    }


  • Mod

    @thierryd if RELAY_1 is defined as 3 it does not make sense, because S_BINARY is an alias for 3 so you should get the exact same result as when using S_BINARY.

    See https://www.mysensors.org/download/serial_api_20#presentation for how the various message types are defined.


  • Mod

    Try changing node ID, just in case domoticz messed up something about that id



  • Thank you all for your answers. @gohan : I'll try changing node ID tomorrow, it's bed time in France 🙂


  • Mod

    It's same time for Italy too


  • Mod

    I learned some more about c programming and my code in the earlier post could be changed to this:

    void loop() {
        static bool first = true;
        if(first){
            first=false;
            send(msg.set(loadState(sensor)?RELAY_ON:RELAY_OFF), true);
        }
    }
    


  • Guys I'm confused as @gohan suggested I tried again with a "blank" node (eeprom clearded, etc...) with 2 relays: worked. Then I cleared it again and tried with one: worked also. It's like Domoticz's bouncer now thinks relays are nice lads, everybody gets accepted!
    So thank you all, and for people having the issue, there's some stuff:
    1- clear node ID, and try again
    2- Add a button (or simulate one with a wire, just for the sake of pairing)
    3- Add a piece of code to send data to domoticz, as per @mfalkvidd 's code.
    All those worked a some point 🙂
    Thank you again guys, I promise my next post will not be a cry for help (more likely improvement for battery percentage reporting - LiPo -, and/or improvement of BME280 handling - avoid sending data every minute -)


  • Mod

    I noticed that Domoticz sometime is picky and doesn't like nodes that change configuration too often, that's why I suggested to use a different ID just in case.


Log in to reply
 

Suggested Topics

  • 3
  • 10
  • 2
  • 2
  • 2
  • 4

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts