Newbee issue: howto set relay node with using MQTT?
-
Hi All,
Today I finally managed to go a bit further with my home automation project. In the future I think to use a combination of OpenHab ( the list of available bindings looks awesome ), and MyController.org because of the possibility to use FOTA.
And after a lot af reading and thinking, I am liking the MQTT broker part as superglue between these controllers and even perhaps in the future some sensors/actuators.But off coarse all projects starts small. So I went on to install a Mosquitto server, created an MQTT ethernet gateway following the description of the build howto on this site. (only the ip addresses, mac address were adapted).
Also I created a basic door/window sensor ( fixed node-id), and a relay actuator (also fixed node-id). Both sensors are a simple copy of the examples on this site. As a radio I use nrf24.After installing mqtt.fx everything looks promising: the broker gets information from the gateway, and even the both sensors are creating topics when entering. The door sensor seems to work since a button press leads to 2 messages.
But, how can I turn on/off the relay sensor? for the sake of the simplicity the relay has been exchanged with a led/resistor. After reading several hours, digging into forums, using google & youtube, I have still no luck to be able to switch the led on/off.
I thought that I needed to follow the information listed in the serial API. More concrete:
my- node id = 250
- child-sensor-id = 1
- command ( i want to set,so 1)
- ack ( don't care for now, so 0)
- type V_status because the sensor is S_BINARY, so value=2
And in the mqtt sketch that is in the gateway:
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"When I publish in mqtt.fx the topic:
mygateway1-in/250/1/1/0/2. I see in the debug log of the relay-node:
3682377 TSF:MSG:READ,0-0-250,s=1,c=1,t=2,pt=0,l=0,sg=0:
Incoming change for sensor:1, New status: 0to add another / to the topic followed by 1 or 0 does not see any information in the debug log of the relay-sensor.
What part am I missing to set/unset the payload in an MQTT message?
But how can I add the payload to on/off the relay ?
I tried in mqtt.fx
-
are you correctly managing the message in the node "receive" function ?
-
Last night I downloaded a mqtt client on my phone. And guess what: first attempt was working directly.
So after I knew at least the node is working, and the topic that I figured out was correct, I returned to mqtt.fx this morning.That was a really facepalm moment. Quite embarrising I must confess......
In mqtt.fx in the publish tab, there is a really great white box right beneath the topic field. And exactly in that great white field I can enter the boolean payload I need.So my help question is answered in the mean time. For now I can continue to explore the mysensors possibilities, and try to let it work together with Openhab. After that, I will look to mycontroller.org to get it glued together by the mqtt layer. Although I’ve read somewere that a pure translation/retransmission between mycontroller to a mqtt broker not seems possible.