Custom build ESP8266+Relays Auto Discovery by Openhab2

I started some project recently, just to reduce number of modifications after each configuration change on ESP device or in home network. I may not be the easiest solution on the earth but it works for me, so maybe it will work for you :slight_smile: Take a look at https://github.com/adrb/mqradar

thanks in advance!

but i will wait for:https://github.com/xoseperez/espurna/issues/1442

Would you have link to how to setup mDNS? - I am struggling with the same issue and do not want fixed ip for my mqtt broker.

MDNS is pretty simple… if you’ve got the ESP8266mDNS library included in your sketch, just do a:

MDNS.begin("hostname");

I usually set my hostnames to a project prefix, and the chipId, so:

String hostname="ProjectPrefix-" + String(ESP.getChipId());

That’ll create a projectprefix-aaaaaa.local in MDNS (whatever the chipId is) – ensuring every device is unique.

I also use the SSDP protocol to expose the units to SSDP-aware systems (like Windows Explorer), which makes them show up in the Network area under “Other Devices”. The nice thing about that is you can also expose the management URL for it, so when I double click on their icons in Explorer, it just opens right up.

SSDP is trickier, though – the ESP library for it is buggy and doesn’t publish the metadata correctly, so they don’t show up in Windows. I had to write my own code to do it. (But they will be found by the UPnP discovery code in OpenHab, if you write your own binding.)

1 Like

What I have done in many of my ESP devices is to actually make them call OH /rest/item to create the thing/item themselves. No need for other configuration/paperui inbox, etc. Just make a GET call to /rest/items/someName and if it returns 404, you need to make a PUT reqeust to create it. Once that receives a 201 (created) you can start POSTing states to it. This is usually how I do it.

1 Like