Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

Commit

Permalink
feat: Added pressure for compatible sensors.
Browse files Browse the repository at this point in the history
Some sensors have pressure that is nice to use.
  • Loading branch information
Stephan van Rooij committed Dec 12, 2017
1 parent c99109c commit 0da1905
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ function publishMagnetState (device, newState) {
function publishHTSensor (sensorDevice) {
const tempTopic = `${config.name}/status/temperature/${sensorDevice.getSid()}`
const humTopic = `${config.name}/status/humidity/${sensorDevice.getSid()}`
const presTopic = `${config.name}/status/pressure/${sensorDevice.getSid()}`
let data = {
val: sensorDevice.getTemperature(),
battery: sensorDevice.getBatteryPercentage(),
Expand All @@ -233,6 +234,15 @@ function publishHTSensor (sensorDevice) {
JSON.stringify(data),
{qos: 0, retain: true}
)

let pressure = sensorDevice.getPressure()
if (pressure !== null) {
data.val = pressure
mqttClient.publish(presTopic,
JSON.stringify(data),
{qos: 0, retain: true}
)
}
}

// Usefull function
Expand Down

0 comments on commit 0da1905

Please sign in to comment.