tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
316 stars 58 forks source link

DHCP feature - client and/or relay + server #321

Open TV456 opened 1 year ago

TV456 commented 1 year ago

Is your feature request related to a problem?

It would be awesome to have a feature where you can integrate the dhcp values like client, relay and/or server. In my case I would really like to read the dhcp client values and let them show up in HA. It is helpfull to get this information when you have a dynamic dns from your ISP. There has been a earlier feature request.

Desired solution

Not all users need this information, because it depends on their set up. I would love to see an extra option in the configuration to select. In this case the option (i.e.) 'DHCP client list' which returns the various interface, IP-address, lease and status values.

While tinkering with setting up other sensors for my system health, I found that the script/api already retrieves the ip/dhcp/client values. I have tried to alter the code to set it up like I described above, but unfortunately I lack the coding skills to get it up and running. (I am breaking the configuration options and with that the api request for all 'extra' values.)

Alternatives

There is also the possibility to retrieve the desired values from the IP Address list, which I used in my reply on the earlier feature request I have replied how to create and environmental variable and a script to update it. This works but it would be a very nice feature to have 'out-of-the-box'.

tomaae commented 1 year ago

I'm not sure I understand. can you show me which value(s) you need in mikrotik?

TV456 commented 1 year ago

To explain I have made some screen shots and some mockup's.

In RouterOS Winbox, I need the value(s) of the /ip/dhcp-client/ table. Especially the IP Address corresponding to the Interface, marked with the red oval:

RouterOS-DHCP-Client

I attempted to set up an extra option in the options for the configuration (2/2), also marked with the red oval in the mockup:

RouterOS - HA - configuration screen

Then it would be great to see the dhcp clients as devices in HomeAssistant, something like the next mockup:

RouterOS - HA - device

And with i.e. the following attributes of the device (escpecially the IP-Address and the Status), like the following mockup:

RouterOS - HA - Device - Attributes
tomaae commented 1 year ago

I see, so adding ip and interface to clients where possible. Should be doable. IP and mac is actually available on traffic sensors for clients already.

TV456 commented 1 year ago

The MAC-addresses are indeed already available, but the IP-addresses are only available when internally given (from the dhcp-server), when a port or bond is a dhcp-client, the IP-address shows up as none.