OpenEVSE / openevse_wifi_server

15 stars 11 forks source link

Add 'describe' end-point #4

Closed glynhudson closed 5 years ago

glynhudson commented 5 years ago

Please could you port this addition to the NodeJS web server

https://github.com/OpenEVSE/ESP8266_WiFi_v2.x/commit/dd4de35b3611ceea24bb58465a3c16920b259bdb

Thanks

jeremypoulter commented 5 years ago

Sure, although you probably want more than just openevse. Would it not be better to send a JSON response with some useful info? Say:

{
  "type": "openevse",
  "variant": "nodejs",
  "version": "0.0.1",
  "hardware": "Raspberry Pi 3B"
}
jeremypoulter commented 5 years ago

Also there are a bunch of protocols for device discovery, eg SSDP or mDNS (the latter is already installed and running on all your devices, just need to define a custom device profile)

glynhudson commented 5 years ago

Yes, it might well be an idea in the future to add more info. But I believe currently emoncms find only supports a single device name. Let's keep it simple for now.

We wanted a simple lightweight method that worked across all platforms, @emrysr came up with emoncms find, it works very well. It's full javascript browser based and does not require anything running locally.

Out of interest what's involved in defining a custom mDNS profile? Do you have experience? We have found hostname lookup to be unreliable between different networks.

jeremypoulter commented 5 years ago

Interesting, not looked at the details of emoncms find although I have seen mention of it in the forum. Interesting that is is entirely browser based, I hope it isn't doing anything nasty like trying to fetch a known URL off every IP in a subnet and assuming that a subnet is 256 IPs?

Both SSDP and mDNS are really light weight as long as you don't confuse then with some of the things that sit on top (like UPnP for example).

Out of interest what's involved in defining a custom mDNS profile? Do you have experience? We have found hostname lookup to be unreliable between different networks.

Something like this https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266mDNS/src/LEAmDNS.cpp#L1113:L1128

I think that has to do with trying to look up stuff on demand, I think these protocols work better if you have a daemon running all the time listening for announcements, (although most of my experience is from the SSDP/UPnP world, but same basic principle)

jeremypoulter commented 5 years ago

But back to the topic will add the end point do you want it to just return openevse, or something different to distinguish from the ESP8266 version?

glynhudson commented 5 years ago

I think 'openevse' is fine for the moment, most users will only had a single openevse. I guess we should have some way to distinguish between the two in the interface. I think appending a 'JS' to the name would confuse nontechnical users. The purpose of Fine is to allow the user to easily find the IP address rather than a technical description.

This is an example of how Find works: https://codepen.io/emrys/full/aPKPzv there is a brief description on the read me. It's quite amazing that it can work in a browser. I think it only works on Chrome / Firefox and not Safari.