enwi / RNGBridgeDoc

Documentation and guides for RNGBridge the renogy to wifi bridge with PVOutput and MQTT support and much more
17 stars 0 forks source link

Enhancement: read charge controller data using REST #11

Closed Doggy77 closed 2 years ago

Doggy77 commented 2 years ago

It would be cool to use the REST API for reading the charge controller parameters according to the MQTT response.

In my use case the MQTT data is sent using a 4G Router from my garden shed to my server. A second raspberry oder microcontroller can act according to the charge controller states, e.g. switch something off when an errror appears or switch something on when the sun goes down (panel voltage drops to zero). This can be done by subscribing to the MQTT, but as soon as the 4G would fail there is no possibility to get the controller data locally on the LAN.

By using GET requests for the REST API and reading the states directly from the RNGBridge an offline/failsafe operation would be possible.

enwi commented 2 years ago

So you mean that you set up RNGBridge in access point mode and then have another ESP8266 connect to said AP and poll the REST api?

Doggy77 commented 2 years ago

No. At my garden I have an access point Router with 4g Internet connection and a Raspberry pi with wireguard VPN für tunneling all data traffic to my home server , which is also the MQTT server that collects the MQTT data. The Raspberry pi in the garden also controls shades, collects environment data and controls the watering pump for the produce. The watering pump shall switch off or not switch on via GPIO as long as e.g. the battery is too low. For this I would be able to read the rngbridge's data weithin the local LAN without the need to rely on the VPN and the 4g connection in order to read data from my MQTT home server. Just by Rest API GET calls directly to the WiFi connected rngbridge.

enwi commented 2 years ago

Should be fairly easy to implement :)

Doggy77 commented 2 years ago

In a brief: Getting the same json as from MQTT by http get. IP/api/status as according to IP/api/control for setting the output maybe.

enwi commented 2 years ago

I have been thinking about this feature, but since RNGBridge already sends it's data using an EventSource wouldn't it be easier to just connect to that? I mean it sends a status every second, so you would have to handle all that data. Or do you think polling a REST API is still better suited?

enwi commented 2 years ago

REST api for getting state added with V2.7.0