Skip to content

Commit

Permalink
ADDED: Support for displaying humidity values if data is provided by …
Browse files Browse the repository at this point in the history
…the sensor. Version bumped to 1.1.0.
  • Loading branch information
balassy committed Jan 17, 2019
1 parent 190d718 commit 48d4364
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project is documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.1.0]

- ADDED: Displaying humidity data if provided by the sensor.

## [1.0.0]

First public release.
8 changes: 7 additions & 1 deletion MMM-RemoteTemperature.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.MMM-RemoteTemperature .symbol {
margin-right: 10px;
margin-right: 15px;
}

.MMM-RemoteTemperature .humidity {
display: inline-block;
margin-left: 10px;
}

8 changes: 8 additions & 0 deletions MMM-RemoteTemperature.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ Module.register('MMM-RemoteTemperature', {
tempEl.innerHTML = `${this.viewModel.temp}°`;
firstLineEl.appendChild(tempEl);

if (this.viewModel.humidity) {
const humidityEl = document.createElement('span');
humidityEl.classList = "humidity";
humidityEl.innerHTML = `${this.viewModel.humidity}%`;
firstLineEl.appendChild(humidityEl);
}

wrapper.appendChild(firstLineEl);

if (this.config.showTime) {
Expand All @@ -79,6 +86,7 @@ Module.register('MMM-RemoteTemperature', {
if (!this.config.sensorId || (this.config.sensorId && this.config.sensorId === payload.sensorId)) {
this.viewModel = {
temp: payload.temp,
humidity: payload.humidity,
timestamp: Date.now()
};

Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# MMM-RemoteTemperature

This is a module for the [MagicMirror²](https://github.com/MichMich/MagicMirror/) to display temperature values from a remote sensor that is capable to POST the measured value through HTTP protocol.
This is a module for the [MagicMirror²](https://github.com/MichMich/MagicMirror/) to display temperature and humidity values from a remote sensor that is capable to POST the measured values through HTTP protocol.

## Features

By default this module displays the measured temperature, an icon and the time of the last update:
By default this module displays the measured temperature, humidity, an icon and the time of the last update:

![Default](https://raw.githubusercontent.com/balassy/MMM-RemoteTemperature/master/doc/screenshot-default.png)
![Default](./doc/screenshot-with-humidity.png)

If the sensor does not send humidity data, then only the temperature is displayed:

![Default](./doc/screenshot-temp-only.png)

You can configure the module to display a custom icon:

Expand Down Expand Up @@ -83,11 +87,14 @@ This module can work with any temperature sensor that is capable to periodically
```javascript
{
"temp": 27,
"humidity": 30.4,
"sensorId": "1"
}
```

The `temp` property value must be a `number`, and must contain the measured temperature. It will be displayed on the mirror as is, without any conversion.
The `temp` property value must be a `number`, and must contain the measured temperature. It will be displayed on the mirror as is, without any conversion, appended by the `°` symbol.

The `humidity` property value is optional, but if specified, it must be a number, and must contain the measured humidity represented in percentage. It will be displayed on the mirror as is, without any conversion, appended by the `%` symbol.

The `sensorId` property must be a `string`, and can contain any value, but it is important that it must match the `sensorId` specified for the module in the configuration. It is used to determine which module should display the value, if the module is added multiple times to the mirror. It can also be used as an API key to ensure that only authorized sensors can update the mirror.

Expand Down
File renamed without changes
Binary file added doc/screenshot-with-humidity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = NodeHelper.create({

const payload = {
temp: params.temp,
humidity: params.humidity,
sensorId: params.sensorId
};

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": "MMM-RemoteTemperature",
"version": "1.0.0",
"version": "1.1.0",
"description": "MagicMirror module that displays temperature value from a remote sensor.",
"main": "MMM-RemoteTemperature.js",
"author": "György Balássy",
Expand Down

0 comments on commit 48d4364

Please sign in to comment.