Skip to content

Commit

Permalink
Merge pull request #3 from peterzen/round-calculated-values
Browse files Browse the repository at this point in the history
Round calculated values
  • Loading branch information
peterzen authored Apr 5, 2023
2 parents 6600e57 + 91e64ea commit a5b1502
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

This Home Assistant add-on retrieves live weather data from a WH2600 personal weather station (PWS) and publishes it to an MQTT topic where HAAS can access it as sensor information.

Supported weather stations: tested on Renkforce WH260, probably also supports Froggit units but I can't verify it.

## Installation

Add this URL to your HAAS add-on repositories:
Expand Down
6 changes: 6 additions & 0 deletions pwsmqttdispatcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.1.19

- Rounding calculated values to 1 decimal
- Added info about supported weather stations


## 0.1.18

- Calculate dew point, wind chill, cardinal wind direction
Expand Down
2 changes: 1 addition & 1 deletion pwsmqttdispatcher/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
name: PWS to MQTT dispatcher addon
version: "0.1.18"
version: "0.1.19"
slug: pwsmqttdispatcher
description: Push weather station (PWS) data to MQTT
url: "https://github.com/peterzen/haas-pws-mqtt-addon/tree/main/pwsmqttdispatcher"
Expand Down
4 changes: 2 additions & 2 deletions pwsmqttdispatcher/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ func calculateWindChill(windSpeed float64, temp float64) float64 {
T := temp*1.8 + 32 // convert temperature to Fahrenheit
WCI := 35.74 + 0.6215*T - 35.75*math.Pow(V, 0.16) + 0.4275*T*math.Pow(V, 0.16)
windChill := (WCI - 32) * 5 / 9 // convert wind chill to Celsius
return windChill
return math.Round(windChill*10) / 10
}

func calculateDewPoint(tempCelsius, humidity float64) float64 {
a := 17.27
b := 237.7
alpha := ((a * tempCelsius) / (b + tempCelsius)) + math.Log(humidity/100.0)
dewPointCelsius := (b * alpha) / (a - alpha)
return dewPointCelsius
return math.Round(dewPointCelsius*10) / 10
}

func addCalculatedData(wd WeatherData) WeatherData {
Expand Down

0 comments on commit a5b1502

Please sign in to comment.