Skip to content

Commit

Permalink
invalid date in timestamp corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
woessmich committed Aug 9, 2021
1 parent 9592281 commit d7e62ab
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 39 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Standard port the adpater listens on is 50222 but can be changed in setup.
The adapter provides a minimum set of setup options.
The listening port can be changed, which should not be required as the port the weatherstation hub is sending can not be changed, to my knowledge.

The station height in meters above sea level is used to calculate the reduced pressure from local pressure as is provided by the station. Just use the same height as entered in the App. There may be small differences compared to the reduced pressure in the app depending on the formula used. The adapter uses the formula the german weather service DWD is using (http://dk0te.ba-ravensburg.de/cgi-bin/navi?m=WX_BAROMETER; found [here](https://www.symcon.de/forum/threads/6480-Relativen-Luftdruck-aus-absoluten-Luftdruck-errechnen)).
The station height in meters above sea level is used to calculate the reduced pressure from local pressure as is provided by the station. Just use the same height as entered in the App. There may be small differences compared to the reduced pressure in the app depending on the formula used. The adapter uses the formula the german weather service DWD is using (http://dk0te.ba-ravensburg.de/cgi-bin/navi?m=WX_BAROMETER; nur noch [hier](https://www.symcon.de/forum/threads/6480-Relativen-Luftdruck-aus-absoluten-Luftdruck-errechnen)).

When the debug checkbox is ticked, the adapter creates a lot of output in the log file. Should only be used for debugging.

Expand Down Expand Up @@ -59,6 +59,8 @@ Further, the adapter provides a selection of useful minimum and maximum values o
The protocol sends a lightning distance of 0 when no lightning was detected. Values of 0 are modified to 999 to avoid the impression that lightning strikes are directly overhead.

## Changelog
### 0.1.1
(womi) Fixed "invalid date" in timestamps
### 0.1.0
(womi) Compatibility with Admin 5; Stable version

Expand Down
6 changes: 5 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"common": {
"name": "weatherflow_udp",
"version": "0.1.0",
"version": "0.1.1",
"news": {
"0.1.1": {
"en": "Fixed 'invalid date' for timestamps",
"de": "Problem mit ungültigen Datumswerten bei den Zeitstempeln behoben"
},
"0.1.0": {
"en": "Compatibility with Admin 5; Stable version",
"de": "Kompatibilität mit Admin 5"
Expand Down
16 changes: 8 additions & 8 deletions lib/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ messages.evt_precip = {
0: ['timestamp', {
type: 'state',
common: {
type: 'object', read: true, write: false, role: 'date', name: 'Time of event',
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
},
native: {},
}],
Expand All @@ -28,7 +28,7 @@ messages.evt_strike = {
0: ['timestamp', {
type: 'state',
common: {
type: 'object', read: true, write: false, role: 'date', 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: 'object', read: true, write: false, role: 'date', name: 'Time of event',
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
},
native: {},
}],
Expand Down Expand Up @@ -84,7 +84,7 @@ messages.obs_air = {
0: ['timestamp', {
type: 'state',
common: {
type: 'object', read: true, write: false, role: 'date', name: 'Time of event',
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
},
native: {},
}],
Expand Down Expand Up @@ -157,7 +157,7 @@ messages.obs_sky = {
0: ['timestamp', {
type: 'state',
common: {
type: 'object', read: true, write: false, role: 'date', name: 'Time of event',
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
},
native: {},
}],
Expand Down Expand Up @@ -280,7 +280,7 @@ messages.obs_st = {
0: ['timestamp', {
type: 'state',
common: {
type: 'object', read: true, write: false, role: 'date', name: 'Time of event',
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
},
native: {},
}],
Expand Down Expand Up @@ -430,7 +430,7 @@ messages.device_status = {
0: ['timestamp', {
type: 'state',
common: {
type: 'object', read: true, write: false, role: 'date', name: 'Time of event',
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
},
native: {},
}],
Expand Down Expand Up @@ -536,7 +536,7 @@ messages.hub_status = {
0: ['timestamp', {
type: 'state',
common: {
type: 'object', read: true, write: false, role: 'date', name: 'Time of event',
type: 'number', read: true, write: false, role: 'value.time', name: 'Time of event',
},
native: {},
}],
Expand Down
6 changes: 3 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class WeatherflowUdp extends utils.Adapter {

// Deal with timestamp messages
if (messageInfo[item][field][0] === 'timestamp') {
fieldvalue = JSON.stringify(new Date(fieldvalue * 1000)); // timestamp in iobroker is milliseconds and provided timestamp is seconds
fieldvalue = new Date(fieldvalue * 1000).getTime(); // timestamp in iobroker is milliseconds and provided timestamp is seconds
}

if (that.config.debug === true) { that.log.info(['[', field, '] ', 'state: ', stateName, ' = ', fieldvalue].join('')); }
Expand Down Expand Up @@ -314,7 +314,7 @@ class WeatherflowUdp extends utils.Adapter {
}
}

// raining or not as binary state?
// raining or not as boolean state?
//-------------------------------
if (messageInfo[item][field][0] === 'precipAccumulated') {
const statePathCorrected = statePath.replace('obs_st', 'evt_precip').replace('obs_sky', 'evt_precip'); // move state from observation to evt_precip
Expand All @@ -333,7 +333,7 @@ class WeatherflowUdp extends utils.Adapter {
}
}

if (messageType === 'evt_precip' && messageInfo[item][field][0] === 'timestamp') { // if precipitation start is recieved also set to true
if (messageType === 'evt_precip' && messageInfo[item][field][0] === 'timestamp') { // if precipitation start is received also set to true
const stateNameRaining = [statePath, 'raining'].join('.');
const stateParametersRaining = {
type: 'state',
Expand Down
28 changes: 2 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
{
"_from": "iobroker.weatherflow_udp@0.0.15",
"_id": "iobroker.weatherflow_udp@0.0.15",
"_inBundle": false,
"_integrity": "sha512-SPH6/PhwHV3nFY4ZdTBvh6505DNkyJDOG5lr/XJkmF/dF2PhAT269q9Bfst8NEG/1BZQ+2Qk4xlVAEJtVgBh2g==",
"_location": "/iobroker.weatherflow_udp",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "iobroker.weatherflow_udp@0.0.15",
"name": "iobroker.weatherflow_udp",
"escapedName": "iobroker.weatherflow_udp",
"rawSpec": "0.0.15",
"saveSpec": null,
"fetchSpec": "0.0.15"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/iobroker.weatherflow_udp/-/iobroker.weatherflow_udp-0.0.15.tgz",
"_shasum": "70f06f5a71d204ba4c5fa832093b1d7eb9a03963",
"_spec": "iobroker.weatherflow_udp@0.0.15",
"_where": "C:\\iobroker",
"version": "0.1.1",
"author": {
"name": "womi",
"email": "woessmich@gmail.com"
Expand Down Expand Up @@ -82,6 +59,5 @@
"test:js": "mocha --opts test/mocha.custom.opts",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit"
},
"version": "0.1.0"
}
}

0 comments on commit d7e62ab

Please sign in to comment.