mp-se / kegmon

DIY scale for beer keg monitoring
MIT License
11 stars 4 forks source link

Add ability to push data to Barhelper #35

Closed wookienow closed 4 days ago

wookienow commented 1 week ago

Add the ability to push data to Barhelper for Taplist display https://barhelper.no/

mp-se commented 1 week ago

Do you have any documentation on how there API's looks like ? I could not find anything useful on the URL you shared.

Normally this should not be a big change to add.

mp-se commented 1 week ago

Found the details in the docs.... Will give it a try

mp-se commented 1 week ago

There are apparently 2 ways to report data, either the current volume or the detected pour volume... which is to prefer?

mp-se commented 1 week ago

You can try this version here; https://github.com/mp-se/kegmon/tree/dev/bin, I will do some more testing before releasing beta 2

It updates the volume in Barhelper once there is a stable level. This seamed to be the best option to secure the level is accurate.

wookienow commented 1 week ago

Amazing. Will try the binary tonight.

wookienow commented 1 week ago

@mp-se I have had a go. I can see in the log when weights change publishing to MQTT and this is working. I have configured the Barhelper API key but I am not seeing anything in the logs saying it is trying to publish to barhelper. Or anything in barhelper. It looks like it should log in the console in the barhelper.cpp code. Any idea what else I could try? Will it work with both configured?

mp-se commented 1 week ago

You will get a printout in the serial log when sending data to barhelper, and also the response. Unfortunately the response is not a real json (they have made a misstake) so i cannot parse and check the return. I have reported that problem to the author so we will have to see if they fix that.

You basically just need to enter the API KEY and have a name for the taps. The integration will not work without the API KEY.

Data will be posted when there is a stable level and if there is no defined Custom Keg Monitor it will be created. You then need to connect that to a tap/keg.

But it would be a good idea to have the status visible in the UI (or at least the last status) for each integration

mp-se commented 6 days ago

You can try the new build in the dev branch, it how will show the current status of the transmissions on the main page

wookienow commented 6 days ago

Thanks will try tonight. Have you thought about making the pins configurable? I am moving from another scale software which had a different default pinout. I would love to be able to avoid resoldering 7 more scales if I could.

On Wed, 11 Sept 2024, 2:56 am Magnus, @.***> wrote:

You can try the new build in the dev branch, it how will show the current status of the transmissions on the main page

— Reply to this email directly, view it on GitHub https://github.com/mp-se/kegmon/issues/35#issuecomment-2341484805, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6EHQQHSIKP6QYN2JCXFETZV4QDHAVCNFSM6AAAAABN4FRBE6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBRGQ4DIOBQGU . You are receiving this because you authored the thread.Message ID: @.***>

mp-se commented 6 days ago

The pins are configurable under hardware

wookienow commented 6 days ago

I am getting this error. I am able to call the API directly and it works with the same key externally. Any ideas.

error

mp-se commented 6 days ago

-1 means "connection refused" so do you have a firewall that blocks the request ?

wookienow commented 6 days ago

No. Nothing blocking the call. I am calling the API directly from a laptop on the same network.

On Wed, 11 Sept 2024, 7:26 pm Magnus, @.***> wrote:

-1 means "connection refused" so do you have a firewall that blocks the request ?

— Reply to this email directly, view it on GitHub https://github.com/mp-se/kegmon/issues/35#issuecomment-2343120803, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6EHQWZNT4IHUUN5ZBTA3TZWAED7AVCNFSM6AAAAABN4FRBE6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBTGEZDAOBQGM . You are receiving this because you authored the thread.Message ID: @.***>

wookienow commented 6 days ago

Happy to share my API key as well to see if you get the same error as I can always recreate.

mp-se commented 6 days ago

Can you see what the output from the serial log is? That should give some more details

mp-se commented 6 days ago

Are you using an esp8266 or esp32? Ssl could cause issues on the esp8266 due to lack of memory

wookienow commented 6 days ago

Logs appear to be getting cut off but this is what is shown (2 examples below)

953097 I: HA : Sending POUR information to HA, pour 0.52l [0]. 953101 I: TPL : Buffer needed 390. 953217 I: LVL : Logging level change 953245 I: TPL : Buffer needed 507. 953339 I: PUSH: MQTT publish success 953397 I: HA : Sending TAP informat 953442 I: PUSH: Sending values to mq 953521 I: BARH: Sending TAP informat 953663 I: PUSH: Adding header 'Content-Type': 'application/json' 953664 I: PUSH: Adding header 'Autho 953694 E: PUSH: HTTP post failed, re 955078 I: LOOP: Reading data raw1=0.47,raw2=0.00,stable1=0.46, stable2=0.00,pour1=0.52,pour2=nan


`53097 I: HA  : Sending POUR information to HA, pour 0.52l [0].
    953101 I: TPL : Buffer needed 390.
    953217 I: LVL : Logging level change    953245 I: TPL : Buffer needed 507.
    953339 I: PUSH: MQTT publish success    953397 I: HA  : Sending TAP informat    953442 I: PUSH: Sending values to mq    953521 I: BARH: Sending TAP informat    953663 I: PUSH: Adding header 'Content-Type': 'application/json'
    953664 I: PUSH: Adding header 'Autho    953694 E: PUSH: HTTP post failed, re    955078 I: LOOP: Reading data raw1=0.47,raw2=0.00,stable1=0.46, stable2=0.00,pour1=0.52,pour2=nan
wookienow commented 6 days ago

Wemos D1 Mini 8266

On Wed, 11 Sept 2024, 7:58 pm Magnus, @.***> wrote:

Are you using an esp8266 or esp32? Ssl could cause issues on the esp8266 due to lack of memory

— Reply to this email directly, view it on GitHub https://github.com/mp-se/kegmon/issues/35#issuecomment-2343187199, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6EHQXG6QEOZJPGFMIYZILZWAH4LAVCNFSM6AAAAABN4FRBE6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBTGE4DOMJZHE . You are receiving this because you authored the thread.Message ID: @.***>

mp-se commented 6 days ago

Can you check how much free memory you have on the dashboard ?

wookienow commented 6 days ago

Memory Free: 10 kb, Total: 80 kb

mp-se commented 6 days ago

Then its a memory problem. SSL requires 22kb free memory to work. You need an esp32s3 or esp32s2 mini for that to work

wookienow commented 6 days ago

Thanks, I have 1 floating around will change it over and check but will be tomorrow. Do you think there would be anything I could remove from the codebase to free up memory so I don't have to replace it in all my scales?

On Wed, 11 Sept 2024, 8:44 pm Magnus, @.***> wrote:

Then its a memory problem. SSL requires 22kb free memory to work. You need an esp32s3 or esp32s2 mini for that to work

— Reply to this email directly, view it on GitHub https://github.com/mp-se/kegmon/issues/35#issuecomment-2343288572, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6EHQUK2QCRHZP626WNRRDZWANIHAVCNFSM6AAAAABN4FRBE6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBTGI4DQNJXGI . You are receiving this because you authored the thread.Message ID: @.***>

mp-se commented 6 days ago

You can try to run it without having any interaction with the UI that would help. The webserver and the api communication will consume quite a lot of memory. You can check the memory usage by accessing the http://deviceid/api/status that will give the raw json data. If that has more than 22kb memory free than it should work to update via ssl.

mp-se commented 6 days ago

On my other projects I only allow for SSL when the webserver is not used so that there is enough memory to run, even without that there is typically only 25k memory available once the code is loaded.... but remove the webserver would make it difficult to manage the configuration....

mp-se commented 6 days ago

I just tested to call the API without SSL and that worked. I could change the code so on esp8266 it does not use SSL when calling barhelper, that could fix the problem. Not sure how long they will allow that....

wookienow commented 6 days ago

I am willing to give it a go. Not using the web access didn't free up any memory. Not sure if it loads even if it isn't being accessed.

mp-se commented 6 days ago

I will do the change after work and let you know when there is a new build to test

mp-se commented 6 days ago

You can test the new build in the dev branch. seams to work on esp8266 without ssl. I will see if I can reduce the memory footprint on the esp8266 and remove some of the features that is not essential

wookienow commented 5 days ago

Tested this morning before work and seems to work now. Looks like you nailed the reason why. Will do some more testing tonight but thanks for all the effort and the quick response.

On Thu, 12 Sept 2024, 12:38 am Magnus, @.***> wrote:

You can test the new build in the dev branch. seams to work on esp8266 without ssl. I will see if I can reduce the memory footprint on the esp8266 and remove some of the features that is not essential

— Reply to this email directly, view it on GitHub https://github.com/mp-se/kegmon/issues/35#issuecomment-2343868373, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD6EHQUY4JIRSPFYQJUXLMLZWBIVLAVCNFSM6AAAAABN4FRBE6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBTHA3DQMZXGM . You are receiving this because you authored the thread.Message ID: @.***>

wookienow commented 4 days ago

This works really well and data now flowing through. Would be great if in the future it supported SSL as well but understand the mem requirements. I found one other minor issue when configuring and have another enhancement request I will log these seprately.