@classmethod
def from_json(cls, data):
    """Create an instance given JSON data as a dict"""
    template = cls()
    attrs = {'name': data.get('n', template.name), 'time': data.get('t',
        template.time), 'unit': data.get('u', template.unit), 'value': data
        .get('v', template.value), 'sum': data.get('s', template.sum)}
    if attrs['value'] is None:
        if 'vs' in data:
            attrs['value'] = str(data['vs'])
        elif 'vb' in data:
            if str(data['vb']).casefold() == 'false'.casefold() or str(data
                ['vb']).casefold() == '0'.casefold():
                attrs['value'] = False
            else:
                attrs['value'] = True
        elif 'vd' in data:
            attrs['value'] = bytes(data['vd'])
    return cls(**attrs)
