Tracking trains and mobile bills

Posted on
Wed Jan 28, 2015 11:46 am
Chameleon offline
Posts: 611
Joined: Oct 04, 2014

Tracking trains and mobile bills

With a family of two girls and a boy who are constantly overrunning their mobile phone allowances I've been keen to find someway to track what's happening and catch overfilling before it costs me 100s of pounds (as my oldest did on one occasion watching films online!

It seemed like a good time to start to learn python and this was a good opportunity. Indigo schedules an analysis and downloads the latest mobile phone costs automatically from my account, checks to see if there is any overspend and emails my wife and I if there's a problem. It also flashes a warning on my control pages and announces if there's a problem. It's working really well and shows how complex triggers can be developed in python and integrated into the system.

Flush with this success I've also written plugins to trawl my local train provider (South West) and provide an update every 15 mins on train arrivals & departures. Like the mobile app it flashes a warning of any problems and, if it's within the times that I catch the train in the morning, flashes lights and announces the problem over the speakers.

Great system and the python language is great and easy to learn.

Mike :)

Posted on
Wed Jan 28, 2015 11:54 am
kw123 offline
User avatar
Posts: 8374
Joined: May 12, 2013
Location: Dallas, TX

Re: Tracking trains and mobile bills

could you share your code (without userid's and passwords)?

Posted on
Wed Jan 28, 2015 12:17 pm
Shutter offline
Posts: 345
Joined: Mar 07, 2014
Location: London, UK

Re: Tracking trains and mobile bills

Chameleon wrote:

Flush with this success I've also written plugins to trawl my local train provider (South West) and provide an update every 15 mins on train arrivals & departures. Like the mobile app it flashes a warning of any problems and, if it's within the times that I catch the train in the morning, flashes lights and announces the problem over the speakers.

Mike :)


Oh my, how we would love something similar for Thameslink. Our journey since Friday has been a mess - 2 hours to get home this evening when it normally is only about 40mins. It's got to the point now that the first thing we do in the morning after turning off the wakeup alarm is check the train app on our phones. That and follow their Twitter feed for updates throughout the day.

I wish it was possible to pull external content into the control page without plugins - that would go some way for non-coders, such as myself, to integrate external date sources.

Anyway, great idea. If you ever decide to turn it into a plugin that would be fab. :wink:

Posted on
Wed Jan 28, 2015 6:12 pm
jay (support) offline
Site Admin
User avatar
Posts: 18246
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Tracking trains and mobile bills

Chameleon wrote:
Great system and the python language is great and easy to learn.


Thanks - we picked Python because it's so pervasive and pretty simple to learn.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jan 29, 2015 9:50 am
Chameleon offline
Posts: 611
Joined: Oct 04, 2014

Re: Tracking trains and mobile bills

I'll share the code - let me just tidy it up a bit first :oops:

Actually I've been thinking of creating a plugin as a project. I think that this could be something to experiment with - I guess the train one would be easiest to work on first because it doesn't use password protection. I'm thinking of using beautiful soup and mechanize to do it.

If you need a solution that doesn't require any coding I used Apple Automator originally to pull up the web page for SouthWest trains, saved the page as a text file and then parsed the page to extract the information. It was a good exercise to learn Applescript and it was my first programme on a Mac. I'll share the code I finally came up with for that as well.

Mike

Posted on
Sat Feb 21, 2015 4:16 pm
Chockymonster offline
Posts: 84
Joined: Jul 19, 2014
Location: Sandhurst, UK

Re: Tracking trains and mobile bills

Having something similar for FGW would be so useful. Not that trains in to Reading are ever delayed!

Posted on
Thu Mar 05, 2015 4:31 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Tracking trains and mobile bills

But I think the train company shall provide an interface/API in order to download data, right?

Posted on
Fri Mar 13, 2015 12:58 pm
Chameleon offline
Posts: 611
Joined: Oct 04, 2014

Re: Tracking trains and mobile bills

It would be a lot easier if they did but python's fairly good for scraping web page information to get what you want and I've created a version that doesn't use Automator now and it's a lot more reliable

Posted on
Wed Mar 18, 2015 5:51 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Tracking trains and mobile bills

Thanks.

It would be nice also for flights info, but all the API are not freeware :(

Posted on
Wed Mar 18, 2015 5:19 pm
berkinet offline
User avatar
Posts: 3297
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Tracking trains and mobile bills

Just a thought here... But, have you considered delving a bit more into OS X so you can run applications, like those being discussed here, from the system scheduler, the "cron." (Crontab). This long time feature in *nix OSes can schedule events from the minute to the month and does not add any additional load, or configuration complexity, to Indigo.

Not a big deal in any case, but knowing more about the platform can often help you increase efficiency and expand your options. Like, using Ptpython 2.7 or later.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests