From 90352839cea63b181469df4720c06b7331d5481f Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Fri, 22 Dec 2023 11:16:25 -0500 Subject: [PATCH] feature: add humidity (130313) and pressure pressure (#88) closes #87 --- conversions/humidity.js | 61 +++++++++++++++++++++++++++++++++++++++++ conversions/pressure.js | 37 +++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 conversions/humidity.js create mode 100644 conversions/pressure.js diff --git a/conversions/humidity.js b/conversions/humidity.js new file mode 100644 index 0000000..cef4447 --- /dev/null +++ b/conversions/humidity.js @@ -0,0 +1,61 @@ + +module.exports = (app, plugin) => { + return [{ + pgn: 130313, + title: 'Outside Humidity (PGN130313)', + optionKey: 'HUMIDITY_OUTSIDE', + keys: [ + "environment.outside.relativeHumidity" + ], + callback: (humidity) => { + return [{ + pgn: 130313, + "Instance": 100, + "Source": "Outside", + "Actual Humidity": humidity, + }] + }, + tests: [{ + input: [ .50 ], + expected: [{ + "prio": 2, + "pgn": 130313, + "dst": 255, + "fields": { + "Instance": 100, + "Source": "Outside", + "Actual Humidity": .50 + } + }] + }] + }, { + pgn: 130313, + title: 'Inside Humidity (PGN130313)', + optionKey: 'HUMIDITY_INSIDE', + keys: [ + "environment.inside.relativeHumidity" + ], + callback: (humidity) => { + return [{ + pgn: 130313, + "Instance": 100, + "Source": "Inside", + "Actual Humidity": humidity, + }] + }, + tests: [{ + input: [ 1.0 ], + expected: [{ + "prio": 2, + "pgn": 130313, + "dst": 255, + "fields": { + "Instance": 100, + "Source": "Inside", + "Actual Humidity": 1.0 + } + }] + }] + }] +} + diff --git a/conversions/pressure.js b/conversions/pressure.js new file mode 100644 index 0000000..fcfa77e --- /dev/null +++ b/conversions/pressure.js @@ -0,0 +1,37 @@ + + +let pressMessage = (pres, src) => { + return [{ + pgn: 130314, + "Instance": 100, + "Source": src, + "Pressure": pres, + }] +} + +module.exports = (app, plugin) => { + return [{ + pgn: 130314, + title: 'Atmospheric Pressure (130314)', + optionKey: 'PRESSURE_ATMOSPHERIC', + keys: [ + "environment.outside.pressure" + ], + callback: (pressure) => { + return pressMessage(pressure, 'Atmospheric') + }, + tests: [{ + input: [ 103047.8 ], + expected: [{ + "prio": 2, + "pgn": 130314, + "dst": 255, + "fields": { + "Instance": 100, + "Source": "Atmospheric", + "Pressure": 103047.8 + } + }] + }] + }] +}