mirror of
				https://github.com/MichMich/MagicMirror.git
				synced 2025-11-03 20:55:29 +00:00 
			
		
		
		
	Humidity data to the current weather module
This commit is contained in:
		@@ -14,7 +14,7 @@ modules: [
 | 
			
		||||
		config: {
 | 
			
		||||
			// See 'Configuration options' for more information.
 | 
			
		||||
			location: 'Amsterdam,Netherlands',
 | 
			
		||||
			locationID: '', //Location ID from http://bulk.openweather.org/sample/ 
 | 
			
		||||
			locationID: '', //Location ID from http://bulk.openweather.org/sample/
 | 
			
		||||
			appid: 'abcde12345abcde12345abcde12345ab' //openweathermap.org API key.
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -35,7 +35,7 @@ The following properties can be configured:
 | 
			
		||||
		</tr>
 | 
			
		||||
	<thead>
 | 
			
		||||
	<tbody>
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
		<tr>
 | 
			
		||||
			<td><code>location</code></td>
 | 
			
		||||
			<td>The location used for weather information.<br>
 | 
			
		||||
@@ -106,6 +106,13 @@ The following properties can be configured:
 | 
			
		||||
			</td>
 | 
			
		||||
		</tr>
 | 
			
		||||
		<tr>
 | 
			
		||||
			<td><code>showHumidity</code></td>
 | 
			
		||||
			<td>Show the current humidity<br>
 | 
			
		||||
				<br><b>Possible values:</b> <code>true</code> or <code>false</code>
 | 
			
		||||
				<br><b>Default value:</b> <code>false</code>
 | 
			
		||||
			</td>
 | 
			
		||||
		</tr>
 | 
			
		||||
    <tr>
 | 
			
		||||
			<td><code>useBeaufort</code></td>
 | 
			
		||||
			<td>Pick between using the Beaufort scale for wind speed or using the default units.<br>
 | 
			
		||||
				<br><b>Possible values:</b> <code>true</code> or <code>false</code>
 | 
			
		||||
 
 | 
			
		||||
@@ -6,3 +6,7 @@
 | 
			
		||||
  -webkit-transform: translate(0, -3px); /* Safari */
 | 
			
		||||
  transform: translate(0, -3px);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.currentweather .humidity-padding {
 | 
			
		||||
  padding-bottom: 6px;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,7 @@ Module.register("currentweather",{
 | 
			
		||||
		showWindDirection: true,
 | 
			
		||||
		useBeaufort: true,
 | 
			
		||||
		lang: config.language,
 | 
			
		||||
		showHumidity: false,
 | 
			
		||||
 | 
			
		||||
		initialLoadDelay: 0, // 0 seconds delay
 | 
			
		||||
		retryDelay: 2500,
 | 
			
		||||
@@ -142,6 +143,21 @@ Module.register("currentweather",{
 | 
			
		||||
		sunriseSunsetTime.innerHTML = " " + this.sunriseSunsetTime;
 | 
			
		||||
		small.appendChild(sunriseSunsetTime);
 | 
			
		||||
 | 
			
		||||
		wrapper.appendChild(small);
 | 
			
		||||
 | 
			
		||||
		if (this.config.showHumidity) {
 | 
			
		||||
			var middle = document.createElement("div");
 | 
			
		||||
			middle.className = "normal small humidity-padding";
 | 
			
		||||
 | 
			
		||||
			var humidity = document.createElement("span");
 | 
			
		||||
			humidity.innerHTML = "Humidity: " + this.humidity + "%"; // TODO: Localization
 | 
			
		||||
			var br = document.createElement("br");
 | 
			
		||||
 | 
			
		||||
			middle.appendChild(humidity);
 | 
			
		||||
			middle.appendChild(br);
 | 
			
		||||
			wrapper.appendChild(middle);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var large = document.createElement("div");
 | 
			
		||||
		large.className = "large light";
 | 
			
		||||
 | 
			
		||||
@@ -154,8 +170,8 @@ Module.register("currentweather",{
 | 
			
		||||
		temperature.innerHTML = " " + this.temperature + "°";
 | 
			
		||||
		large.appendChild(temperature);
 | 
			
		||||
 | 
			
		||||
		wrapper.appendChild(small);
 | 
			
		||||
		wrapper.appendChild(large);
 | 
			
		||||
 | 
			
		||||
		return wrapper;
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
@@ -224,6 +240,7 @@ Module.register("currentweather",{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		this.humidity = parseFloat(data.main.humidity);
 | 
			
		||||
		this.temperature = this.roundValue(data.main.temp);
 | 
			
		||||
 | 
			
		||||
		if (this.config.useBeaufort){
 | 
			
		||||
@@ -315,39 +332,39 @@ Module.register("currentweather",{
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	deg2Cardinal: function(deg) {
 | 
			
		||||
                if (deg>11.25 && deg<=33.75){
 | 
			
		||||
                        return "NNE";
 | 
			
		||||
                } else if (deg > 33.75 && deg <= 56.25) {
 | 
			
		||||
                        return "NE";
 | 
			
		||||
                } else if (deg > 56.25 && deg <= 78.75) {
 | 
			
		||||
                        return "ENE";
 | 
			
		||||
                } else if (deg > 78.75 && deg <= 101.25) {
 | 
			
		||||
                        return "E";
 | 
			
		||||
                } else if (deg > 101.25 && deg <= 123.75) {
 | 
			
		||||
                        return "ESE";
 | 
			
		||||
                } else if (deg > 123.75 && deg <= 146.25) {
 | 
			
		||||
                        return "SE";
 | 
			
		||||
                } else if (deg > 146.25 && deg <= 168.75) {
 | 
			
		||||
                        return "SSE";
 | 
			
		||||
                } else if (deg > 168.75 && deg <= 191.25) {
 | 
			
		||||
                        return "S";
 | 
			
		||||
                } else if (deg > 191.25 && deg <= 213.75) {
 | 
			
		||||
                        return "SSW";
 | 
			
		||||
                } else if (deg > 213.75 && deg <= 236.25) {
 | 
			
		||||
                        return "SW";
 | 
			
		||||
                } else if (deg > 236.25 && deg <= 258.75) {
 | 
			
		||||
                        return "WSW";
 | 
			
		||||
                } else if (deg > 258.75 && deg <= 281.25) {
 | 
			
		||||
                        return "W";
 | 
			
		||||
                } else if (deg > 281.25 && deg <= 303.75) {
 | 
			
		||||
                        return "WNW";
 | 
			
		||||
                } else if (deg > 303.75 && deg <= 326.25) {
 | 
			
		||||
                        return "NW";
 | 
			
		||||
                } else if (deg > 326.25 && deg <= 348.75) {
 | 
			
		||||
                        return "NNW";
 | 
			
		||||
                } else {
 | 
			
		||||
                         return "N";
 | 
			
		||||
                }
 | 
			
		||||
								if (deg>11.25 && deg<=33.75){
 | 
			
		||||
												return "NNE";
 | 
			
		||||
								} else if (deg > 33.75 && deg <= 56.25) {
 | 
			
		||||
												return "NE";
 | 
			
		||||
								} else if (deg > 56.25 && deg <= 78.75) {
 | 
			
		||||
												return "ENE";
 | 
			
		||||
								} else if (deg > 78.75 && deg <= 101.25) {
 | 
			
		||||
												return "E";
 | 
			
		||||
								} else if (deg > 101.25 && deg <= 123.75) {
 | 
			
		||||
												return "ESE";
 | 
			
		||||
								} else if (deg > 123.75 && deg <= 146.25) {
 | 
			
		||||
												return "SE";
 | 
			
		||||
								} else if (deg > 146.25 && deg <= 168.75) {
 | 
			
		||||
												return "SSE";
 | 
			
		||||
								} else if (deg > 168.75 && deg <= 191.25) {
 | 
			
		||||
												return "S";
 | 
			
		||||
								} else if (deg > 191.25 && deg <= 213.75) {
 | 
			
		||||
												return "SSW";
 | 
			
		||||
								} else if (deg > 213.75 && deg <= 236.25) {
 | 
			
		||||
												return "SW";
 | 
			
		||||
								} else if (deg > 236.25 && deg <= 258.75) {
 | 
			
		||||
												return "WSW";
 | 
			
		||||
								} else if (deg > 258.75 && deg <= 281.25) {
 | 
			
		||||
												return "W";
 | 
			
		||||
								} else if (deg > 281.25 && deg <= 303.75) {
 | 
			
		||||
												return "WNW";
 | 
			
		||||
								} else if (deg > 303.75 && deg <= 326.25) {
 | 
			
		||||
												return "NW";
 | 
			
		||||
								} else if (deg > 326.25 && deg <= 348.75) {
 | 
			
		||||
												return "NNW";
 | 
			
		||||
								} else {
 | 
			
		||||
												 return "N";
 | 
			
		||||
								}
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user