tobiasfaust / SolaxModbusGateway

Modbus RTU to MQTT Gateway
GNU General Public License v3.0
54 stars 17 forks source link

Add support for Webrequest post of data #25

Closed crathje closed 3 months ago

crathje commented 11 months ago

Support for posting the live data values as json to an arbitrary web page.

tobiasfaust commented 11 months ago

Hi, Without checking your Patch, Your Description sounds like an existent feature:

Check it at your ESP32 by using this url /getitems

https://github.com/tobiasfaust/SolaxModbusGateway/blob/104c32f4c54aa0575e6e598008d25f9e3e0b76e6/src/modbus.cpp#L1360

crathje commented 11 months ago

Hi Tobias,

the supplied patch adds support to actual backend code to upload data to a webpage: Screenshots_2023-07-25-18-13-45

The post request contains a json with all configured/active modbus values.

This is for the people that are not actively using a MQTT broker. I am posting the stuff to webserver that persists the data in a relational database. Quite old fashioned but works 😉 Despite MQTT being from the last century I sometimes got the feeling that it is not that wide spread as it could/should be...

Cheers Claas

tobiasfaust commented 11 months ago

Hi claas, I would prefer that your Webserver calls the /getitems constantly. Maybe via JavaScript or php and process them into your database.

I use a database too, but i use fhem (fhem.de) and a fhem-mqtt Module. You can use a public MQTT Server too.

I think I cannot apply your great work because its too special and you need a configured Webserver to handle it

crathje commented 11 months ago

Issue would be that the Webserver is not on the same net and cannot reach the esp32 but vice versa (esp32 can reach the Webserver).

Scenario would be more like having a Node-RED HTTP In: https://cookbook.nodered.org/http/post-json-data-to-a-flow

But it is okay if you decline it - 'works for me' sometimes means the same as 'only works for me'.

tobiasfaust commented 11 months ago

Do you use nodered? In this Case NodeRed is able to interact with a MQTT-Server. Or what are you using as targetsite/Webserver? A Self-developed Solution?

crathje commented 11 months ago

I am using some self developed stuff... And I do not run a productive MQTT server. Sometimes it is easier to get a hosted webspace with database access than running a custom/root server (with MQTT) or posting your data to a public MQTT server.

I was using thingspeak before they required a paid plan for frequent requests and replaced it with an api compatible solution. And after that TheThingsNetwork for lorawan came to the yard and they support posting the data to Web backends as json - hence I added that. And this why I added this here as well. Did not require setting anything new up.

But as I stated: In case posting the data as json via a http post is too seldomly used I am OK with declining the pull request.

For me it is working and I propably will never update the esp32 anyway 😂