Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weather_Common.pl: Dewpoint calculated only once #329

Closed
JohanBraeken opened this issue Dec 13, 2013 · 3 comments
Closed

Weather_Common.pl: Dewpoint calculated only once #329

JohanBraeken opened this issue Dec 13, 2013 · 3 comments

Comments

@JohanBraeken
Copy link

When changes are made to weather_array[], "&weather_updated;" must be executed in order to calculate certain values.
The "dewpoint" is one of these values that gets calculated and the calculation depends on temperature and humidity.

Currently, the dewpoint calculation is not done when temperature and/or humidity changes as that part of the code is wrongly skipped.

Around Line 90:

# calculate dew point if missing, but we have temp and humid
        if ($temp ne 'unknown' and $humidity ne 'unknown' and $dewpoint eq 'unknown') {

This statement is only true when MisterHouse starts or is reloaded.
Once the dewpoint is calculated, the value gets inserted into the Weather_Array.

The next time "&weather_updated;" is executed, the $dewpoint variable is pulled from the Weather_Array and can never be "unknown" again.

Around line 75:

my $dewpoint=$$w{DewOutdoor};
$dewpoint=$$w{DewIndoor} unless defined $dewpoint;
$dewpoint='unknown' unless defined $dewpoint;

Because of this the dewpoint will never be calculated again.

Solution:
The code assumes temperature and dewpoint are known and tries to calculate the humidity as seen in the following lines of code:

Around line 113:

 # only calculate humidity if is isn't directly measured by something
                if (!$$w{HumidOutdoorMeasured}) {

The original

if ($temp ne 'unknown' and $humidity ne 'unknown' and $dewpoint eq 'unknown') {

can be changed to:

if ($temp ne 'unknown' and $humidity ne 'unknown' and $$w{HumidOutdoorMeasured}) {

so it will calculate the dewpoint correctly everytime.

@hollie
Copy link
Owner

hollie commented Dec 27, 2013

@JohanBraeken I've created a pull request with your change. Am I correct that this will only update the calculated dew point when the humidity is measured, but not when the temperature is updated?

Note to the other developers: if we need additional fixes we can just add them extra to the branch I created for this fix, the pull request should get updated automatically.

@JohanBraeken
Copy link
Author

Sorry for the late reply.

DewPoint will be calculated everytime "&weather_updated;" is called and "$$w{HumidOutdoorMeasured})" is true.
So the dewpoint will change whenever temperature or humidity changes.

@hollie
Copy link
Owner

hollie commented Jan 6, 2014

OK, merged into master.

@hollie hollie closed this as completed Jan 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants