On / off template sensor to decode patterns (blinking light means)

Is there any way to create a sensor that would givea value based on the pattern of on and off. We are putting in a new septic system and it has a pump controller that makes a light on it flash in certain patterns to give information on what the state / error is.
some of the patterns:

constant on           = state A
.     .     .         = state B
-     -     -         = state C
..    ..    ..        = state D
...    ...    ...     = state E
.--.    .--.    .--.  = state F