Relay connection with MQTT?



  • Gday,

    I have been trying to connect to a new relay node via openhab.

    The relay node is set to Node 52 and seems to be connected to the gateway ok. (MQTT Client gateway)
    0_1456103563035_MQQTlensgrab.JPG

    I have a Switch item,

    Switch TestGD				"Test GD"		{mqtt=">[mosquitto:mygateway1-in/52/255/3/0/6:command:ON:1],>[mosquitto:mygateway1-in/52/255/3/0/6:command:OFF:0]"} 
    

    When I hit the switch in openHab it does send the MQTT message,

    0_1456103900175_MQQTlensgrab1.JPG

    The relay does not switch on or off from the MQTT message.

    Could someone point me in the right direction?

    Regards,
    George


  • Hero Member

    what message is the sketch wanting to receive? ( what sketch are you using? link to example or post your specific sketch )



  • Greg,

    I have loaded the current 1.5 Latest Release sketch and just added a static Node ID.

    Regards
    George



  • Gday,

    I hope someone can help, I am trying to get a relay node working.

    Gateway: MQTT Broker Gateway
    Relay Node sketch is: 0_1456304097597_RelayActuator.ino

    The only thing I changed was a fixed Node ID of 52.

    Could someone let me know what is the correct MQTT message is to send to turn it on and off?

    Regards,
    George


  • Admin

    If I interpret your images correctly, the command should be:

    mygateway1-in/52/1/1/0/2

    with payload 0/1



  • @hek
    Thanks for that.
    I switched back to the MQTT Broker Gateway as the client gateway seemed to lock up every no and then.

    Could you let me know the command for the broker gateway?

    Thanks again

    Regards
    George



  • Gday,

    Does anyone have a relay node connected to openHab via the MQTT Broker gateway?

    Could you point me in the right direction with the code to send to turn it on/off.

    • My MQTT broker gateway is working, I have a couple of PIRs & a Distance node working.
    • openHab is working
    • Node ID is 52
    • Sketch is the current latest 1.5 versions for both relay node and gateway

    But I can't seem to understand what to send to turn the relay node on or off.

    I have this but it is not working,

    Switch TestGD				"Test GD"			{mqtt=">[mysensors:MyMQTT/52/1/V_LIGHT:command:ON:1],>[mysensors:MyMQTT/52/1/V_LIGHT:command:OFF:0]"}
    

    This is from the serial monitor,
    send: 52-52-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
    send: 52-52-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=ok:1.5.4
    send: 52-52-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    read: 0-0-52 s=255,c=3,t=6,pt=0,l=1,sg=0:M
    repeater started, id=52, parent=0, distance=1
    send: 52-52-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
    send: 52-52-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.4
    send: 52-52-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
    read: 0-0-52 s=255,c=3,t=6,pt=0,l=1,sg=0:M
    sensor started, id=52, parent=0, distance=1
    send: 52-52-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
    send: 52-52-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
    send: 52-52-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:

    Regards,
    George



  • @George-Whitehouse What do you see in your Openhab event.log. If your TestGD switch is defined OK in your sitemap you should find any changes to the switch logged as events for the TestGD item in the event.log (maybe a stupid question but since you apparently have no incoming messages logged in the serial monitor the question is "what have you sent"/"have you sent anything at all").



  • Thanks, I reloaded the nano with the sketch and it is working ok.

    Regards
    George



  • @George-Whitehouse Good you have it working. Seemed that your sketch was working OK as the messages in the serial monitor were all marked ok.

    I have seen that even if sending of messages work receiving them may fail. In such a case the serial monitor of the gateway ought to show a "fail" in the log so when having problems it is always a good idea to monitor the gateway traffic as well.

    I am using the new MQTT client and then it is easy to monitor the MQTT messages as well (as you showed in the first post). This has simplified looking for errors a lot, at least for me.



  • @George-Whitehouse I've just seen your post about getting the correct message from openhab, I'm also having the same problem getting the relay to switch from within openhab.

    Could you share the openhab item you actually got working? Thanks very much



  • Matt,

    No worries, this is what I am using. It plugs into a rule that energises the relay for 3 seconds and then turns off to open/close the garage door.

    Currently I am using the MQTT Broker sketch from main branch along with the standard relay sketch.

    Config file,

    mqtt:mysensors.url=tcp://192.168.0.50:1883
    mqtt:mysensors.clientId=openHAB
    

    Items file,

    Switch GD					"Garage Door"	{mqtt=">[mysensors:MyMQTT/23/1/V_LIGHT:command:ON:0],>[mysensors:MyMQTT/23/1/V_LIGHT:command:OFF:1]"}
    
    

    I will give the MQTT Client sketch a go again soon however last time I tried it, it locked up on me every day or so and I had to restart it. Reliability is important and for the last few weeks my set up has been working perfectly.

    Cheers,
    George



  • @mbj Thanks, I will give the MQTT Client sketch a go soon.

    Cheers,


Log in to reply
 

Suggested Topics

  • 22
  • 1
  • 10
  • 132
  • 5
  • 3

21
Online

11.2k
Users

11.1k
Topics

112.5k
Posts