This page describes basically what I'm planning to do for the gas meter:
...which gives a strong pulse every 10dm3 of gas consumed (and nine weaker ones for the in-between digits).
The method is not too dissimilar for the electric meter (which has a flashing LED for every 1Wh consumed).
I might use an Arduino instead of RPi (if I can get logging to SD card working easily) because it offers analogue inputs so I can easily add e.g. temperature sensors later, and maybe do all the optical sensing in software instead of needing a couple of opamps. This page looks useful: