OctoPrint-TPLinkSmartplug icon indicating copy to clipboard operation
OctoPrint-TPLinkSmartplug copied to clipboard

[Feature Request]: Allow devices to be addressed by name, not just IP address

Open puterboy opened this issue 2 years ago • 15 comments

I have given all my plugs "names" in my router - so that I can address them by name which is helpful if the IP address changes. Any reason why this can't be enabled and allowed here?

puterboy avatar May 24 '22 21:05 puterboy

in theory if the name is resolvable by the pi the plugin is running on it should work. I have the setting to try and figure out the ip from hostname here

jneilliii avatar May 25 '22 00:05 jneilliii

But the GUI seems to only accept numerical IP addresses -- anything else shows up as 'red' print...

puterboy avatar May 25 '22 05:05 puterboy

Does it prevent you from saving?

jneilliii avatar May 25 '22 11:05 jneilliii

I hadn't tried because it was marked in 'red' and I thought it was an error. However, it does work nonetheless when I save it. Perhaps update the plugin to allow for valid hostnames?

puterboy avatar May 25 '22 15:05 puterboy

Yeah, I could remove the red highlighting from the field to counter that confusion and update the label. There is no good way to validate hostnames, so will depend on the status check to throw that error.

jneilliii avatar May 25 '22 17:05 jneilliii

Typically, it's up to the user to use a valid hostname. You could do some simple syntactic checks to make sure the hostname is consistent with the relevant RFC (maybe RFC 1035) -- e.g, no '@'

puterboy avatar May 26 '22 01:05 puterboy

I would like to see this implemented as well. In addition, a notes field would be useful. I was going to ask about using the MAC address (which I'd put in the notes if it wasn't entered somewhere else. The reason I ask is because my cable modem/router died and I had to replace it. All of the DHCP obtained IP addresses changed because the new modem/router uses a different net block (used to be 192.168.0.0/24, is now 10.0.0.0/24). If I had a place to record the MAC address, I can look at the DHCP server to find the new IP address.

b-morgan avatar Jul 16 '22 22:07 b-morgan

@b-morgan I see you found the other FR about MAC Address addressing, but you can use hostname in the ip field even though it highlights it as red, di you happen to try that? I haven't heard back from anyone else if it works as expected.

jneilliii avatar Jul 17 '22 07:07 jneilliii

Yes it works (despite the red). Sorry for not confirming earlier with you. jneilliii wrote at about 00:09:37 -0700 on Sunday, July 17, 2022:

@b-morgan I see you found the other FR about MAC Address addressing, but you can use hostname in the ip field even though it highlights it as red, di you happen to try that? I haven't heard back from anyone else if it works as expected.

-- Reply to this email directly or view it on GitHub: https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/issues/312#issuecomment-1186425560 You are receiving this because you authored the thread.

Message ID: @.***>

puterboy avatar Jul 17 '22 07:07 puterboy

Unless I can figure out how to name the plugs, each plug's name is the model name of the plug, i.e. HS105, HS103, and HS300 so while I tried the name, it didn't work.

BTW, I'm happy to collect any debugging information you need.

b-morgan avatar Jul 17 '22 13:07 b-morgan

I did some research and changing the hostname of a plug doesn't appear to be possible. Issue #76 appears to be the best option. Alternatively, adding a "note" field to each entry would allow documenting the MAC address which could then be used to obtain the IP address manually.

b-morgan avatar Jul 17 '22 14:07 b-morgan

Thanks @b-morgan, obviously for those that only have one plug they can use hostname. Unfortunately, I never really found a good MAC to IP address translation option for python that wasn't a full network scanning/hacking tool which is why the option hasn't been implemented.

jneilliii avatar Jul 17 '22 15:07 jneilliii

How about adding a text "note" field to each entry. You don't have to do anything with it.

b-morgan avatar Jul 17 '22 15:07 b-morgan

Yes, I can definitely do that which is one reason I was leaving this issue open (that and red highlighting/label for IP). I was just looking at the original source of the encryption/decryption I used for this from softScheck and there is a PR that implements a broadcast option. I could probably implement something like that to create a discovery of devices and create a lookup table based on the "info" command to all plugs in the network. Would probably take me a while to program that and test though. I think the wemo library I use for that plugin incorporates a similar approach for device discovery.

jneilliii avatar Jul 17 '22 16:07 jneilliii