toJson method

Map<String, Object?> toJson()

Encodes to JSON (absent members omitted, extra merged back).

Implementation

Map<String, Object?> toJson() => jsonMerge({
  'online': online,
  if (power case final v?) 'power': v.value,
  if (shutter case final v?) 'shutter': v.value,
  'signal': ?signal,
  'temperatureC': ?temperatureC,
  if (pattern case final v?) 'pattern': v.toJson(),
  'lastSeen': ?lastSeen,
  if (capabilities case final v?)
    'capabilities': [for (final e in v) e.value],
  if (faults case final v?) 'faults': [for (final e in v) e.toJson()],
}, extra);