How to know what MQTT topic to send data on to reach a relay?
-
When did you last update the library code?
Do you have this that was committed 12 days ago?
https://github.com/mysensors/Arduino/pull/251I got the development branch 2 days ago from your github.
Would the child sensor id be the same on the publish topic as it is on the subscribe topic, surely yes, if so then the relay has a ID of 1. Which implies that i have my published message correct and its just not leaving the gateway. Which would then point towards what your suggesting of my gateway not being a repeater.
I just checked what the change was on the MySensor.h file for that update you just linked and i can confirm i have it in my version of MySensor.h:
// GATEWAY - TRANSPORT #if defined(MY_GATEWAY_MQTT_CLIENT) #if defined(MY_RADIO_FEATURE) // We assume that a gateway having a radio also should act as repeater #define MY_REPEATER_FEATURE #endif -
@samuel235 said:
Would you say that the construction of my message looks okay and conforms with the API?
Yes it looks ok. Very strange.
Far fetched: Could it be something about case sensitivity on topic prefix naming? But you get "Message arrived on topic" message... Hmm..
-
@samuel235 said:
Would you say that the construction of my message looks okay and conforms with the API?
Yes it looks ok. Very strange.
Far fetched: Could it be something about case sensitivity on topic prefix naming? But you get "Message arrived on topic" message... Hmm..
@hek I've just been comparing the 1.5 RelayActuator sketch with the Development one.
Is it supposed to be completely different? I'm assuming its referenced in the MySensor.h but the development sketch doesn't have any of the gw. options or anything. This is how its supposed to be? In an attempt to lower the memory needed on the node side?
Just out of interested, could you briefly explain or point me to the page where i can decode the sending message layout "send: 4-4-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:" Makes no sense to me at all. I only know that the s=1 is something to do with the sensor attached maybe? I keep looking everywhere to decode this and i can't get any sense out of it. It probably wont have any influence on this issue but i would just like to understand the methods, if possible.
-
I've just found this in the sketch
void receive(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.isAck()) { Serial.println("This is an ack from gateway"); }So, i changed my published message to: mosquitto_pub -t Gateway1-in/4/1/1/1/2 -m '1'.
The relay has not printed anything out, so i think its fair to assume that the issue is for some reason or another the gateway is not pushing that message to the relay node.
-
I´m new on this forum, and I'm really excited about the MySensors project. I've done a lot of research on the internet and haven't found anything close to what you guys are doing.Thanks Henrik and the rest of the team involved! Excellent work, really!
I haven't tried yet the 1.6 Development Branch; but when looking into your MQTT Client issue I don't recognize the MQTT message format being used (I could be deeply wrong about something I haven't understood about your set-up). Normally the standard MQTT format is a/b/c/d + payload. In my GW_MQTT Client pre-version I'm using to send messages to a Relay sensor I use format: "a/b/c/d/set + payload. In your case it seems to be a/b/c/d/e/f + payload. That wouldn't work in my case. Or in 'MySensors' terms it would be: 'MyMQTT/Sensor_Node_id/Child_Id/Sub_Type/set' + Payload. I use for my relay sensor Sub_Type = V_LIGHT. You're using Sub_Type=2, I guess it is incorrect.
With mosquitto publish client command it would be: mosquitto_pub -t Gateway1-in/4/0/V_LIGHT/set -m 1 or 0. This works ok for me. I think the command '/set' for publishing to the sensor isn't used in current MySensors V1.6 GW_MQTT_Client proposal. Not sure yet how this has been arranged in V1.6 development branch. I have to look into the code.
I have an up and running test environment with a pre-relaease to V1.6 MySensors MQTT-GW-Client, a mosquitto-brooker, ZABBIX for monitoring and a bunch of sensors (so far: Temperatue / Humidity / RFID-reader / Energy-Consumption / ON-OFF-sensors (door-open, smoke alarm, motion detector etc.)/ Action-Relays / Battery back-up voltage measurement). It's working incredibly well. I'm impressed so far! To push messages to the relay over MQTT works fine too. My expectations are to reach hopefully hundreds of environmental sensors over MQTT and MySensors to monitor our data-nodes at work via ZABBIX. If anyone is interested in my set-up and preliminary hardware prototypes pls. let me know. (sorry if it's the wrong forum-channel).
Right now I'm looking into the new RS485 concept added to V1.6. Hopefully it'll work with MQTT? I have been struggling too much with NRF24L01+ without being fully satisfied. Interested as well in the new RFM69W radio with better range with the LowPowerLabs Moteino board, but haven't got time to test so far.
-
I´m new on this forum, and I'm really excited about the MySensors project. I've done a lot of research on the internet and haven't found anything close to what you guys are doing.Thanks Henrik and the rest of the team involved! Excellent work, really!
I haven't tried yet the 1.6 Development Branch; but when looking into your MQTT Client issue I don't recognize the MQTT message format being used (I could be deeply wrong about something I haven't understood about your set-up). Normally the standard MQTT format is a/b/c/d + payload. In my GW_MQTT Client pre-version I'm using to send messages to a Relay sensor I use format: "a/b/c/d/set + payload. In your case it seems to be a/b/c/d/e/f + payload. That wouldn't work in my case. Or in 'MySensors' terms it would be: 'MyMQTT/Sensor_Node_id/Child_Id/Sub_Type/set' + Payload. I use for my relay sensor Sub_Type = V_LIGHT. You're using Sub_Type=2, I guess it is incorrect.
With mosquitto publish client command it would be: mosquitto_pub -t Gateway1-in/4/0/V_LIGHT/set -m 1 or 0. This works ok for me. I think the command '/set' for publishing to the sensor isn't used in current MySensors V1.6 GW_MQTT_Client proposal. Not sure yet how this has been arranged in V1.6 development branch. I have to look into the code.
I have an up and running test environment with a pre-relaease to V1.6 MySensors MQTT-GW-Client, a mosquitto-brooker, ZABBIX for monitoring and a bunch of sensors (so far: Temperatue / Humidity / RFID-reader / Energy-Consumption / ON-OFF-sensors (door-open, smoke alarm, motion detector etc.)/ Action-Relays / Battery back-up voltage measurement). It's working incredibly well. I'm impressed so far! To push messages to the relay over MQTT works fine too. My expectations are to reach hopefully hundreds of environmental sensors over MQTT and MySensors to monitor our data-nodes at work via ZABBIX. If anyone is interested in my set-up and preliminary hardware prototypes pls. let me know. (sorry if it's the wrong forum-channel).
Right now I'm looking into the new RS485 concept added to V1.6. Hopefully it'll work with MQTT? I have been struggling too much with NRF24L01+ without being fully satisfied. Interested as well in the new RFM69W radio with better range with the LowPowerLabs Moteino board, but haven't got time to test so far.
@jpaulin I'm not completely sure in what your reply objective is. However, I'm not convinced that you understand the message API properly.... gateway-subscription-prefix/node-id/child-sensor-id/message-type/ack/sub-type/payload. I'm not sure what your meaning with the "/set" at the end of your message layout? For an example, my gateway subscription prefix is "Gateway-1". So for me to set a value of 1 on my relay node i would send the payload as '1' on the route of:
"/Gateway-1/4/1/1/0/2/[Payload-Goes-Here]" Now, i personally use 2 for the Sub_Type rather than V_Light. Not sure if that will impose any issues further down the line, but it works perfectly for me right now.
Just to let you know, I run my controller (OpenHAB) and my MQTT Broker (Mosquitto) on a RaspberryPi, then my Gateway is using the development branch of W5100GatewayMQTT which is pretty awesome, and then my sensors at the moment are running all on Arduino Nano Pros, but I'm in the process of converting those to Arduino Pro Minis for lower power consumption and to enable me to get close to installing them in socket boxes behind light switches.
-
ok, I think I need to look into the new MQTTW5100 code to understand better the new API structure. Anyhow, I had a similar case as you mentioned with my MQTT pre-version, where the mesage_type has to be written in ASCII (V_LIGHT), and internally in the .cpp code it's translated to 2. Could be your case, maybe? In the MQTT-GW-Client pre-version I'm using it expects '/set' after the a/b/c/d MQTT message to allow sending forward a message to the sensor node, to avoid message loops. I guess that's been changed in the V1.6 branch.
-
Yeah, the numbers of the type of message is set as variables in the .cpp or the .h file somewhere, i can't remember which one off the top of my head.
The /set might still be in but all i'm saying is that i don't need to specify it in my sketches. It may be referenced somewhere. I'm sure Hek could advise on this, not that its an issue as we both have working examples. Just out of curiosity more than anything. The new dev branch for the MQTTGateway is super smooth and functional now. Give it a shot!
-
Here is a page on the message structure. It's the same as the Serial API. There is also a list of all the subtypes.
-
UPDATE:
If i publish a message from mosquitto out to the Gateway of:
mosquitto_pub -t Gateway1-in/4/1/1/0/2 -m '0'I get this in the Gateway serial interface:
0;0;3;0;9;Message arrived on topic: Gateway1-in/4/1/1/0/2Now, the controller isn't reporting that it sent out a message to node 4 (which is my relay node). Should i expect to see it serial print a message saying its sent that message to the node? I've had a little attempt to look through the .h files to see if it is supposed to be saying its sent a message out, i would have thought so considering that it shows when it sends out a message to the controller....
@samuel235 I guess you have the same problem which I faced. I managed to receive the topic on the gateway like you have did, but it wasn't sent to the sensor node.
There was two fixes for these to work for me. First one which is defining #MY_REAPEATER_NODE (You have already did this ) and hek has verified this solution. The other issue is related to a ( IF CONDITION ) in the code but it was not verified by hek so it was reported as a bug as no one else complained except me.
Please read this post that includes details explanation of the two fixes http://forum.mysensors.org/topic/2193/gatewayesp8266mqttclient-in-development-branch/10
This is also the main thread where I had the same problem which you complain of now. You can read it if you want also http://forum.mysensors.org/topic/2378/how-can-i-set-the-payload-for-mqtt-v1-6/5
Please update me. Hope that it solves your problem.
-
@samuel235 I guess you have the same problem which I faced. I managed to receive the topic on the gateway like you have did, but it wasn't sent to the sensor node.
There was two fixes for these to work for me. First one which is defining #MY_REAPEATER_NODE (You have already did this ) and hek has verified this solution. The other issue is related to a ( IF CONDITION ) in the code but it was not verified by hek so it was reported as a bug as no one else complained except me.
Please read this post that includes details explanation of the two fixes http://forum.mysensors.org/topic/2193/gatewayesp8266mqttclient-in-development-branch/10
This is also the main thread where I had the same problem which you complain of now. You can read it if you want also http://forum.mysensors.org/topic/2378/how-can-i-set-the-payload-for-mqtt-v1-6/5
Please update me. Hope that it solves your problem.
@ahmedadelhosni I have got my gateway working perfectly with my sensors now, have a look at my topic i created for this issue.
http://forum.mysensors.org/topic/2469/solved-mqttgatewayw5100-not-sending-messages-to-nodes
-
@ahmedadelhosni I have got my gateway working perfectly with my sensors now, have a look at my topic i created for this issue.
http://forum.mysensors.org/topic/2469/solved-mqttgatewayw5100-not-sending-messages-to-nodes
@samuel235 Yes. That's the same issue which I was pointing to but with a better solution. Glad that someone guided you (Y)