Upload gas usage to mindergas.nl  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Upload gas usage to mindergas.nl

Post by jvdz »

Are you running this as a DzEvents script?
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
mvveelen
Posts: 687
Joined: Friday 31 October 2014 10:22
Target OS: NAS (Synology & others)
Domoticz version: Beta
Location: Hoorn, The Netherlands
Contact:

Re: Upload gas usage to mindergas.nl

Post 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.
RPi3b+/RFXCOM rfxtrx433E/Shelly/Xiaomi Gateway/Philips HUE Lights/Atag Zone One/2 SunnyBoy inverters/AirconWithMe/P1 smartmeter/Domoticz latest Beta
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Upload gas usage to mindergas.nl

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Upper78
Posts: 5
Joined: Tuesday 28 March 2017 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10228
Contact:

Re: Upload gas usage to mindergas.nl

Post 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.
User avatar
sincze
Posts: 1300
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: Upload gas usage to mindergas.nl

Post 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
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Upload gas usage to mindergas.nl

Post 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
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
njlammerts
Posts: 145
Joined: Wednesday 12 August 2020 17:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Fryslan
Contact:

Re: Upload gas usage to mindergas.nl

Post 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?
HvdW
Posts: 600
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Upload gas usage to mindergas.nl

Post 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
Bugs bug me.
njlammerts
Posts: 145
Joined: Wednesday 12 August 2020 17:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Fryslan
Contact:

Re: Upload gas usage to mindergas.nl

Post 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?
njlammerts
Posts: 145
Joined: Wednesday 12 August 2020 17:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Fryslan
Contact:

Re: Upload gas usage to mindergas.nl

Post 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"
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Upload gas usage to mindergas.nl

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
njlammerts
Posts: 145
Joined: Wednesday 12 August 2020 17:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Fryslan
Contact:

Re: Upload gas usage to mindergas.nl

Post 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 !!!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest