OpenHAB + ESP8266 Ethernet GW without Radio: "send" does nothing
-
Hi there,
I am trying to setup MySensors with OpenHAB and I don't understand what I am doing wrong.
- I installed the MySensors Binding in OpenHAB following the instructions here on the MySensors website.
- I took the "GatewayESP8266" sketch from the examples, commented the radio define (as I want only direct attached sensors for the first test) and copied the "door" example into the places where comments suggested it.
- I added "MY_TRANSPORT_WAIT_READY_MS 1" to get into the running condition without a working radio.
- In OpenHAB, I can manually add the gateway as a "MySensors Ethernet Gateway" and it does immediately tell OpenHAB about the attached sensor, so there definitely is some communication going on.
- The example code calls "send" every 10s (with a "sleep" in between that I replaced by a "wait" because the ESP does not support "sleep), and I do see (I added serial outputs) that the "send" function is being called.
- What I do not see is any traffic on the network or even a debug log entry that a message was being sent.
The Code:
#define MY_DEBUG #define MY_BAUD_RATE 9600 // Enables and select radio type (if attached) //#define MY_RADIO_RF24 //#define MY_RADIO_RFM69 //#define MY_RADIO_RFM95 #define MY_GATEWAY_ESP8266 #define MY_WIFI_SSID "----redacted----" #define MY_WIFI_PASSWORD "----redacted----" #define MY_HOSTNAME "ESP8266_GW" #define MY_IP_ADDRESS 10,0,5,201 #define MY_IP_GATEWAY_ADDRESS 10,0,5,1 #define MY_IP_SUBNET_ADDRESS 255,255,255,0 #define MY_PORT 5003 #define MY_GATEWAY_MAX_CLIENTS 2 // ignore transport and start working immediately #define MY_TRANSPORT_WAIT_READY_MS 1 #include <MySensors.h> #define OPEN 1 #define CLOSE 0 #define CHILD_ID 1 MyMessage msg(CHILD_ID, V_TRIPPED); uint8_t value = OPEN; void setup() { // Setup locally attached sensors Serial.println("Setup"); } void presentation() { // Present locally attached sensors here Serial.println("Presentation"); present(CHILD_ID, S_DOOR); } void loop() { // Send locally attached sensors data here Serial.println("Loop"); value = value == OPEN ? CLOSE : OPEN; Serial.print("...send: "); Serial.println(value); send(msg.set(value)); Serial.println("...wait"); wait(10000); }
The Serial Log:
MCO:BGN:INIT GW,CP=R-NGE---,FQ=80,REL=255,VER=2.3.2 scandone scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 1 cnt connected with ----redacted----, channel 1 ip:10.0.5.201,mask:255.255.255.0,gw:10.0.5.1 ip:10.0.5.201,mask:255.255.255.0,gw:10.0.5.1 326 GWT:TIN:CONNECTING... 486 GWT:TIN:IP: 10.0.5.201 515 MCO:BGN:STP Setup 532 MCO:REG:NOT NEEDED 563 MCO:BGN:INIT OK,TSP=NA Loop ...send0 ...wait pm open,type:2 0 Loop ...send1 ...wait Loop ...send0 ...wait Loop ...send1 ...wait
I am not sure why the "send" command, that is being called, does not actually send data to OpenHAB. Am I missing something obvious?
Thanks for any hints
-
Update: I can't seem to get the Ethernet GW working. The MQTT GW does work however.
As a workaround, I now have the MQTT GW sketch on the ESP8266, the internal MQTT Broker of OpenHAB ("MQTT Embedded Broker") activated in "Services", and because the MySensors MQTT Gateway Binding doesn't seem to handle unexpected reboots of a Gateway very well (no communication for a LONG time), I am using the generic MQTT Binding to handle the MySensors messages.
It is not a nice solution, but a working workaround for the time being.
Still hoping for help with the "right way" of doing this.
Can't be that hard, I am sure I am missing something obvious.
-
Hello,
I am using OpenHab with MQTT GW for few weeks and I am pretty happy about this. Reporting data and even setting relays work for me ok.
What is your issues with it?
-
i tried to get the binding working as i wanted to maybe 2 years ago and after a bunch of issues i moved it all to MQTT instead. You obviously lose auto adding of new nodes but thats about it. MQTT just works better, i wouldn't call it a work around.
-
I did not even know there was "MySensors binding" as it is not listed in default openhab installation. So I used MQTT binding from the beginning.
Only thing I noticed is that maybe default sketches needs to be little modified for better behavior as I am writing/asking in Ethernet / MQTT PoE gateway for 16 reed switches:
I noticed the gateway sends the presentation of sensors all the time but that is not of much use in my setup. On the other hand it is useful to send the actual state periodically as it is known without remembering or if the controller started later than GW. But I have a feeling that I might misused the presentation function. Does any one know if this approach is ok by the "mysensors way"?
-
@tssk What my issues with it are:
- there is an official binding and installation instruction here on mysensors.org and it does not work reliably
- the ESP8266 Ethernet Gateway Example connected the first time and then stopped working at all
- the ESP8266 MQTT Gateway Example connected the first time and then stopped working at all
- when looking at the MQTT broker, messages do come in, but the official binding (see above) does not register them, does not update the things/items in OpenHAB.
This leads me to the conclusion that the official binding does not handle disconnects very well. Once disconnected, it either takes forever to re-establish a connection or it straight up refuses to work again unless maybe if I rebooted the OpenHAB machine.
When I completely ignore the existence of the official OpenHAB binding that is promoted here as "the" way of connecting to OpenHAB, and instead use a generic MQTT binding, it works like a charm.
I am just confused that the "official" way is so unreliable. I expected this to be the best way. That's why I went for it.