warthog618 / dunnart

Lightweight remote system monitoring over MQTT for Home Assistant
MIT License
13 stars 2 forks source link

Run-Error: discovery: can't find mac #3

Closed Mimosinito closed 5 months ago

Mimosinito commented 5 months ago

I have compiled your app with Debian Bullseye and newest go (version go1.22.3 linux/amd64). When I start it, I only get the error: discovery: can't find mac

I do have disabled module NET.

warthog618 commented 5 months ago

A MAC address is required to uniquely identify the device with HA, so whether you are using the NET module is not relevant. By default, the get_mac function tries to determine the MAC address from one of the standard network interfaces - "eth0", "enp3s0" or "wlan0". If you have none of those then you need to specify the interface to use in the config file.

From the example config file:

#homeassistant:
#  birth_message_topic: homeassistant/status
#  discovery:
#    prefix: homeassistant
#    status_delay: 15s
#    node_id: <hostname>
#    mac_source: [eth0, enp3s0, wlan0]    <--- here

So add

homeassistant:
  discovery:
    mac_source: [ethX] 

where "ethX" is whatever network interface you do have setup.

warthog618 commented 5 months ago

That is also described in the HomeAssistant configuration section of the README.

And I've added the option to specify a MAC address explicitly in the config file, if searching for it in the available interfaces is too tricky. I was considering allowing the _macsource fields to be regexes, but that could make the search result potentially unstable, and it needs to be stable or HA will get confused.

Mimosinito commented 5 months ago

Ok, i added the correct "mac_source: [enp1s0]" and all works well. Thanx