Encode device metadata as json and then stringify it.
Add x-axis interval and y-axis unit.
wip on passing unit
Tidy up.