Skip to content

Commit

Permalink
Bugfixes and some new data points
Browse files Browse the repository at this point in the history
  • Loading branch information
phifogg committed May 7, 2023
1 parent b735da0 commit 941881f
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ Station does not answer to scheduler commands, so only listener mode is supporte

Latest version

#### 0.10.1 Bugfixes

#### 0.10.0 Added new sensors for Lightning, Piezo elements, DP250 and minor fixes

#### 0.8.2 Updated UVRaw to maxvalue 4000
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": "sainlogic",
"version": "0.10.0",
"version": "0.10.1",
"news": {
"0.10.1": {
"en": "Bugfixes and new datapoints of battery level of some sensors",
"de": "Fehlerbehebungen und neue Datenpunkte für Batterieslevels von ein paar Sensoren"
},
"0.10.0": {
"en": "Added new external sensors for lightning (DP60), Co2 sensor (DP250), GW200A Piezo elements and minor fixes",
"de": "Neue Datenpunkte für Blitz (DP60), CO2 (DP250) und Piezo Regensensoren (GW200A), kleinere Updates"
Expand Down
83 changes: 82 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,36 @@ const DATAFIELDS = [
}
]
},
{
id: 'totalrainin',
channels: [{
channel: 'weather.current',
name: 'Rainrate (Total)'
},{
channel: 'weather.maxvalues.absolut',
name: 'Max. Rainrate (Total) (absolut)'
}],
type: 'number',
unit: 'mm',
role: 'value',
min: 0,
wunderground: '^totalrainin',
ecowitt: '^totalrainin',
scheduler: 'totalrainin',
listener_conversion: mm_to_inch,
scheduler_conversion: ' x / 10',
unit_config: 'unit_rain',
units: [{
display_name: 'in',
display_conversion: inch_to_mm,
main_unit_conversion: mm_to_inch
}, {
display_name: 'mm',
display_conversion: null,
main_unit_conversion: null
}
]
},
{
id: 'yearlyrain_piezo',
channels: [{
Expand Down Expand Up @@ -1149,6 +1179,57 @@ const DATAFIELDS = [
listener_conversion: null,
scheduler_conversion: null
},
{
id: 'wh80batt',
channels: [{
channel: 'weather.info',
name: 'WH80 Battery Voltage'
}],
type: 'number',
unit: 'V',
role: 'value.voltage',
min: 0,
max: 24,
wunderground: '^wh80batt([0-9])*',
ecowitt: '^wh80batt([0-9])*',
scheduler: null,
listener_conversion: null,
scheduler_conversion: null
},
{
id: 'wh40batt',
channels: [{
channel: 'weather.info',
name: 'WH40 Battery Voltage'
}],
type: 'number',
unit: 'V',
role: 'value.voltage',
min: 0,
max: 24,
wunderground: '^wh40batt([0-9])*',
ecowitt: '^wh40batt([0-9])*',
scheduler: null,
listener_conversion: null,
scheduler_conversion: null
},
{
id: 'wh25batt',
channels: [{
channel: 'weather.info',
name: 'WH25 Battery Voltage'
}],
type: 'number',
unit: 'V',
role: 'value.voltage',
min: 0,
max: 24,
wunderground: '^wh25batt([0-9])*',
ecowitt: '^wh25batt([0-9])*',
scheduler: null,
listener_conversion: null,
scheduler_conversion: null
},
{
id: 'tf_ch',
channels: [{
Expand Down Expand Up @@ -1512,7 +1593,7 @@ const COMMANDS = [
.uint32('weeklyrain').seek(1)
.uint32('monthlyrain').seek(1)
.uint32('yearlyrain').seek(1)
.uint32('raintotal').seek(1)
.uint32('totalrainin').seek(1)
.uint32('solarradiation').seek(1)
.uint16('UVraw').seek(1)
.uint8('uvi')
Expand Down
2 changes: 1 addition & 1 deletion lib/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Listener {
// forward to another host
const fwd_url = new URL(this.forward_url);

got(fwd_url, { searchParams: json_response, method: 'GET', retry: 0 }).then(response => {
got(fwd_url, { searchParams: json_response, method: 'GET', retry: {limit: 0} }).then(response => {
this.adapter.log.info(response.body.url);
this.adapter.log.info(response.body.explanation);
}).catch(error => {
Expand Down
13 changes: 8 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Sainlogic extends utils.Adapter {
if (target_unit != obj.common.unit) {
// change and convert unit
this.log.info(`Unit changed for ${c_id} from ${obj.common.unit} to ${target_unit}, updating data point`);
this.setObjectNotExists(c_id, {
this.extendObject(c_id, {
type: obj.type,
common: {
name: attrdef.display_name,
Expand Down Expand Up @@ -144,12 +144,15 @@ class Sainlogic extends utils.Adapter {
verify_datapoint(obj_id, that, attrdef, attrname, value) {

// check target type and type-cast if needed
if (attrdef.type == 'number') {
value = parseFloat(value);
let val_obj = { val: '', ack: true };
if (value != null) {
if (attrdef.type == 'number') {
value = parseFloat(value);
}

val_obj = { val: value, ack: true };
}

const val_obj = { val: value, ack: true };

this.getObject(obj_id, function (err, obj) {
if (err || obj == null) {

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.sainlogic",
"version": "0.10.0",
"version": "0.10.1",
"description": "Read data from a sainlogic based weather station",
"author": {
"name": "Daniel Draes",
Expand Down

0 comments on commit 941881f

Please sign in to comment.