I am aware this is quite an old thread but I had the exact same issue. The total usage variables showed up as unknown for some reason, I checked the scripts and the values were correct. I created a work-around it by creating two bash scripts, one for tariff 1 and one for tariff 2. It grabs the values from the smartmeter which in my case was attached to /dev/ttyUSB1, my code for tariff-1 started with 1-0:1.8.1, but this can be any value to filter out the right data you want. The command head looks for the first five values, otherwise it keeps going on and on.
kwh1=$(head -5 /dev/ttyUSB1 | sed '/1-0:1.8.1(/!d;s//&\n/;s/.\n//;:a;//bb;$!{n;ba};:b;s//\n$/;P;D’)
curl --silent -X PATCH --header “Content-Type:application/json” --user “#####:#####” --data ‘{“type”: “value”, “valueOrExpression”: "’"$kwh1"’"}’ http://localhost/api/variables/tariff-1 > /dev/null
kwh2=$(head -5 /dev/ttyUSB1 | sed '/1-0:1.8.2(/!d;s//&\n/;s/.\n//;:a;//bb;$!{n;ba};:b;s//\n$/;P;D’)
curl --silent -X PATCH --header “Content-Type:application/json” --user “#####:#####” --data ‘{“type”: “value”, “valueOrExpression”: "’"$kwh2"’"}’ http://localhost/api/variables/tariff-2 > /dev/null
I created two VariablesDevices to show this on the interface.
Just create some rules who execute those scripts every five / ten minutes or so.