Newer
Older
smart-home-server / webclient-vue / src / api / mappers.js
@Eugene Sukhodolskiy Eugene Sukhodolskiy 7 hours ago 446 bytes Scaffold Vue web client
const deviceFieldMap = {
  device_name: "name",
  device_hard_id: "device_id",
  device_ip: "ip",
  device_type: "type",
  ip_address: "ip",
  mac_address: "mac",
  device_mac: "mac",
  core_version: "firmware_core_version",
};

export function unifyDeviceFields(device) {
  const normalized = {};

  for (const [field, value] of Object.entries(device || {})) {
    normalized[deviceFieldMap[field] || field] = value;
  }

  return normalized;
}