Page 3 of 3

Re: Upload gas usage to mindergas.nl

Posted: Sunday 07 August 2022 14:51
by jvdz
Are you running this as a DzEvents script?

Re: Upload gas usage to mindergas.nl

Posted: Tuesday 09 August 2022 20:36
by mvveelen
Yes, I tried. But saving scripts gives me a "save error" so I prefer to use a bash script.

I also tried the slave-master construction, but I keep getting errors because I use an RPi 3B+ and a Synology with Domoticz in Docker.

Re: Upload gas usage to mindergas.nl

Posted: Tuesday 09 August 2022 22:03
by jvdz
It is an DzEvents script as you can see in the scriptsource, so will not work in any other way!
/home/pi/domoticz/scripts/dzVents/scripts/upload_gas_usage_to_minderGas.lua

Re: Upload gas usage to mindergas.nl

Posted: Monday 17 October 2022 12:13
by Upper78
Hi mvveelen,

I just tested with your script, and the only thing that needs to be changed is the URL from mindergas.
This has changed. Change line 40 to https://www.mindergas.nl/api/meter_readings as the url, and it works.

Re: Upload gas usage to mindergas.nl

Posted: Saturday 29 April 2023 11:23
by sincze
As my experience with dZVents is 0,0 and the and the wiki described a version with special tools required in BASH I had to give it a small different BASH twist for 2 house holds that wanted to have this done.

Best Practices:
- No mindergas key in the main script but in separate config file.
- Needs no special tools or apt-get installs

Find the mindergas.sh here.
https://github.com/sincze/bash/blob/main/mindergas.sh

Re: Upload gas usage to mindergas.nl

Posted: Thursday 24 August 2023 12:41
by Derik
MM Hi..
Oud topic..
maar ik gebruikt eerst een ander script wat niet meer werkt na een nieuw armbian installatie.

Welk script werkt nu goed?
En uploaden jullie alleen gas? Of ook KWH/2 als zijnde gas, voor een wp verbruik [ de oude api ]
Nieuw is wel Kwh maar ik zoek eigen de /2 versie
En natuurlijk de kwh versie altijd welkom

Re: Upload gas usage to mindergas.nl

Posted: Monday 26 February 2024 12:16
by njlammerts
I used the script from Sándor Incze because this seems to be the latest (2023) script for uploaden to Mindergas.nl. The older scripts give an arror "meterstand is geen getal"

The script from Sándor runs ok, but i get ( a simular message) "Error no value!" as result.

Does anyone has a solution?

Re: Upload gas usage to mindergas.nl

Posted: Friday 14 June 2024 14:28
by HvdW
Here is a script that should work.
jq is the ingredient that you need.

Code: Select all

#!/bin/bash

# LET OP
# METERSTAND check your domoticz port and domoticz idx (rid) for gas
# check your mindergas token
# LET OP

#Token to authenicate with mindergas.nl
TOKEN=your token

#fetch meterstand (use jq to parse JSON object correctly)
METERSTAND=`curl -s "http://127.0.0.1:8383/json.htm?type=devices&rid=16" | jq '.result[0].Counter'| tr -d '"'`

#Get OS date, and format it corectly.
NOW=$(date +"%Y-%m-%d")

#Build JSON by hand 😉
JSON='{ "date":"'$NOW'", "reading":"'$METERSTAND'" }'

#post using curl to API
curl -v -H "Content-Type:application/json" -H "AUTH-TOKEN:$TOKEN" -d "$JSON" https://www.mindergas.nl/api/meter_readings

# don't forget:
# https://ehoco.nl/stand-gasmeter-uploaden-naar-mindergas-nl/
# sudo apt install jq -y
and in crontab for a daily upload.

Code: Select all

58 23 * * * /home/pi/scripts/mindergas-upload.sh

Re: Upload gas usage to mindergas.nl

Posted: Tuesday 13 May 2025 10:59
by njlammerts
After the update to Domoticz 2025.05 the update to mindergas does not work anymore
when running the mindergas.sh manually I get " Error no value!"

Does anyone know what could be the reason?

Re: Upload gas usage to mindergas.nl

Posted: Tuesday 13 May 2025 14:17
by njlammerts
njlammerts wrote: Tuesday 13 May 2025 10:59 After the update to Domoticz 2025.05 the update to mindergas does not work anymore
when running the mindergas.sh manually I get " Error no value!"

Does anyone know what could be the reason? it has been running for 1.5 year without a problem

mindergas.sh:

# Config file in here
# -------------------
source /home/pi/domoticz/scripts/system/config
# -------------------

#Token to authenicate with mindergas.nl
TOKEN=$MINDERGAS_API
IDX=$GAS_IDX

#fetch meterstand

METERSTAND=`curl -s --connect-timeout 2 --max-time 5 "Accept: application/json" "http://$DOMOTICZ_IP:$DOMOTICZ_PORT/json.htm?type=devices&rid=$IDX" | /bin/grep '"Co$

if [ $METERSTAND ] ; then
# echo $METERSTAND

#Get OS date, and format it corectly.
NOW=$(date +"%Y-%m-%d")
# NOW=$(date --date="yesterday" +"%Y-%m-%d")

#Build JSON by hand ;-)
JSON='{ "date":"'$NOW'", "reading":"'$METERSTAND'" }'

#post using curl to API
curl -v -H "Content-Type:application/json" -H "AUTH-TOKEN:$TOKEN" -d "$JSON" https://www.mindergas.nl/api/meter_readings
exit
else
echo "Error no value!"
fi



Config file:

# CONFIG FILE that will be used in BASH scripts
# Is placed in DIR_SCRIPTS directory
DEBUG="true"
DIR_TEMP="/var/tmp"
DIR_LOG="/var/log"
DIR_SCRIPTS="/home/pi/domoticz/scripts/system"
DOMOTICZ_IP="172.16.10.248"
DOMOTICZ_PORT="8080"

MINDERGAS_API="blabla12345"
GAS_IDX="694"

Re: Upload gas usage to mindergas.nl

Posted: Tuesday 13 May 2025 16:04
by jvdz
This line is wrong: type=devices&rid=$IDX" | /bin/grep '"Co$
That needs to follow the new API structure:type=command&param=getdevices&rid=$IDX" | /bin/grep '"Co$

See: https://wiki.domoticz.com/Domoticz_API/ ... fic_device

Re: Upload gas usage to mindergas.nl

Posted: Tuesday 13 May 2025 18:28
by njlammerts
The line which was copied, was not complete (my mistake) . It is:

METERSTAND=`curl -s --connect-timeout 2 --max-time 5 "Accept: application/json" "http://$DOMOTICZ_IP:$DOMOTICZ_PORT/json.htm?type=command&param=getdevices&rid=$IDX" | /bin/grep '"Counter" :' | awk {'print $3'} | /usr/bin/cut -d '"' -f 2`

But the reply from jvdz was good enough for me to change the line, and it seems to work when I execute manually..

Big Thanks !!!