MySensors MQTT Gateway Integration

Hi!

I’m pretty new to Hassio but even newer to MQTT. I’ve built a MySensors (MS) MQTT gateway and a simple binary sensor that I know are working. MQTT topics are sent out from the MS gateway and I’ve validated the topic data using the MS Log Parser.

The problem is I’m not getting anything in the homeassistant.log file so I have no idea how to identify the sensor.

Am I going about things the wrong way? It feels like I’m so close but I just can’t work it out.

My configuration is below, I’m using the hassio mqtt addon as the broker.

configuration.yaml

homeassistant:
  name: Home
  latitude: !secret home_lat
  longitude: !secret home_long
  elevation: 43
  unit_system: metric
  time_zone: Europe/Stockholm
  customize: !include includes/customize.yaml

# Enables the frontend
frontend:

# Enables configuration UI
config:

http:
  api_password: !secret hass_api_pass
  server_port: 443
  ssl_certificate: /ssl/hass.pem
  ssl_key: /ssl/hass_s.key
  cors_allowed_origins:
    - https://google.com
    - https://home-assistant.io
  use_x_forwarded_for: True
  trusted_networks:
    - 127.0.0.1
    - ::1
    - 10.10.1.0/24
    - 10.1.1.0/24
    - 172.31.254.0/24
  ip_ban_enabled: False
  login_attempts_threshold: 5

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# Text to speech
tts:
  - platform: google

# Enable Z-Wave  
zwave:
  usb_path: /dev/ttyACM0
  network_key: "0xFA, 0x08, 0x7A, 0xA9, 0x1A, 0xE7, 0xF1, 0x08, 0x0D, 0x83, 0x8C, 0xEF, 0xC6, 0x57, 0x83, 0x76"
  
# Tellstick
tellstick:
    host: core-tellstick
    port: [50800, 50801]
    signal_repetitions: 7
    
# MQTT
mqtt:
  broker: core-mosquitto
  username: !secret mqtt_user
  password: !secret mqtt_pass
  client_id: hass01
  
# MySensors
mysensors:
  gateways:
    - device: mqtt
      persistence_file: 'mysensors/mysensorsPer.json'
      topic_in_prefix: 'mqttgw1-in'
      topic_out_prefix: 'mqttgw1-out'
  optimistic: false
  persistence: true
  retain: true
  version: '2.0'

# Logger

logger:
  default: warning
  logs:
    homeassistant.components.mysensors: debug
    mysensors: debug
    homeassistant.components.mqtt: debug
##########################################################
# Includes
##########################################################
automation: !include includes/automations.yaml
device_tracker: !include includes/device_tracker.yaml
group: !include includes/groups.yaml
media_player: !include includes/mediaPlayers.yaml
script: !include includes/scripts.yaml
sensor: !include includes/sensors.yaml
switch: !include includes/switches.yaml
zone: !include includes/zones.yaml

MQTT Add-On config

{
  "plain": true,
  "ssl": true,
  "anonymous": false,
  "logins": [
    {
      "username": "hassmqtt",
      "password": "redacted"
    }
  ],
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "hass.pem",
  "keyfile": "hass_s.key"
}

homeassistant.log

2018-01-17 22:02:59 INFO (Thread-3) [mysensors.gateway_mqtt] Setting up initial MQTT topic subscription
2018-01-17 22:02:59 DEBUG (Thread-3) [mysensors.gateway_mqtt] Subscribing to: mqttgw1-in/+/+/0/+/+, qos: 0
2018-01-17 22:02:59 DEBUG (Thread-3) [mysensors.gateway_mqtt] Subscribing to: mqttgw1-in/+/+/3/+/+, qos: 0
2018-01-17 22:03:09 WARNING (SyncWorker_5) [netdisco.ssdp] Error fetching description at http://10.10.1.254:8200/rootDesc.xml
2018-01-17 22:10:44 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting

MySensors Console Output

0;255;3;0;9;Sending message on topic: mqttgw1-out/1/3/1/0/16
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=3,c=1,t=16,pt=2,l=2,sg=0:1
0;255;3;0;9;Sending message on topic: mqttgw1-out/1/3/1/0/16
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=3,c=1,t=16,pt=2,l=2,sg=0:0
0;255;3;0;9;Sending message on topic: mqttgw1-out/1/3/1/0/16
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=3,c=1,t=16,pt=2,l=2,sg=0:1
0;255;3;0;9;Sending message on topic: mqttgw1-out/1/3/1/0/16

Any would be so appreciated!

EDIT: Forgot to add, hassio version is 0.60.1 :slight_smile:

/Ed

I think you’ve inverted the topics in/out. The topic prefix config keys are referring to the home assistant side, so the topic that the gateway publishes to, mqttgw1-out, should be connected to the topic_in_prefix, and vice versa.

Btw, check your persistence file path. It looks weird when you use a relative path like that. I don’t use Hass.io, so that might be a thing there but otherwise it should always be absolute paths.

Hey Martin,

Thanks for pointing that out. I’ve switched around the topic prefixes and removed the definition for the persistence file - there is a default configured in the component so it felt necessary plus i don’t know the relative path myself on hassio.

I’m still not getting anything via logger but i see that mosquitto is connected to the mysensors gateway, and as i mentioned earlier the gateway is working as intended (i’ve verified traffic and topics are sent out correctly using mosquitto for windows).

Any other ideas regarding logging? I’m assuming I don’t need to define sensors to be able to see anything in the mqtt debug log?

Thanks

Ed

1 Like

Just wanted to say that I finally resolved this. I upgraded HASS to 61.1 from 60.1, this gave me log entries for the mysensors component. I also make a change to the code on the sensor based on what was reported in the logs.

I’ve been using the door/button example from the mysensors website, in the sketch the presentation section wasn’t presenting the sketch name. This is fine for mysensors, not for hassio. HASS creates an entity based on the sketch name so nothing was showing up in HASS. :slight_smile:

1 Like

Awesome! Any chance you would publish a repo (or did I miss that)?

Thanks

Sorry haven’t got Git up and running yet but I’ve copied in the code below //Ed

configuration.yaml

homeassistant:
  name: Home
  latitude: !secret home_lat
  longitude: !secret home_long
  elevation: 43
  unit_system: metric
  time_zone: Europe/Stockholm
  customize: !include includes/customize.yaml

# Enables the frontend
frontend:

# Enables configuration UI
config:

http:
  api_password: !secret hass_api_pass
  server_port: 443
  ssl_certificate: /ssl/hass.pem
  ssl_key: /ssl/hass_s.key
  cors_allowed_origins:
    - https://google.com
    - https://home-assistant.io
  use_x_forwarded_for: True
  trusted_networks:
    - 127.0.0.1
    - ::1
    - 10.10.1.0/24
    - 10.1.1.0/24
    - 172.31.254.0/24
  ip_ban_enabled: False
  login_attempts_threshold: 5

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time
history:

# View all events in a logbook
logbook:

# Enables a map showing the location of tracked devices
map:

# Track the sun
sun:

# Text to speech
tts:
  - platform: google

# Enable Z-Wave  
zwave:
  usb_path: /dev/ttyACM0
  network_key: "0xFA, 0x08, 0x7A, 0xA9, 0x1A, 0xE7, 0xF1, 0x08, 0x0D, 0x83, 0x8C, 0xEF, 0xC6, 0x57, 0x83, 0x76"
  
# Tellstick
tellstick:
    host: core-tellstick
    port: [50800, 50801]
    signal_repetitions: 7
    
# MQTT
mqtt:
  broker: core-mosquitto
  username: !secret mqtt_user
  password: !secret mqtt_pass
  client_id: hass01
  
# MySensors
mysensors:
  gateways:
    - device: mqtt
      topic_in_prefix: 'mqttgw1-out'
      topic_out_prefix: 'mqttgw1-in'
  optimistic: false
  persistence: true
  retain: true
  version: '2.0'

# Logger

logger:
  default: warning
  logs:
    homeassistant.components.mysensors: debug
    mysensors: debug
    
##########################################################
# Includes
##########################################################
automation: !include includes/automations.yaml
device_tracker: !include includes/device_tracker.yaml
group: !include includes/groups.yaml
media_player: !include includes/mediaPlayers.yaml
script: !include includes/scripts.yaml
sensor: !include includes/sensors.yaml
switch: !include includes/switches.yaml
zone: !include includes/zones.yaml

MySensors MQTT Gateway

/**
 * 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 <[email protected]>
 * Copyright (C) 2013-2015 Sensnology AB
 * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * 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.
 *
 *******************************
 *
 * REVISION HISTORY
 * Version 1.0 - Henrik Ekblad
 *
 * DESCRIPTION
 * 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 http://www.mysensors.org/build/esp8266_gateway 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.
 */


// Enable debug prints to serial monitor
#define MY_DEBUG

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

#define MY_GATEWAY_MQTT_CLIENT

// Set this node's subscribe and publish topic prefix
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mqttgw1-out"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mqttgw1-in"

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

// 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
#endif

// 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
#endif
#ifndef MY_RF24_CS_PIN
#define MY_RF24_CS_PIN 6
#endif

// Enable these if your MQTT broker requires usenrame/password
#define MY_MQTT_USER "hassmqtt"
#define MY_MQTT_PASSWORD "[redacted]"

// Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
#define MY_IP_ADDRESS 10,10,1,12

// If using static ip you can define Gateway and Subnet address as well
#define MY_IP_GATEWAY_ADDRESS 10,10,1,1
#define MY_IP_SUBNET_ADDRESS 255,255,255,0

// MQTT broker ip address or url. Define one or the other.
//#define MY_CONTROLLER_URL_ADDRESS "m20.cloudmqtt.com"
#define MY_CONTROLLER_IP_ADDRESS 10, 10, 1, 11
// Vault57 broker
//#define MY_CONTROLLER_IP_ADDRESS 10, 1, 1, 7

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

// The MAC address can be anything you want but should be unique on your network.
// Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
// Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
//#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED

/*
// Enable inclusion mode
#define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
//#define MY_INCLUSION_BUTTON_FEATURE
// Set inclusion mode duration (in seconds)
#define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
//#define MY_INCLUSION_MODE_BUTTON_PIN  3

// Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300

// Flash leds on rx/tx/err
// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
//#define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
*/

#include <Ethernet2.h>
#include <MySensors.h>

void setup()
{
    // Setup locally attached sensors
}

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

void loop()
{
    // Send locally attached sensors data here
}

MySensors Binary Sensor

/**
 * 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 <[email protected]>
 * Copyright (C) 2013-2015 Sensnology AB
 * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
 *
 * Documentation: http://www.mysensors.org
 * Support Forum: http://forum.mysensors.org
 *
 * 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.
 *
 *******************************
 *
 * DESCRIPTION
 *
 * Simple binary switch example 
 * Connect button or door/window reed switch between 
 * digitial I/O pin 3 (BUTTON_PIN below) and GND.
 * http://www.mysensors.org/build/binary
 */


// Enable debug prints to serial monitor
#define MY_DEBUG 

// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69

#include <SPI.h>
#include <MySensors.h>
#include <Bounce2.h>

#define CHILD_ID 0
#define BUTTON_PIN  3  // Arduino Digital I/O pin for button/reed switch

Bounce debouncer = Bounce(); 
int oldValue=-1;

// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg(CHILD_ID,V_STATUS);

void setup()  
{  
  // Setup the button
  pinMode(BUTTON_PIN,INPUT);
  // Activate internal pull-up
  digitalWrite(BUTTON_PIN,HIGH);
  
  // After setting up the button, setup debouncer
  debouncer.attach(BUTTON_PIN);
  debouncer.interval(5);
  
}

void presentation() {
  // Register binary input sensor to gw (they will be created as child devices)
  // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
  // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
  sendSketchInfo("Binary", "1.0");
  present(CHILD_ID, S_BINARY);  
}


//  Check if digital input has changed and send in new value
void loop() 
{  
  debouncer.update();
  // Get the update value
  int value = debouncer.read();
 
  if (value != oldValue) {
     // Send in the new value
     send(msg.set(value==HIGH ? 1 : 0));
     oldValue = value;
  }
}
2 Likes

Thanks! Will give this a spin…

Great that you found a solution. The general requirements for presenting a mysensors device in home assistant are documented here:

Hi
I have a problem with Mysensors Gateway by MQTT for cover. This is my sketch which i write on Arduino Mega.

// Enable debug prints to serial monitor
//#define MY_DEBUG

// Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
//#define MY_BAUD_RATE 9600

#define MY_TRANSPORT_WAIT_READY_MS 1

// uncomment if we want to manually assign an ID
#define MY_NODE_ID 3


// !!!! CHOOSE ONLY ONE !!!!

//#include "ESPGateway.h" // for ESP8266 WiFi gateway -> set your WiFi in ESPGateway.h tab!
//#include "SerialGateway.h" // for Serial gateway
//#include "RF24Gateway.h" // for RF24 radio gateway
#include "MQTTGateway.h" // for MQTT Ethernet gateway



#include <Bounce2.h>
#include <PMButton.h>
#include <MySensors.h>
#include <SPI.h>

#include "RollerShutter.h"

/* define your RollerShutter objects here
 RollerShutter(int childId      // Cover/Roller Shutter device ID for MySensors and Controller (Domoticz, HA etc)
              , int setIdUp     // Roll time UP setpoint device ID for MySensors and Controller (Domoticz, HA etc)
              , int setIdDown   // Roll time DOWN setpointdevice ID for MySensors and Controller (Domoticz, HA etc)
              , int initId      // Initialization device ID for MySensors and Controller (Domoticz, HA etc)
              , int buttonUp    // Button Pin for UP
              , int buttonDown  // Button Pin for DOWN
              , int relayUp     // Relay Pin for UP
              , int relayDown   // Relay Pin for DOWN
              , uint8_t initTimeUp          // Initial Roll time UP
              , uint8_t initTimeDown        // Initial Roll time DOWN
              , uint8_t initCalibrationTime // Initial calibration time (time that relay stay ON after reach 0 or 100%)
              , int debaunceTime            // Time to debounce button -> standard = 50
              , bool invertedRelay          // for High level trigger = 0; for Low level trigger = 1
              )
*/

bool service = 0;
int servicePin = 32;
int serviceLedPin = 33; // built-in LED

RollerShutter blinds[] =
{
  {1, 21, 41, 61, A0, A1, 13, 12, 24, 23, 5, 50, 0, "Roleta kuchnia1"},
//  {2, 22, 42, 62, A2, A3, 11, 10, 23, 23, 5, 50, 0, "Roleta kuchnia2"},
//  {3, 23, 43, 63, A4, A5, 9, 8, 30, 30, 5, 50, 0, "Roleta wykusz"},
//  {4, 24, 44, 64, A6, A7, 7, 6, 32, 30, 5, 50, 0, "Roleta salon-taras"},
//  {5, 25, 45, 65, A8, A9, 5, 4, 26, 25, 5, 50, 0, "Roleta gabinet"},
//  {6, 26, 46, 66, A10, A11, 3, 2, 16, 16, 5, 50, 0, "Roleta kotlownia"},
//  {7, 27, 47, 67, A12, A13, 14, 15, 17, 17, 5, 50, 0, "Roleta garaz"},
//  {8, 28, 48, 68, A14, A15, 16, 17, 38, 35, 5, 50, 0, "Roleta Zuzia"},
//  {9, 29, 49, 69, 53, 52, 18, 19, 37, 35, 5, 50, 0, "Roleta pokoj2"},
//  {10, 30, 50, 70, 51, 50, 20, 21, 37, 35, 5, 50, 0, "Roleta sypialnia"},
//  {11, 31, 51, 71, 49, 48, 22, 23, 35, 35, 5, 50, 0, "Roleta pralnia"},
//  {12, 32, 52, 72, 47, 46, 24, 25, 25, 20, 5, 50, 0, "Roleta dach Zuzia"},
//  {13, 33, 53, 73, 45, 44, 26, 27, 25, 20, 5, 50, 0, "Roleta dach pok.2"},
//  {14, 34, 54, 74, 43, 42, 28, 29, 25, 20, 5, 50, 0, "Roleta lazienka"},
//  {15, 35, 55, 75, 41, 40, 30, 31, 25, 20, 5, 50, 0, "Roleta dach klatka"}
};

const int blindsCount = sizeof(blinds) / sizeof(RollerShutter);

void setup() 
{ 
  // Service Mode input = D2 -> only if pass-through mode is needed, f.e. for programming the build-in motor's limit switches.
  pinMode(servicePin, INPUT_PULLUP);
  service = !digitalRead(servicePin);
  pinMode(serviceLedPin, OUTPUT);
  digitalWrite(serviceLedPin, service);
  
  // Setup locally attached sensors
  wait(5000);
  for(int i = 0; i < blindsCount; i++)
  {
    blinds[i].SyncController(); 
    if(service)
    {
      blinds[i].enterServiceMode(); 
    }
  }
}

void presentation()  
{   
  // Send the sketch version information to the gateway and Controller
  sendSketchInfo("Cover", "22.0");
  for(int i = 0; i < blindsCount; i++)
  {
    blinds[i].Present(); 
  }
}

void loop() 
{ 
  for(int i = 0; i < blindsCount; i++)
  {
    blinds[i].Update(); 
  }
}

void receive(const MyMessage &message) {
  for(int i = 0; i < blindsCount; i++)
  {
    blinds[i].Receive(message); 
  }
}

It is code for MQTT from sketch mysensors:

#define MY_GATEWAY_MQTT_CLIENT

#define MY_MQTT_PUBLISH_TOPIC_PREFIX "HomeAssistant/in/MyMQTT"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "HomeAssistant/out/MyMQTT"

// 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
#endif

// 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
#endif
#ifndef MY_RF24_CS_PIN
#define MY_RF24_CS_PIN 6
#endif
*/

#define MY_MQTT_CLIENT_ID "Cover_MQTT_ETH"

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

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

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

// The MAC address can be anything you want but should be unique on your network.
// Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
// Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
#define MY_MAC_ADDRESS 0xBA, 0xDC, 0xCA, 0x02, 0x3B, 0x0F

// MQTT broker ip address or url. Define one or the other.
//#define MY_CONTROLLER_URL_ADDRESS "m20.cloudmqtt.com"
#define MY_CONTROLLER_IP_ADDRESS 192, 168, 13, 5

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

#include <Ethernet.h>

And it is my config from HomeAssistant:

mysensors:
  gateways:
    - device: mqtt
      persistence_file: '/config/cover_mqtt_eth.json'
      topic_in_prefix: 'HomeAssistant/out/MyMQTT'
      topic_out_prefix: 'HomeAssistant/in/MyMQTT'
  optimistic: false
  persistence: true
  retain: true
  version: '2.3'

In HomeAssistant i dont find this cover. On arduino it works because i see when click button. ALso communication with MQTT Broker is connected because i see in logs that W5100 is connected to MQTT. But not find in state this cover.
please help me. I am beginner with MQTT. Also in file ‘/config/cover_mqtt_eth.json’ is empty. not find any nods…

Debug logs. But json files is empty.

2019-12-24 08:25:01 WARNING (MainThread) [homeassistant.config_entries] Config entry for wled not ready yet. Retrying in 5 seconds.
2019-12-24 08:25:19 DEBUG (SyncWorker_16) [mysensors.persistence] Loading sensors from persistence file /config/cover_mqtt_eth.json
2019-12-24 08:25:19 DEBUG (SyncWorker_15) [mysensors.persistence] Saving sensors to persistence file /config/cover_mqtt_eth.json
2019-12-24 08:25:19 INFO (MainThread) [mysensors.gateway_mqtt] Setting up initial MQTT topic subscription
2019-12-24 08:25:19 DEBUG (MainThread) [mysensors.gateway_mqtt] Subscribing to: HomeAssistant/out/MyMQTT/+/+/0/+/+, qos: 0
2019-12-24 08:25:19 DEBUG (MainThread) [mysensors.gateway_mqtt] Subscribing to: HomeAssistant/out/MyMQTT/+/+/3/+/+, qos: 0