(view source code of youless.bat as plain text)
@ECHO OFF
IF NOT "%~1"=="" GOTO Syntax
SETLOCAL ENABLEDELAYEDEXPANSION
:: Get Youless IP address
FOR /F "tokens=2 delims=[]" %%A IN ('PING.EXE youless -n 1 -w 100') DO SET IPAddress=%%A
:: Get device data
FOR /F "tokens=1 delims={}[]" %%A IN ('WGET.EXE -q -O - http://youless/d') DO (SET DeviceData=%%A)
:: Get actual logging values
FOR /F "tokens=1 delims={}[]" %%A IN ('WGET.EXE -q -O - http://youless/e') DO (SET AllValues=%%A)
:: Store collected values in environment variables
SET RemainingValues=%DeviceData%,%AllValues%
:Loop
FOR /F "tokens=1* delims=," %%A IN ("!RemainingValues!") DO (
FOR /F "tokens=1* delims=:" %%C IN ('ECHO %%A') DO (
SET Values.%%~C=%%~D
REM Format date and time to make it more readable
IF "%%~C"=="gts" (
SET Values.%%~C=20!Values.%%~C:~0,2!-!Values.%%~C:~2,2!-!Values.%%~C:~4,2! !Values.%%~C:~6,2!:!Values.%%~C:~8,2!
)
REM make uppercase and replace colons by dashes
IF "%%~C"=="mac" (
SET Values.%%~C=!Values.%%~C::=-!
SET Values.%%~C=!Values.%%~C:a=A!
SET Values.%%~C=!Values.%%~C:b=B!
SET Values.%%~C=!Values.%%~C:c=C!
SET Values.%%~C=!Values.%%~C:d=D!
SET Values.%%~C=!Values.%%~C:e=E!
SET Values.%%~C=!Values.%%~C:f=F!
)
REM Remove leading spaces
FOR /F "tokens=*" %%E IN ("!Values.%%~C!") DO SET Values.%%~C=%%E
)
IF "%%~B"=="" GOTO EndLoop
SET RemainingValues=%%B
GOTO Loop
)
:EndLoop
ECHO.
ECHO Youless model : %Values.model%
ECHO Youless firmware : %Values.fw%
ECHO Youless MAC adres : %Values.mac%
ECHO Youless IP adres : %IPAddress%
ECHO.
ECHO Tijdstip : %Values.gts%
ECHO.
ECHO Vermogen : %Values.pwr% W
ECHO P1 afname hoog tarief : %Values.p1% kWh
ECHO P1 afname laag tarief : %Values.p2% kWh
ECHO P1 teruglevering hoog tarief : %Values.n1% kWh
ECHO P1 teruglevering laag tarief : %Values.n2% kWh
ECHO Netto totaal verbruik : %Values.net% kWh
ECHO.
ECHO Gas verbruik : %Values.gas% m3
ECHO.
ENDLOCAL
EXIT /B 0
:Syntax
ECHO.
ECHO Youless.bat, Version 1.00
ECHO Read data from a Youless LS120 energy monitor device
ECHO.
ECHO Usage: Youless.exe
ECHO.
ECHO Notes: This program requires wget.exe, available at:
ECHO https://gnuwin32.sourceforge.net/packages/wget.htm
ECHO Return code ("ErrorLevel") equals 1 in case of
ECHO (command line) errors, otherwise 0.
ECHO.
ECHO Written by Rob van der Woude
ECHO https://www.robvanderwoude.com
EXIT /B 1
page last modified: 2024-04-16; loaded in 0.0061 seconds