Dew point¶
The aim is to determine if condensation will occur. Temperature and humidity are used to calculate a dew point. If temperature is lower than the dew point, condensation will appear.
As water vapour concentration grows, the rate of condensation increases. The amount of water grows until the rate of condensation and the rate of evaporation are in equilibrium. Then the water vapour concentration will stop increasing because the air is saturated with water vapour. Relative humidity of saturated air is 100 %. The temperature to which the air has to be cooled to reach saturation is called dew point.
The configuration parameters in the examples below can be changed
in the configuration file config.ini
that is described in section Configuration file.
"""Dew point.
"""
from os.path import dirname, abspath, join
import sys
sys.path.append(abspath(join(dirname(__file__), '../..', '')))
from dm.ConnectionUtil import ConnectionUtil as cu
from dm.models.ModelsUtil import ModelsUtil
from dm.WundergroundCom import WundergroundCom
from dm.DateTimeUtil import DateTimeUtil
if __name__ == '__main__':
cu.setup_logging()
cls = cu.setup_clients()
actual_time = int(DateTimeUtil.local_time_str_to_utc('2019/02/20 03:00:00').timestamp())
lat = 49.1649894
lon = 16.562262499999974
w = WundergroundCom()
w.api_key = cu.wunderground_api_key()
devs = [
{
'db_column_name': 'temperature_in_celsius',
'name': 'BeeeOn sensor',
'gateway_id': '1816820318180747',
'device_id': '0xa900811026800001',
'module_id': 0,
'server_name': 'ant-work',
},
{
'db_column_name': 'rh_in_percentage',
'name': 'BeeeOn sensor',
'gateway_id': '1816820318180747',
'device_id': '0xa900811026800001',
'module_id': 1,
'server_name': 'ant-work',
}
]
notification = ModelsUtil.dew_point(devs, cls, lat, lon, actual_time, w)
ModelsUtil.json_to_file(notification, 'notification.doc.json', log_notification=True)
It is necessary to set clients that can communicate with a remote server using the function setup_clients
.
Current time is stored in the variable actual_time
. Latitude and longitude that enable to get weather data
according to a sensor position are stored in the variable lat
and lon
. The API key allows to get weather data
from server and it is obtained by the function wunderground_api_key
. The sensors used to gather data are stored
in the variable devs
. Determination if condensation will occur is performed by the function dew_point
and the result is stored
in the variable notification
.
An output of the determination is a notification that contains basic information described in the section Notifications and the following information:
dew_point - dew point calculated using indoor temperature and humidity,
dewing - if condensation will occur,
hum_in - indoor humidity,
temp_in - indoor temperature,
type - what quantity is used for prediction.
The example of a notification follows.
{
"data": {
"dew_point": 11.75,
"dewing": null,
"hum_in": 41.0,
"temp_in": 26.0,
"type": "dew_point"
},
"device_id": "0xa900811026800001",
"event": "env-notification-pre",
"gateway_id": "1816820318180747",
"raise": true,
"raise_catch": false,
"readable": "2019-02-20 03:00:00",
"timestamp": 1550628000
}
The example of a command that can be used to determine if condensation will occur is below.
python examples2/0304_dew_point/run.py