pywws.service.weathercloud

Upload data to WeatherCloud.

Classes

ToService(context[, check_params])
class pywws.service.weathercloud.ToService(context, check_params=True)[source]

Bases: pywws.service.LiveDataService

config = {'deviceid': ('', True, 'wid'), 'devicekey': ('', True, 'key'), 'internal': ('False', True, None)}
fixed_data = {'type': '481', 'ver': '19.7.2'}
interval = datetime.timedelta(seconds=600)
logger = <Logger pywws.service.weathercloud (WARNING)>
service_name = 'weathercloud'
template = '\n#live#\n#temp_out\n "\'temp\' : \'%.0f\'," "" "scale(x, 10.0)"#\n#calc "wind_chill(data[\'temp_out\'], data[\'wind_ave\'])"\n "\'chill\' : \'%.0f\'," "" "scale(x, 10.0)"#\n#calc "dew_point(data[\'temp_out\'], data[\'hum_out\'])"\n "\'dew\' : \'%.0f\'," "" "scale(x, 10.0)"#\n#calc "usaheatindex(data[\'temp_out\'], data[\'hum_out\'])"\n "\'heat\' : \'%.0f\'," "" "scale(x, 10.0)"#\n#hum_out\n "\'hum\' : \'%.d\',"#\n#wind_ave\n "\'wspdavg\' : \'%.0f\'," "" "scale(x, 10.0)"#\n#wind_ave\n "\'wspd\' : \'%.0f\'," "" "scale(x, 10.0)"#\n#wind_gust\n "\'wspdhi\' : \'%.0f\'," "" "scale(x, 10.0)"#\n#wind_dir\n "\'wdiravg\' : \'%.0f\'," "" "winddir_degrees(x)"#\n#wind_dir\n "\'wdir\' : \'%.0f\'," "" "winddir_degrees(x)"#\n#rel_pressure\n "\'bar\' : \'%.0f\'," "" "scale(x, 10.0)"#\n#calc "rain_day(data)"\n "\'rain\' : \'%.0f\'," "" "scale(x, 10.0)"#\n#calc "rain_hour(data)"\n "\'rainrate\' : \'%.0f\'," "" "scale(x, 10.0)"#\n#idx\n "\'time\' : \'%Y%m%d %H%M%S\',"#\n'
session()[source]

Context manager factory function for a batch of one or more uploads.

This makes it easy to ensure any resources such as an internet connection are properly closed after a batch of uploads. Use the contextlib.contextmanager() decorator when you implement this method.

For a typical example, see the source code of the pywws.service.openweathermap module. If your upload can’t benefit from a session object yield None, as in pywws.service.copy.

valid_data(data)[source]
upload_data(session, prepared_data={})[source]

Upload one data set to the service.

Every data service class must implement this method.

Parameters:
  • session (object) – the object created by session(). This is typically used to communicate with the server and is automatically closed when a batch of uploads has finished.
  • prepared_data (dict) – a set of key: value pairs to upload. The keys and values must all be text strings.

Comments or questions? Please subscribe to the pywws mailing list http://groups.google.com/group/pywws and let us know.