Skip to content

Commit

Permalink
updated UDP Reference - v171
Browse files Browse the repository at this point in the history
  • Loading branch information
woessmich committed Jan 21, 2023
1 parent 26f4b68 commit 23cb5aa
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -59,9 +59,8 @@ The protocol sends a lightning distance of 0 when no lightning was detected. Val

## Changelog

### __WORK IN PROGRESS__
(Scrounger) calculation of absolut humidity added

### 0.1.3
(Scrounger) calculation of absolute humidity added
### 0.1.2
(womi) Update js-controller >3.0.0; checked compatibility with js-controller 4.0
### 0.1.1
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
@@ -1,9 +1,9 @@
version: 'test-{build}'
environment:
matrix:
- nodejs_version: '12'
- nodejs_version: '14'
- nodejs_version: '16'
- nodejs_version: '18'
platform:
- x86
- x64
Expand Down
5 changes: 4 additions & 1 deletion io-package.json
@@ -1,8 +1,11 @@
{
"common": {
"name": "weatherflow_udp",
"version": "0.1.2",
"version": "0.1.3",
"news": {
"0.1.3": {
"en": "Added absolute humidty to calculated values; updated to UDP Reference - v171"
},
"0.1.2": {
"en": "Updated js-controller min dependency; checked compatibility with js-controller 4.0"
},
Expand Down
19 changes: 13 additions & 6 deletions lib/messages.js
@@ -1,6 +1,6 @@
/*
WeatherFlow Smart Weather UDP Reference - v143
https://weatherflow.github.io/SmartWeather/api/udp/v143/
WeatherFlow Smart Weather UDP Reference - v171
https://https://weatherflow.github.io/Tempest/api/udp/v171/
*/

const { ENETDOWN } = require('constants');
Expand Down Expand Up @@ -28,7 +28,7 @@ messages.evt_strike = {
0: ['timestamp', {
type: 'state',
common: {
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
},
native: {},
}],
Expand Down Expand Up @@ -56,7 +56,7 @@ messages.rapid_wind = {
0: ['timestamp', {
type: 'state',
common: {
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
},
native: {},
}],
Expand Down Expand Up @@ -481,7 +481,7 @@ messages.device_status = {
native: {},
}],
},
sensor_status: { // 0x00000000 All Sensors OK, 0x00000001 lightning failed, 0x00000002 lightning noise, 0x00000004 lightning disturber, 0x00000008 pressure failed, 0x00000010 temperature failed, 0x00000020 rh failed, 0x00000040 wind failed, 0x00000080 precip failed, 0x00000100light/uv failed
sensor_status: { // 0x00000000 All Sensors OK, 0x00000001 lightning failed, 0x00000002 lightning noise, 0x00000004 lightning disturber, 0x00000008 pressure failed, 0x00000010 temperature failed, 0x00000020 rh failed, 0x00000040 wind failed, 0x00000080 precip failed, 0x00000100 light/uv failed, 0x00008000 power booster depleted, 0x00010000 power booster shore power
0: ['sensor_status', {
type: 'state',
common: {
Expand Down Expand Up @@ -613,7 +613,14 @@ messages.hub_status = {
3: ['radio_stats.radioStatus', {
type: 'state',
common: {
type: 'mixed', states: { 0: 'Radio Off', 1: 'Radio On', 3: 'Radio Active' }, read: true, write: false, role: 'value.status', name: 'Radio Status',
type: 'mixed',
states: {
0: 'Radio Off', 1: 'Radio On', 3: 'Radio Active', 7: 'BLE Connected',
},
read: true,
write: false,
role: 'value.status',
name: 'Radio Status',
},
native: {},
}],
Expand Down
12 changes: 5 additions & 7 deletions main.js
Expand Up @@ -683,7 +683,7 @@ class WeatherflowUdp extends utils.Adapter {
const stateParametersAbsoluteHumidity = {
type: 'state',
common: {
type: 'number', unit: 'g/m³', read: true, write: false, role: 'value.temperature.absoluteHumidity', name: 'absolute Humidity; adapter calculated',
type: 'number', unit: 'g/m³', read: true, write: false, role: 'value.humidity', name: 'absolute Humidity; adapter calculated',
},
native: {},
};
Expand All @@ -692,7 +692,6 @@ class WeatherflowUdp extends utils.Adapter {
const stationPressure = await that.getValObj(stateNameStationPressure);

if (airTemp !== null && stationPressure !== null) {

// Calculate min/max for dewpoint
that.calcMinMaxValue(stateNameAbsoluteHumidity, stateParametersAbsoluteHumidity, dewpoint(airTemp.val, fieldvalue, stationPressure.val).absoluteHumidity, MIN);
that.calcMinMaxValue(stateNameAbsoluteHumidity, stateParametersAbsoluteHumidity, dewpoint(airTemp.val, fieldvalue, stationPressure.val).absoluteHumidity, MAX);
Expand Down Expand Up @@ -1008,9 +1007,9 @@ function getQFF(temperature, airPressureAbsolute, altitude, humidity) {
*/
function dewpoint(temperature, humidity, pressure = undefined) {
// Konstanten
var mw = 18.016; // Molekulargewicht des Wasserdampfes (kg/kmol)
var gk = 8314.3; // universelle Gaskonstante (J/(kmol*K))
var t0 = 273.15; // Absolute Temperatur von 0 °C (Kelvin)
const mw = 18.016; // Molekulargewicht des Wasserdampfes (kg/kmol)
const gk = 8314.3; // universelle Gaskonstante (J/(kmol*K))
const t0 = 273.15; // Absolute Temperatur von 0 °C (Kelvin)

let a;
let b;
Expand All @@ -1034,11 +1033,10 @@ function dewpoint(temperature, humidity, pressure = undefined) {
const v = Math.log(DD / 6.1078) / Math.log(10);
const dewpointTemp = Math.round(((b * v) / (a - v)) * 10) / 10;


// absolut humidity
const absoluteHumidity = Math.pow(10, 5) * mw / gk * DD / (temperature + t0);

return { dewpointTemp: dewpointTemp, absoluteHumidity: absoluteHumidity };
return { dewpointTemp, absoluteHumidity };
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,5 +1,5 @@
{
"version": "0.1.2",
"version": "0.1.3",
"author": {
"name": "womi",
"email": "woessmich@gmail.com"
Expand Down

0 comments on commit 23cb5aa

Please sign in to comment.