Local Zevvle web app

Thought I’d share a little thing I’ve made using the Zevvle API.

Despite being here and loving Zevvle, I’m not actually a big fan of app-based services, and try to keep closed-source apps off of my devices altogether.

I therefore threw together a Rails application that I can use to check my balance and recent usage from my laptop.



4 Likes

OMG. I freaking love it :heart_eyes:

Ultimately we do want a web app, but would tie it all into 1; a cross-platform monolith. We’re quite far down the native rabbit hole at the moment, so timeframe is TBD…

3 Likes

I was pleasantly surprised to find that this was still working when I ran it today. :smiley:

Although:

  • I realised that there are only a few pieces of information I’m regularly interested in
  • a Rails app with almost 200 dependencies just to display the results of some API calls is a bit much

So I wrote a shell script that’s useful for my most common use case - casually wondering what my recent usage has been like.

Bonus feature: I actually use it since it’s always at my finger tips :dizzy:

I present: shevvle.sh

$ shevvle
Texts   : 22 this month, 21 last month
Calls   : 17 this month, 15 last month
Data    : 439 MiB this month, 45 MiB last month
Balance : £7.08
4 Likes

That’s including sub-dependants, right? A clean install has 191 :scream:

:eyes: I love it!

Screenshot 2020-10-06 at 23.40.44

Can we tweet about it? :stuck_out_tongue_winking_eye:

When we re-do the usage summaries soon, we’ll open up the API we use for it so that could be useful… (enter 2 dates and we’ll give the summary between them.)

3 Likes

Yes! :sweat_smile:

Sure. Here’s a version that doesn’t look for an env file and fixes a silly bug: shevvle

That API endpoint does sound useful. ^^ At the moment the script only counts the first 100 call records it finds for each type so it can miscount - especially when it comes to data usage.

1 Like
➜  code bash shevvle.sh
Texts   :  0 this month,  6 last month
Calls   :  1 this month, 19 last month
Data    : 83 MiB this month, 101 MiB last month
Balance : £6.67

This doesn’t tally with my summary in the Zevvle app. e.g. for last month September I’ve got data: 3.19GB, Voice 32m 25 s and SMS 6
The last week is showing data: 96.7MB, voice: 1m 51s, SMS: 0
This month (I’ve got a frequent issue where this just shows the spinner): Data 87.2 MB, 49s, and SM: 0.

Are the calls number of calls rather than duration? Being on PAYG bundles, the total call/SMS charges would be an interesting metric to have. e.g. would I be better shifting to unlimited calls/texts?

Could the this month data difference be due to the difference be the 1000 vs 1024 calculation?

Increasing the number of records hasn’t increased the data for last month. I’m thinking it’s the switch from PAYG to Bundles which is tripping up the duration, as on the PAYG there’s a second nested duration in the tiers section e.g.:

    "tiers": {
      "3": {
        "charge": "0.000224",
        "duration": 2240,
        "description": null
      }
    }

I’m not convinced that’s the issue though as both durations are the same.

1 Like

Yes, and that would be useful. :slight_smile: Personally I’m more interested in number of calls at the moment.

The API only returns at most the first 100 records. (@nick, maybe add a way to choose the page when paging? :wink:) The only work around I could think of would be to ask for smaller periods of time instead of the whole month at once, but that adds quite a lot of complexity and the numbers have been close enough for me. They’re way off for you though!

1 Like

It has cursor-based offset, so you can either pass a record ID or timestamp for before/after that time or record! :smiley:

The total summaries we do should hopefully fix the above issues with missing records and less pagination faff.

2 Likes

This patch will give you total minutes used instead of number of calls.

minutes.patch
diff --git a/shevvle b/shevvle
index 41f4004..6baf6b7 100755
--- a/shevvle
+++ b/shevvle
@@ -30,7 +30,11 @@ sms_between () {
 }
 
 voice_between () {
-	call_records "-d type=voice -d after=$1 -d before=$2" | jq '.|length'
+	call_records "-d type=voice -d after=$1 -d before=$2" |
+		jq '.[].duration' |
+		paste -s -d '+' - |
+		xargs printf "(%s)/60\n" |
+		bc -l
 }
 
 _data_between () {
@@ -58,7 +62,7 @@ fi
 printf "Texts   : %2d this month, %2d last month\n" \
 	"$(sms_between "$start_of_this_month" "$now")" \
 	"$(sms_between "$start_of_last_month" "$start_of_this_month")"
-printf "Calls   : %2d this month, %2d last month\n" \
+printf "Calls   : %2.1f mins this month, %2.1f mins last month\n" \
 	"$(voice_between "$start_of_this_month" "$now")" \
 	"$(voice_between "$start_of_last_month" "$start_of_this_month")"
 printf "Data    : %.0f MiB this month, %.0f MiB last month\n" \
1 Like

For your usage this month, yes. The Zevvle app gives you MB while my script gives you MiB.

The massive disparity in your September data is I assume the 100 records thing.

Thank you! I’ve updated the script to fetch all data records using this. Do you get more accurate results with this one, @smsm1?

1 Like

Good to know. I think Zevvle switched to charging point of 1000 <-> 1024 at one point. So might be good to align with the charging divisor.

Agree on it being the 100 records issue.

I’m now getting

Data    : 83 MiB this month, 3050 MiB last month

which matches what the app shows baring the 1000 vs 1024 difference.

Also if you get a 401 error, might want to stop the script, e.g. when the variables for the account details are the default.

1 Like

When are you getting 401 errors?? :thinking:

1 Like

Run the script as downloaded, so the variables for the user account are not set thus a valid case for a 401, that the script doesn’t deal with. There’s a point that it also gets into an infinite loop due to this when long through the pages.

Will keep an eye out for this; haven’t been able to reproduce it…^^

Error checking is for products, personal projects enjoy undefined behaviour :stuck_out_tongue_winking_eye:

2 Likes

This is what happened until I stopped it:

➜  code bash shevvle2.sh
curl: (22) The requested URL returned error: 401
curl: (22) The requested URL returned error: 401
Texts   :  0 this month,  0 last month
curl: (22) The requested URL returned error: 401
curl: (22) The requested URL returned error: 401
Calls   :  0 this month,  0 last month
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
curl: (22) The requested URL returned error: 401
shevvle2.sh: line 41: [: : integer expression expected
^C
1 Like