Verified Commit fc7365f3 authored by Peter Müller's avatar Peter Müller
Browse files

Added "air pressure" to RadioHeadWeatherStation device

Also updated radiohead-serial dependency to v4.1.1
parent 4cd68799
Pipeline #410 passed with stages
in 48 seconds
## v2.1.0 2020-12-05
- Added "air pressure" to RadioHeadWeatherStation device
## v2.0.0 2019-06-26
- BREAKING CHANGE: Minimum required Node.js version is now v8.9.0
- Upgraded `radiohead-serial` dependency
......
......@@ -111,6 +111,7 @@ Die folgenden Indikatoren können verwendet werden, um die Position der Werte in
* `t` - Temperatur
* `h` - Luftfeuchtigkeit
* `r` - Regenmenge
* `p` - Luftdruck
* `ws` - Windgeschwindigkeit
* `wd` - Windrichtung
* `wg` - Windböengeschwindigkeit
......@@ -236,6 +237,6 @@ Außerdem werden einige andere Informationen im Log angezeigt, wie zum Beispiel
Lizenziert unter GPL Version 2
Copyright (c) 2017 Peter Müller <peter@crycode.de> (https://crycode.de/)
Copyright (c) 2017-2020 Peter Müller <peter@crycode.de> (https://crycode.de/)
Einige Codeteile des RadioHeadWeatherStation-Gerätes sind inspiriert von [pimatic-homeduino](https://github.com/pimatic/pimatic-homeduino).
......@@ -110,6 +110,7 @@ Supported data types in a message are: 32bit Float LE, 64bit Double LE, 8bit Int
Use the following indicators to mark the positions of the values in the data messages:
* `t` - temperature
* `h` - humidity
* `p` - air presure
* `r` - rain
* `ws` - wind speed
* `wd` - wind direction
......@@ -235,6 +236,6 @@ In debug mode you will find all received RadioHead messages in the log and some
Licensed under GPL Version 2
Copyright (c) 2017 Peter Müller <peter@crycode.de> (https://crycode.de/)
Copyright (c) 2017-2020 Peter Müller <peter@crycode.de> (https://crycode.de/)
Some parts of the RadioHeadWeatherStation devices are inspired by [pimatic-homeduino](https://github.com/pimatic/pimatic-homeduino).
......@@ -310,6 +310,24 @@ module.exports = {
description: "Ausdruck, der den Wert vorverarbeiten kann. $value ist ein Platzhalter für den Wert selbst."
type: "string"
default: "$value"
pressure:
description: "Der Datentyp des übertragenen Luftdrucks oder 'none' wenn kein Luftdruck verwendet wird."
enum: [
"none"
"32bit Float LE", "64bit Double LE",
"8bit Integer", "8bit Unsigned Integer", "16bit Integer LE", "16bit Unsigned Integer LE", "32bit Integer LE", "32bit Unsigned Integer LE",
"4bit Float BE", "8bit Double BE",
"16bit Integer BE", "16bit Unsigned Integer BE", "32bit Integer BE", "32bit Unsigned Integer BE"
]
default: "none"
pressureUnit:
description: "Die Einheit des Luftdrucks."
type: "string"
default: "hPa"
pressureProcessing:
description: "Ausdruck, der den Wert vorverarbeiten kann. $value ist ein Platzhalter für den Wert selbst."
type: "string"
default: "$value"
rain:
description: "Der Datentyp der übertragenen Regenmenge oder 'none' wenn keine Regenmenge verwendet wird."
enum: [
......
......@@ -309,6 +309,24 @@ module.exports = {
description: "Expression that can preprocess the value, $value is a placeholder for the value itself."
type: "string"
default: "$value"
pressure:
description: "The datatype of the transmitted air pressure or 'none' if no air pressure is used."
enum: [
"none"
"32bit Float LE", "64bit Double LE",
"8bit Integer", "8bit Unsigned Integer", "16bit Integer LE", "16bit Unsigned Integer LE", "32bit Integer LE", "32bit Unsigned Integer LE",
"4bit Float BE", "8bit Double BE",
"16bit Integer BE", "16bit Unsigned Integer BE", "32bit Integer BE", "32bit Unsigned Integer BE"
]
default: "none"
pressureUnit:
description: "The unit of the air pressure."
type: "string"
default: "hPa"
pressureProcessing:
description: "Expression that can preprocess the value, $value is a placeholder for the value itself."
type: "string"
default: "$value"
rain:
description: "The datatype of the transmitted rain fall or 'none' if no rain fall is used."
enum: [
......
......@@ -23,7 +23,7 @@
"README.md",
"README-de.md"
],
"version": "2.0.0",
"version": "2.1.0",
"homepage": "https://crycode.de/pimatic-radiohead",
"license": "GPL-2.0",
"repository": {
......@@ -35,7 +35,7 @@
},
"configSchema": "radiohead-config-schema.coffee",
"dependencies": {
"radiohead-serial": "^4.0.1"
"radiohead-serial": "^4.1.1"
},
"peerDependencies": {
"pimatic": "0.9.*"
......
###
# Pimatic RadioHead Plugin
#
# Copyright (c) 2017 Peter Müller <peter@crycode.de> (https://crycode.de)
# Copyright (c) 2017-2020 Peter Müller <peter@crycode.de> (https://crycode.de)
#
# Plugin for Pimatic to send and receive messages through a network of RadioHead nodes.
# RadioHead is a Packet Radio library for embedded microprocessors and (c) 2008 Mike McCauley.
......@@ -672,6 +672,10 @@ module.exports = (env) ->
@humidityIndex = []
@_humidity = lastState?.humidity?.value or 0
@hasPressure = false
@pressureIndex = []
@_pressure = lastState?.pressure?.value or 0
@hasRain = false
@rainIndex = []
@_rain = lastState?.rain?.value or 0
......@@ -732,6 +736,15 @@ module.exports = (env) ->
acronym: 'RH'
}
if @config.pressure? and @config.pressure isnt 'none'
@hasPressure = true
@attributes.pressure = {
description: "the measured air pressure"
type: "number"
unit: @config.pressureUnit or 'hPa'
acronym: 'P'
}
if @config.rain? and @config.rain isnt 'none'
@hasRain = true
@attributes.rain = {
......@@ -824,6 +837,13 @@ module.exports = (env) ->
_.forEach data, (value, index) =>
data[index] = '*' if value is 'h'
if @hasPressure
@pressureIndex[i] = _.indexOf data, 'p'
if @pressureIndex[i] >= 0
# translate the p's to *
_.forEach data, (value, index) =>
data[index] = '*' if value is 'p'
if @hasRain
@rainIndex[i] = _.indexOf data, 'r'
if @rainIndex[i] >= 0
......@@ -909,6 +929,20 @@ module.exports = (env) ->
@emit "humidity", @_humidity
)
# check the data bytes for air pressure
if @hasPressure and @pressureIndex[i] >= 0 and checkDataMatch msg.data, @data[i]
env.logger.debug "#{@id} [#{i}] received data matched air pressure", msg.data, @data[i]
pressure = getValueFromBuffer msg.data, @config.pressure, @pressureIndex[i], @id
unless isNaN pressure
processing = @config.pressureProcessing or "$value"
info = @framework.variableManager.parseVariableExpression(
processing.replace(/\$value\b/g, pressure)
)
@framework.variableManager.evaluateNumericExpression(info.tokens).then( (value) =>
@_pressure = value
@emit "pressure", @_pressure
)
# check the data bytes for rain
if @hasRain and @rainIndex[i] >= 0 and checkDataMatch msg.data, @data[i]
env.logger.debug "#{@id} [#{i}] received data matched rain", msg.data, @data[i]
......@@ -1015,6 +1049,7 @@ module.exports = (env) ->
getRain: -> Promise.resolve @_rain
getTemperature: -> Promise.resolve @_temperature
getHumidity: -> Promise.resolve @_humidity
getPressure: -> Promise.resolve @_pressure
getLowBattery: -> Promise.resolve @_lowBattery
getBattery: -> Promise.resolve @_battery
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment