{"id":21585182,"url":"https://github.com/conectric/node-gateway","last_synced_at":"2025-04-10T20:07:17.189Z","repository":{"id":42982744,"uuid":"215930975","full_name":"Conectric/node-gateway","owner":"Conectric","description":"Generic Sensor and RS485 EKM Meter Gateway","archived":false,"fork":false,"pushed_at":"2022-12-10T05:58:37.000Z","size":132,"stargazers_count":2,"open_issues_count":6,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T17:52:38.979Z","etag":null,"topics":["conectric","iot","iot-platform","javascript","nodejs","rs485","rs485-comunication","sensors"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Conectric.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-18T03:06:53.000Z","updated_at":"2022-06-17T19:28:43.000Z","dependencies_parsed_at":"2023-01-25T21:55:12.860Z","dependency_job_id":null,"html_url":"https://github.com/Conectric/node-gateway","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Conectric%2Fnode-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Conectric%2Fnode-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Conectric%2Fnode-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Conectric%2Fnode-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Conectric","download_url":"https://codeload.github.com/Conectric/node-gateway/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248288345,"owners_count":21078903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conectric","iot","iot-platform","javascript","nodejs","rs485","rs485-comunication","sensors"],"created_at":"2024-11-24T15:09:19.898Z","updated_at":"2025-04-10T20:07:17.154Z","avatar_url":"https://github.com/Conectric.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Conectric Gateway for Node.js\n\nGateway code to receive sensor and EKM meter readings from the Conectric mesh network and forward it to a HTTP POST API and optionally to the Go-IoT BACNET service if configured on your gateway.\n\nMessage formats to send to the API, and the format of the API URL used are configured in a file called `clientimpl.js`, described in the \"Setup\" section.\n\n## Installation\n\nClone this repo then:\n\n```\ncd \u003cdirectory where repo was cloned to\u003e\nnpm install\n```\n\nNote that if you are upgrading from an older version of this software, you should run `rm -rf node_modules` before running `npm install`.  This ensures that you have all of the dependencies at their expected versions.\n\n## Setup\n\nPlug a Conectric USB router into an available USB port.\n\nEdit `config.json` to set the correct API base URL and other parameters.  Edit `meters.json` to include your EKM v3 and/or v4 meters.\n\nThen:\n\n```\n$ npm install\n$ npm start\n```\n\n## config.json\n\nContains configurable parameters.\n\n```\n{\n    \"http\": {\n        \"apiUrl\": \"\u003cAPI URL to post data to\u003e e.g. https://mydomain.com/api/endpoint\",\n        \"enabled\": true,\n        \"successCodes\": [ 200, 201, 202, 204 ]\n    },\n    \"go-iot\": {\n        \"enabled\": false\n    },\n    \"requestTimeout\": \u003cSeconds that a request for a chunk of meter data can run for before being considered timed out, min 1\u003e,\n    \"maxRetries\": \u003cNumber of times to retry a request for a chunk of meter data that timed out, min 0\u003e\n    \"readingInterval\": \u003cSeconds between successfully reading a meter and starting the next read, min 1\u003e,\n    \"useMillisecondTimestamps\": \u003ctrue to use millisecond precision timestamps, false for second precision\u003e,\n    \"useFahrenheitTemps\": \u003ctrue for Fahrenheit temperature data, false for Celsius\u003e,\n    \"sendStatusMessages\": \u003ctrue to enable sensor status message processing, false to disable\u003e,\n    \"sendEventCount\": \u003ctrue to send event count information, false to disable\u003e,\n    \"sendHopData\": \u003ctrue to send hop count data in messages, false to disable\u003e,\n    \"useHaystack\": \u003ctrue to use haystack format messages, false to disable\u003e\n}\n```\n\nYou may also add your own extra parameters to the config file.  These can then be referenced in your customized `clientimpl.js` file.\n\nFor `http`, `successCodes` is an array of HTTP status codes that should be considered success responses from the server.\n\nWhen `go-iot` is enabled, you **must** set `useHaystack` to `true`.  Failure to do this will result in the gateway logging an error message and quitting on startup.\n\n## meters.json\n\nContains an array of EKM v3 or v4 meters to be read, and information about which RS485 hub each meter is connected to.\n\n```\n{\n    \"meters\": [\n        {\n            \"serialNumber\": \"000300004299\",\n            \"rs485HubId\": \"0000\",\n            \"version\": 4,\n            \"password\": \"00000000\",\n            \"ctRatio\": 100\n        },\n        ...\n    ]\n}\n```\n\nThe values `password` and `ctRatio` are optional, and used by a separate configuration tool that sets the meter's CT ratio.  Values are as follows:\n\n* `password`: An eight digit number, default meter password is 00000000.\n* `ctRatio`: The CT ratio that should be set for the meter, values are between 100 and 5000.\n\nTo run this without any meters, use:\n\n```\n{\n    \"meters\": [\n    ]\n}\n```\n\n### clientimpl.js\n\nThis file exports functions that the gateway code requires you to provide implementations for:\n\n* `formatPayload` should perform any required transformations on the message payload that is to be sent to the API.  If `useHaystack` is `true`, then the message format passed into this function will be the haystack format.\n* `buildAPIUrl` should return the full URL of the API endpoint to post a message to.\n* `buildAPIHeaders` should return an object describing HTTP headers that will be used when posting a message to the URL generated by `buildAPIUrl`.  If none are required, return an empty object `{}`.\n* `getAPIVerb` should return the string `POST` or the string `PUT`.  This will be the HTTP verb used when calling the API.\n* `onMeterReadFail`, a callback function that is invoked whenever a meter reading attempt fails due to the meter not responding after retries.  This is passed the serial number of the affected meter.\n\nA stub implementation of each, with examples, is provided in the file `clientimpl_template.js`.  You should copy this to `clientimpl.js` and add your own specific code here.\n\nBoth `formatPayload` and `buildAPIUrl` have access to the moment library for date formatting. `buildApiURL` additionally has access to any values that you add to `config.json` so you should put API keys etc in here and reference them in your code using the `config` object. Similarly `buildAPIHeaders` also has access to both the `config` and message payload objects, allowing you to store API keys etc in `config.json` and set headers per message type as needed.\n\n## Sensor Message Formats\n\nWhen config parameter `useHaystack` is `false` the format of the messages you can expect to receive from each type of Conectric sensor is documented [here](https://www.npmjs.com/package/conectric-usb-gateway-beta), as part of the documentation for the mesh network to USB gateway.\n\nWhen config parameter `useHaystack` is `true`, message formats will look like the following examples.  In all cases:\n\n* `connection` will be `\"conectric\"`.\n* `networkRef` will be `\"conectric\"`.\n* `device1Ref` will be the gateway ID.\n* `device2Ref` will be `null`.\n* `id` will be the sensor ID.\n* `t` will be ISO-8601 formatted time of the message.\n\n### echoStatus\n\nNote: `battery` will always be `null` as devices are not running from batteries.\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"28b0\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"echoStatus\",\n  \"payload\": { \n    \"battery\": null, \n    \"eventCount\": 236 \n  },\n  \"sensorId\": \"28b0\",\n  \"sequenceNumber\": 229,\n  \"timestamp\": 1588648225536,\n  \"numHops\": 0,\n  \"maxHops\": 0,\n  \"t\": \"2020-05-05T03:10:25.536Z\"\n}\n\n```\n\n### moisture\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"3a4a\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"moisture\",\n  \"payload\": { \n    \"battery\": 3.1, \n    \"moisture\": false, \n    \"eventCount\": 1 \n  },\n  \"sensorId\": \"3a4a\",\n  \"sequenceNumber\": 2,\n  \"timestamp\": 1588451660099,\n  \"numHops\": 1,\n  \"maxHops\": 0,\n  \"t\": \"2020-05-02T20:34:20.099Z\"\n}\n```\n\n### moistureStatus\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"3a4a\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"moistureStatus\",\n  \"payload\": { \n    \"battery\": 3.1,\n    \"moisture\": false,\n    \"temp\": 80.2,\n    \"unit\": \"F\",\n    \"humidity\": 48.32,\n    \"eventCount\": 15 \n  },\n  \"sensorId\": \"3a4a\",\n  \"sequenceNumber\": 16,\n  \"timestamp\": 1588453043581,\n  \"numHops\": 1,\n  \"maxHops\": 0,\n  \"t\": \"2020-05-02T20:57:23.581Z\" \n}\n```\n\n### motion\n\n```\n{ \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"1701\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"motion\",\n  \"payload\": { \n    \"battery\": 3.3, \n    \"eventCount\": 121158, \n    \"occupancyIndicator\": true \n  },\n  \"sensorId\": \"1701\",\n  \"sequenceNumber\": 62,\n  \"timestamp\": 1588283168766,\n  \"numHops\": 2,\n  \"maxHops\": 0,\n  \"t\": \"2020-04-30T21:46:08.766Z\"\n}\n```\n\n### motionStatus\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"15e0\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"motionStatus\",\n  \"payload\": { \n    \"battery\": 3.2, \n    \"eventCount\": 56216, \n    \"occupancyIndicator\": false \n  },\n  \"sensorId\": \"15e0\",\n  \"sequenceNumber\": 169,\n  \"timestamp\": 1588647505086,\n  \"numHops\": 1,\n  \"maxHops\": 0,\n  \"t\": \"2020-05-05T02:58:25.086Z\" \n}\n```\n\nNote: `occupancyIndicator` will always be `false`.\n\n### pulse\n\n```\n{ \n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"connection\": \"conectric\",\n  \"device2Ref\": null,\n  \"id\": \"1413\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"pulse\",\n  \"payload\": { \n    \"battery\": 3.1, \n    \"pulse\": true, \n    \"eventCount\": 151 \n  },\n  \"sensorId\": \"1413\",\n  \"sequenceNumber\": 86,\n  \"timestamp\": 1588546855788,\n  \"numHops\": 0,\n  \"maxHops\": 0,\n  \"t\": \"2020-05-03T23:00:55.788Z\" \n}\n```\n\n### pulseStatus\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"dbad\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"pulseStatus\",\n  \"payload\": { \n    \"battery\": 3, \n    \"eventCount\": 0, \n    \"pulse\": false \n  },\n  \"sensorId\": \"dbad\",\n  \"sequenceNumber\": 122,\n  \"timestamp\": 1588647605806,\n  \"numHops\": 1,\n  \"maxHops\": 0,\n  \"t\": \"2020-05-05T03:00:05.806Z\" \n}\n```\n\nNote: `pulse` will always be `false`.\n\n### rs485Status\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"1d0c\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"rs485Status\",\n  \"payload\": { \n    \"battery\": null, \n    \"eventCount\": 922239 \n  },\n  \"sensorId\": \"1d0c\",\n  \"sequenceNumber\": 39,\n  \"timestamp\": 1588648178159,\n  \"numHops\": 2,\n  \"maxHops\": 0,\n  \"t\": \"2020-05-05T03:09:38.159Z\" \n}\n```\n\n### switch\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"3d94\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"switch\",\n  \"payload\": { \n    \"battery\": 3.3, \n    \"eventCount\": 152, \n    \"switch\": true \n  },\n  \"sensorId\": \"3d94\",\n  \"sequenceNumber\": 251,\n  \"timestamp\": 1588553778855,\n  \"numHops\": 3,\n  \"maxHops\": 0,\n  \"t\": \"2020-05-04T00:56:18.855Z\"\n}\n```\n\n### switchStatus\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"1413\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"switchStatus\",\n  \"payload\": { \n    \"battery\": 3, \n    \"eventCount\": 36, \n    \"switch\": false \n  },\n  \"sensorId\": \"1413\",\n  \"sequenceNumber\": 138,\n  \"timestamp\": 1588218274974,\n  \"numHops\": 0,\n  \"maxHops\": 0,\n  \"t\": \"2020-04-30T03:44:34.974Z\" \n}\n```\n\nNote: `switch` will indicate the current status of the switch.\n\n### tempHumidity\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"3457\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"tempHumidity\",\n  \"payload\":\n  { \n    \"eventCount\": 126407,\n    \"battery\": 2.8,\n    \"humidity\": 49.48,\n    \"temp\": 76.5,\n    \"unit\": \"F\" \n  },\n  \"sensorId\": \"3457\",\n  \"sequenceNumber\": 152,\n  \"timestamp\": 1588218027201,\n  \"numHops\": 0,\n  \"maxHops\": 0,\n  \"t\": \"2020-04-30T03:40:27.201Z\" \n}\n```\n\n### tempHumidityAdc\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"4443\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"tempHumidityAdc\",\n  \"payload\": { \n    \"battery\": 3,\n    \"eventCount\": 411318,\n    \"humidity\": 49.24,\n    \"adcIn\": \"008a\",\n    \"adcMax\": \"07ff\",\n    \"temp\": 74.12,\n    \"unit\": \"F\" \n  },\n  \"sensorId\": \"4443\",\n  \"sequenceNumber\": 171,\n  \"timestamp\": 1588218032173,\n  \"numHops\": 0,\n  \"maxHops\": 0,\n  \"t\": \"2020-04-30T03:40:32.173Z\"\n}\n```\n\n### tempHumidityLight\n\n```\n{ \n  \"connection\": \"conectric\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": null,\n  \"id\": \"15eb\",\n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"tempHumidityLight\",\n  \"payload\": { \n    \"battery\": 3,\n    \"eventCount\": 144848,\n    \"humidity\": 51.22,\n    \"bucketedLux\": 0,\n    \"temp\": 76.23,\n    \"unit\": \"F\",\n    \"lightLevel\": 19 \n  },\n  \"sensorId\": \"15eb\",\n  \"sequenceNumber\": 67,\n  \"timestamp\": 1588218063484,\n  \"numHops\": 0,\n  \"maxHops\": 0,\n  \"t\": \"2020-04-30T03:41:03.484Z\"\n}\n```\n\n## Meter Message Formats\n\nMessages received from meters are formatted as follows.  The fields:\n\n* `gatewayId`\n* `type`\n* `meterModel`\n* `timestamp`\n* `sensorId`\n* `sequenceNumber`\n\nare all as described [here](https://www.npmjs.com/package/conectric-usb-gateway-beta) as part of the documentation for the mesh network to USB gateway.\n\n### Formatting (Haystack Mode off)\n\nThe format for meter messages is dependent on the `useHaystack` configuration setting in `config.json`.  When this is set to `false`, the following message format will be generated.\n\nIn common with the sensor messages, meter messages contain a `payload` object with a common schema regardless of the type of smart meter hardware used.  An example message from an EKM v4 meter is shown below:\n\n```\n{ \n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"meter\",\n  \"meterModel\": \"ekm4\",\n  \"timestamp\": 1589326058877,\n  \"sensorId\": \"1d0c\",\n  \"sequenceNumber\": 76,\n  \"payload\": { \n    \"battery\": 3.2,\n    \"kwh_scale\": 2,\n    \"model\": \"4132\",\n    \"firmware\": 25,\n    \"meter_address\": \"000300002255\",\n    \"kwh_tot\": 6334.78,\n    \"reactive_energy_tot\": 1455.51,\n    \"rev_kwh_tot\": 0,\n    \"kwh_ln_1\": 3012.84,\n    \"kwh_ln_2\": 3321.08,\n    \"kwh_ln_3\": 0,\n    \"rev_kwh_ln_1\": 0,\n    \"rev_kwh_ln_2\": 0,\n    \"rev_kwh_ln_3\": 0,\n    \"resettable_kwh_tot\": 6334.78,\n    \"resettable_rev_kwh_tot\": 0,\n    \"rms_volts_ln_1\": 119.2,\n    \"rms_volts_ln_2\": 119.3,\n    \"rms_volts_ln_3\": 0,\n    \"amps_ln_1\": 2.6,\n    \"amps_ln_2\": 4.6,\n    \"amps_ln_3\": 0,\n    \"rms_watts_ln_1\": 198,\n    \"rms_watts_ln_2\": 510,\n    \"rms_watts_ln_3\": 0,\n    \"rms_watts_tot\": 708,\n    \"power_factor_ln_1\": \"C0.92\",\n    \"power_factor_ln_2\": \"C0.96\",\n    \"power_factor_ln_3\": \"C0.00\",\n    \"reactive_pwr_ln_1\": 86,\n    \"reactive_pwr_ln_2\": 146,\n    \"reactive_pwr_ln_3\": 0,\n    \"reactive_pwr_tot\": 232,\n    \"line_freq\": 59.99,\n    \"pulse_cnt_1\": 0,\n    \"pulse_cnt_2\": 1,\n    \"pulse_cnt_3\": 1,\n    \"state_inputs\": 0,\n    \"state_watts_dir\": 1,\n    \"state_out\": 1,\n    \"meter_time\": \"20051304072326\",\n    \"kwh_tariff_1\": 37946.6,\n    \"kwh_tariff_2\": 25401.3,\n    \"kwh_tariff_3\": 0,\n    \"kwh_tariff_4\": 0,\n    \"rev_kwh_tariff_1\": 0,\n    \"rev_kwh_tariff_2\": 0,\n    \"rev_kwh_tariff_3\": 0,\n    \"rev_kwh_tariff_4\": 0,\n    \"cos_theta_ln_1\": 0.92,\n    \"cos_theta_ln_2\": 0.96,\n    \"cos_theta_ln_3\": 0,\n    \"rms_watts_max_demand\": 4500,\n    \"max_demand_period\": 1,\n    \"pulse_ratio_1\": 1,\n    \"pulse_ratio_2\": 1,\n    \"pulse_ratio_3\": 1,\n    \"ct_ratio\": 200,\n    \"auto_reset_max_demand\": 0,\n    \"pulse_output_ratio\": 800 \n  } \n}\n```\n\n`timestamp` is the time that the gateway received the message.  `meter_time` is the time according to the meter when the message was generated.  `meter_time` is as received from the hardware and is formatted as follows:\n\n`YYMMDDXXHHMMSS`\n\n* `YY` = 2 digit year.\n* `MM` = month.\n* `DD` = day.\n* `XX` = day of week, 01 = Sunday, 02 = Tuesday ... 06 = Saturday.\n* `HH` = hour of day (24hr clock).\n* `MM` = minutes.\n* `SS` = seconds.\n\nEKM Omnimeter v3 and v4 meters are supported.  The `meterModel` field will be set to `ekm3` for the v3 Omnimeter, and `ekm4` for the v4.\n\nThe v3 Omnimeter does not have all of the features of the v4 and uses a slightly different schema.  Here's an example message from a v3 meter:\n\n```\n{ \n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"meter\",\n  \"meterModel\": \"ekm3\",\n  \"timestamp\": 1589235150812,\n  \"sensorId\": \"22fb\",\n  \"sequenceNumber\": 55,\n  \"payload\": { \n    \"battery\": 3.2,\n    \"model\": \"4130\",\n    \"firmware\": 23,\n    \"meter_address\": \"000010007076\",\n    \"kwh_tot\": 9583.7,\n    \"kwh_tariff_1\": 5931.3,\n    \"kwh_tariff_2\": 3652.4,\n    \"kwh_tariff_3\": 0,\n    \"kwh_tariff_4\": 0,\n    \"rev_kwh_tot\": 9499.3,\n    \"rev_kwh_tariff_1\": 5879,\n    \"rev_kwh_tariff_2\": 3620.3,\n    \"rev_kwh_tariff_3\": 0,\n    \"rev_kwh_tariff_4\": 0,\n    \"rms_volts_ln_1\": 118,\n    \"rms_volts_ln_2\": 0,\n    \"rms_volts_ln_3\": 0,\n    \"amps_ln_1\": 0.4,\n    \"amps_ln_2\": 0,\n    \"amps_ln_3\": 0,\n    \"rms_watts_ln_1\": 42,\n    \"rms_watts_ln_2\": 0,\n    \"rms_watts_ln_3\": 0,\n    \"rms_watts_tot\": 42,\n    \"cos_theta_ln_1\": 0.78,\n    \"cos_theta_ln_2\": 0,\n    \"cos_theta_ln_3\": 0,\n    \"max_demand\": 6635,\n    \"max_demand_period\": 1,\n    \"meter_time\": \"20051203061051\",\n    \"ct_ratio\": 200,\n    \"pulse_cnt_1\": 0,\n    \"pulse_cnt_2\": 0,\n    \"pulse_cnt_3\": 0,\n    \"pulse_ratio_1\": 0,\n    \"pulse_ratio_2\": 0,\n    \"pulse_ratio_3\": 0,\n    \"state_inputs\": 0 \n  } \n}\n```\n\n### Formatting (Haystack Mode on)\n\nWhen haystack mode is on (`useHaystack` in `config.json` set to `true`), messages will look like the following.  Note that `battery` will always be `null` (devices are powered from the meter, not a battery).\n\nEKM v4 Meter:\n\n```\n{ \n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"meter\",\n  \"meterModel\": \"ekm4\",\n  \"timestamp\": 1588391740085,\n  \"sensorId\": \"1d0c\",\n  \"sequenceNumber\": 249,\n  \"connection\": \"ekm\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": \"1d0c\",\n  \"equip\": \"elec_meter\",\n  \"t\": \"2020-05-02T11:51:29.000Z\",\n  \"id\": \"000300002255\",\n  \"payload\": { \n    \"battery\": null,\n    \"volt_A\": 119.7,\n    \"volt_B\": 119.6,\n    \"volt_C\": 0,\n    \"current_A\": 0.2,\n    \"current_B\": 3.8,\n    \"current_C\": 0,\n    \"power_A\": 0.006,\n    \"power_B\": 0.418,\n    \"power_C\": 0,\n    \"reactive_power_A\": 0.032,\n    \"reactive_power_B\": 0.12,\n    \"reactive_power_C\": 0,\n    \"pf_A\": 0.19,\n    \"pf_B\": 0.96,\n    \"pf_C\": 0,\n    \"power\": 0.424,\n    \"power_reactive\": 0.152,\n    \"state_current_dir\": 1,\n    \"freq\": 60.03,\n    \"power_max\": 4.5,\n    \"power_max_period\": 1,\n    \"power_max_auto_reset\": 0,\n    \"energy_A\": 3005.56,\n    \"energy_B\": 3204.98,\n    \"energy_C\": 0,\n    \"energy\": 6211.39,\n    \"power_reactive_h\": 1414.06,\n    \"energy_tariff_1\": 37217.8,\n    \"energy_tariff_2\": 24896.1,\n    \"energy_tariff_3\": 0,\n    \"energy_tariff_4\": 0,\n    \"energy_export_A\": 0,\n    \"energy_export_B\": 0,\n    \"energy_export_C\": 0,\n    \"energy_export\": 0,\n    \"energy_export_tariff_1\": 0,\n    \"energy_export_tariff_2\": 0,\n    \"energy_export_tariff_3\": 0,\n    \"energy_export_tariff_4\": 0,\n    \"energy_resettable\": 6211.39,\n    \"energy_export_resettable\": 0,\n    \"state_pulse_inputs\": 0,\n    \"state_out_cmd\": 1,\n    \"pulse_hisTotalized_1\": 0,\n    \"pulse_hisTotalized_2\": 1,\n    \"pulse_hisTotalized_3\": 1,\n    \"pulse_ratio_1\": 1,\n    \"pulse_ratio_2\": 1,\n    \"pulse_ratio_3\": 1,\n    \"pulse_output_ratio\": 800,\n    \"sensor_ct_ratio\": 200,\n    \"decimal\": 2,\n    \"meter_time\": \"2020-05-02T11:51:29.000Z\" \n  } \n}\n```\n\nEKM v3 Meter:\n\n```\n{ \n  \"gatewayId\": \"00124b00051422cd\",\n  \"type\": \"meter\",\n  \"meterModel\": \"ekm3\",\n  \"timestamp\": 1588218048516,\n  \"sensorId\": \"22fb\",\n  \"sequenceNumber\": 8,\n  \"connection\": \"ekm\",\n  \"networkRef\": \"conectric\",\n  \"device1Ref\": \"00124b00051422cd\",\n  \"device2Ref\": \"22fb\",\n  \"equip\": \"elec_meter\",\n  \"t\": \"2020-04-30T11:39:11.000Z\",\n  \"id\": \"000010007076\",\n  \"payload\": { \n    \"battery\": null,\n    \"volt_A\": 118.7,\n    \"volt_B\": 0,\n    \"volt_C\": 0,\n    \"current_A\": 0.4,\n    \"current_B\": 0,\n    \"current_C\": 0,\n    \"power_A\": 0.042,\n    \"power_B\": 0,\n    \"power_C\": 0,\n    \"reactive_power_A\": null,\n    \"reactive_power_B\": null,\n    \"reactive_power_C\": null,\n    \"pf_A\": 0.78,\n    \"pf_B\": 0,\n    \"pf_C\": 0,\n    \"power\": 0.042,\n    \"power_reactive\": null,\n    \"state_current_dir\": null,\n    \"freq\": null,\n    \"power_max\": 6.635,\n    \"power_max_period\": 1,\n    \"power_max_auto_reset\": null,\n    \"energy_A\": null,\n    \"energy_B\": null,\n    \"energy_C\": null,\n    \"energy\": 9571.7,\n    \"power_reactive_h\": null,\n    \"energy_tariff_1\": 5923.8,\n    \"energy_tariff_2\": 3647.9,\n    \"energy_tariff_3\": 0,\n    \"energy_tariff_4\": 0,\n    \"energy_export_A\": null,\n    \"energy_export_B\": null,\n    \"energy_export_C\": null,\n    \"energy_export\": 9499.3,\n    \"energy_export_tariff_1\": 5879,\n    \"energy_export_tariff_2\": 3620.3,\n    \"energy_export_tariff_3\": 0,\n    \"energy_export_tariff_4\": 0,\n    \"energy_resettable\": null,\n    \"energy_export_resettable\": null,\n    \"state_pulse_inputs\": 0,\n    \"state_out_cmd\": null,\n    \"pulse_hisTotalized_1\": 0,\n    \"pulse_hisTotalized_2\": 0,\n    \"pulse_hisTotalized_3\": 0,\n    \"pulse_ratio_1\": 0,\n    \"pulse_ratio_2\": 0,\n    \"pulse_ratio_3\": 0,\n    \"pulse_output_ratio\": null,\n    \"sensor_ct_ratio\": 200,\n    \"decimal\": null,\n    \"meter_time\": \"2020-04-30T11:39:11.000Z\" \n  } \n}\n```\n\nThe v3 Omnimeter does not support all of the fields in the meter payload schema, so you can expect the values of these fields to be null when using a v3 meter:\n\n* `reactive_power_A`\n* `reactive_power_B`\n* `reactive_power_C`\n* `power_reactive_h`\n* `freq`\n* `power_max_auto_reset`\n* `energy_A`\n* `energy_B`\n* `energy_C`\n* `energy_resettable`\n* `energy_export_resettable`\n* `state_out_cmd`\n* `pulse_output_ratio`\n* `decimal`\n\nIn Haystack mode, the units for each meter data field are as follows:\n\n| Key\t                        | Unit          |\n| --------------------------- | ------------- |\n| `battery`\t                  | V             | \n| `temp`\t                    | degrees (C/F) |\n| `humidity`\t                | %             |\n| `adcIn`\t                    | V             |\n| `adcMax`\t                  | V             |\n| `lightLevel`\t              | Lux           |\n| `eventCount`\t              | #             |\n| `volt`\t                    | V             |\n| `current` \t                | A             |\n| `power` (active)\t          | kW            |\n| `reactive_power`\t          | kVAR          |\n| `pf` (power factor)\t        | %             |\n| `frequency`                 |\tHz            |\n| `power_max`\t                | kW            |\n| `energy`\t                  | kWh           |\n| `power_reactive_h`\t        | kVARh         |\n| `energy_tarriff`\t          | kWh           |\n| `energy_export`\t            | kWh           |\n| `energy_export_tarriff`     |\tkWh           |\n| `energy_resettable`\t        | kWh           |\n| `energy_export_resettable`\t| kWh           |\n| `pulse_hisTotalized`\t      | #             |\n| `sensor_ct_ratio`           |\tA             |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconectric%2Fnode-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconectric%2Fnode-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconectric%2Fnode-gateway/lists"}