OpenHab mysensors item

Hi guys,

I just got my MQTTMysensor gateway working without any problem but now I have a different problem, The thing is that I tried to add an item, door window sensor, to my sitemap but I just can’t get it working. I spend all day testing and serching to get it work but I just can’t, so I try here.

My item looks like this,
Contact door "MQTT [MAP(]" {mqtt="<[homeAuto:homeAuto-out/101/3/1/0/V_TRIPPED:state:MAP(]"}

Anyone that can see any problem with this setup?

I don’t see anything wrong with your item line, but you don’t say exactly what is going wrong, so its hard to help.

Is the MQTT message getting to the broker from your gateway? The broker log will tell you this.

If so, is the MQTT message getting to openhab? The openhab.log log will tell you this.

If so, is OH interpreting the message as updating the item. The event log will tell you this.

Trace back and get some more information, and we may be able to help.

Good Luck!

I guess you’r on the right track. This is my mosquitto.log

1466492552: mosquitto version 1.4.9 (build date Fri, 03 Jun 2016 09:02:12 +0100) starting
1466492552: Config loaded from /etc/mosquitto/mosquitto.conf.
1466492552: Opening ipv4 listen socket on port 1883.
1466492552: Opening ipv6 listen socket on port 1883.
1466492555: New connection from on port 1883.
1466492555: New client connected from as homeAuto (c1, k60).
1466492595: Error in poll: Interrupted system call.
1466492595: mosquitto version 1.4.9 terminating

Mosquitto conf

pid_file /var/run/

persistence true
persistence_location /var/lib/mosquitto/

log_dest topic

log_type error
log_type warning
log_type notice
log_type information

connection_messages true
log_timestamp true

include_dir /etc/mosquitto/conf.d

My openhab.log looks like this.

08:08:23.228 [DEBUG] [.io.transport.mqtt.MqttService:123  ] - Starting MQTT Service...

08:08:23.386 [INFO ] [.io.transport.mqtt.MqttService:108  ] - MQTT Service initialization completed.
08:08:23.389 [INFO ] [o.i.t.m.i.MqttBrokerConnection:114  ] - Starting MQTT broker connection 'homeauto'
08:08:23.433 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:294  ] - Creating new client for 'tcp://' using id 'openhab.1469426903424' and file store '/tmp/homeauto'

08:08:56.760 [DEBUG] [.b.mqtt.internal.MqttActivator:34   ] - MQTT binding has been started.

08:08:56.830 [DEBUG] [i.internal.GenericItemProvider:341  ] - Start processing binding configuration of Item 'door (Type=ContactItem, State=Uninitialized)' with 'MqttGenericBindingProvider' reader.
08:08:57.069 [DEBUG] [b.mqtt.internal.MqttItemConfig:72   ] - Loaded MQTT config for item 'door' : 1 subscribers, 0 publishers
08:08:57.076 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:476  ] - Starting message consumer for broker 'homeauto' on topic 'homeAuto-out/101/3/1/0/16'

08:08:57.175 [DEBUG] [m.internal.MqttEventBusBinding:68   ] - MQTT: Activating event bus binding.

Nothing about ‘door’ in my event.log.

Thank you Sir for helping

Your mosquitto.log says that it stops to work. You should find the reason.

Yeah, to find the reason would make it easier to solve it. The problem is that I’m not used to work with mosquitto or linux so I’m trying the best I can but it a’int working, no matter what I do.

Anyone know this issue? How should the conf file look like and do I have to do any other configurations after installing mosquitto?



Now I have reinstalled MQTT and now my MQTT.log looks like this,

1469508265: New connection from on port 1883.
1469508265: New client connected from as homeAutoMQTT (c1, k15).
1469508300: Socket error on client homeAutoMQTT, disconnecting.
1469508300: New connection from on port 1883.
1469508300: New client connected from as homeAutoMQTT (c1, k15).
1469508334: Socket error on client homeAutoMQTT, disconnecting.

As you can see, it connects to my Arduino Mysensors MQTT Gateway, then it disconnects and then it continue like this in a loop for ever.

try to publish something using mosquitto_pub via command, it helps to understand if your mosquitto is ok and in that case something is wrong with your gateway.

Yeah, that one works. So the problem is in my gateway? It is an arduino Uno with Ethernet shield running Mysensors MQTTW5100 gateway. The source can you see below.

 * The MySensors Arduino library handles the wireless radio link and protocol
 * between your home built sensors/actuators and HA controller of choice.
 * The sensors forms a self healing radio network with optional repeaters. Each
 * repeater and gateway builds a routing tables in EEPROM which keeps track of the
 * network topology allowing messages to be routed to nodes.
 * Created by Henrik Ekblad <>
 * Copyright (C) 2013-2015 Sensnology AB
 * Full contributor list:
 * Documentation:
 * Support Forum:
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 * Version 1.0 - Henrik Ekblad
 * The W5100 MQTT gateway sends radio network (or locally attached sensors) data to your MQTT broker.
 * The node also listens to MY_MQTT_TOPIC_PREFIX and sends out those messages to the radio network
 * LED purposes:
 * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
 * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
 * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
 * - ERR (red) - fast blink on error during transmission error or recieve crc error  
 * See for wiring instructions.
 * nRF24L01+  ESP8266
 * VCC        VCC
 * CE         GPIO4          
 * CSN/CS     GPIO15
 * SCK        GPIO14
 * MISO       GPIO12
 * MOSI       GPIO13
 * Not all ESP8266 modules have all pins available on their external interface.
 * This code has been tested on an ESP-12 module.
 * The ESP8266 requires a certain pin configuration to download code, and another one to run code:
 * - Connect REST (reset) via 10K pullup resistor to VCC, and via switch to GND ('reset switch')
 * - Connect GPIO15 via 10K pulldown resistor to GND
 * - Connect CH_PD via 10K resistor to VCC
 * - Connect GPIO2 via 10K resistor to VCC
 * - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch')
  * Inclusion mode button:
 * - Connect GPIO5 via switch to GND ('inclusion switch')
 * Hardware SHA204 signing is currently not supported!
 * Make sure to fill in your ssid and WiFi password below for ssid & pass.

#include <SPI.h>

// Enable debug prints to serial monitor
#define MY_DEBUG 

// Enables and select radio type (if attached)
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69


// Set this nodes subscripe and publish topic prefix
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "homeAuto-out"

// Set MQTT client id
#define MY_MQTT_CLIENT_ID "homeAutoMQTT"

// W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
//#define MY_W5100_SPI_EN 4  

// Enable Soft SPI for NRF radio (note different radio wiring is required)
// The W5100 ethernet module seems to have a hard time co-operate with 
// radio on the same spi bus.
#if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
  #define MY_SOFTSPI
  #define MY_SOFT_SPI_SCK_PIN 14
  #define MY_SOFT_SPI_MISO_PIN 16
  #define MY_SOFT_SPI_MOSI_PIN 15

// When W5100 is connected we have to move CE/CSN pins for NRF radio
#ifndef MY_RF24_CE_PIN 
  #define MY_RF24_CE_PIN 5
#ifndef MY_RF24_CS_PIN 
  #define MY_RF24_CS_PIN 6

// Enable these if your MQTT broker requires usenrame/password
//#define MY_MQTT_USER "username"
//#define MY_MQTT_PASSWORD "password"

// Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
#define MY_IP_ADDRESS 192,168,254,228

// If using static ip you need to define Gateway and Subnet address as well
#define MY_IP_GATEWAY_ADDRESS 192,168,254,1
#define MY_IP_SUBNET_ADDRESS 255,255,255,0

// MQTT broker ip address or url. Define one or the other. 
#define MY_CONTROLLER_IP_ADDRESS 192,168,254,229

// The MQTT broker port to to open 
#define MY_PORT 1883      

// Flash leds on rx/tx/err
// Set blinking period

// Enable inclusion mode
// Enable Inclusion mode button on gateway
// Set inclusion mode duration (in seconds)
// Digital pin used for inclusion mode button

// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 10  // Error led pin
//#define MY_DEFAULT_RX_LED_PIN  9  // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN  8  // the PCB, on board LED

#include <Ethernet.h>
#include <MySensors.h>

void setup() { 

void presentation() {
  // Present locally attached sensors here    

void loop() {
  // Send locally attech sensors data here

@EricB in this post got things working with mosquitto rather than the MySensors gateway.