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