示例#1
0
 def read_location_xml(p_pyhouse_obj):
     """
     @param p_house_xml: is the config file xml for a house.
     """
     l_obj = LocationData()
     l_obj.RiseSet = RiseSetData()
     p_pyhouse_obj.House.Location = l_obj
     try:
         l_xml = p_pyhouse_obj.Xml.XmlRoot.find('HouseDivision')
         if l_xml is None:
             return l_obj
         l_xml = l_xml.find('LocationSection')
         if l_xml is None:
             return l_obj
         l_obj.Street = PutGetXML.get_text_from_xml(l_xml, 'Street')
         l_obj.City = PutGetXML.get_text_from_xml(l_xml, 'City')
         l_obj.State = PutGetXML.get_text_from_xml(l_xml, 'State')
         l_obj.ZipCode = PutGetXML.get_text_from_xml(l_xml, 'ZipCode', '99999')
         l_obj.Region = PutGetXML.get_text_from_xml(l_xml, 'Region', 'America')
         l_obj.Phone = PutGetXML.get_text_from_xml(l_xml, 'Phone')
         l_obj.Latitude = PutGetXML.get_float_from_xml(l_xml, 'Latitude')
         l_obj.Longitude = PutGetXML.get_float_from_xml(l_xml, 'Longitude')
         l_obj.Elevation = PutGetXML.get_float_from_xml(l_xml, 'Elevation', 10)
         l_obj.TimeZoneName = PutGetXML.get_text_from_xml(l_xml, 'TimeZoneName', 'America/New_York')
     except AttributeError as e_err:
         LOG.error('ERROR getting location Data - {}'.format(e_err))
     p_pyhouse_obj.House.Location = l_obj
     LOG.info('Loaded location information.')
     return l_obj
示例#2
0
 def __init__(self):
     # type: (Any) -> None
     super(LocationInformationPrivate, self).__init__()
     self._RiseSet = RiseSetData()  # RiseSetData()
     self._Yaml = None
     self._TimeZoneOffset = '-5:00'
     self._IsDaylightSavingsTime = False
示例#3
0
 def calc_solar_times(p_pyhouse_obj, p_date=datetime.date.today()):
     """
     @param p_date: is the datetime.date that we want sunrise and sunset for
     """
     l_a = astral.Location(info=(p_pyhouse_obj.House.Name,
                                 p_pyhouse_obj.House.Location.Region,
                                 p_pyhouse_obj.House.Location.Latitude,
                                 p_pyhouse_obj.House.Location.Longitude,
                                 p_pyhouse_obj.House.Location.TimeZoneName,
                                 p_pyhouse_obj.House.Location.Elevation))
     l_a.solar_depression = "civil"
     if (isinstance(p_date, datetime.datetime)):
         l_date = p_date.date(
         )  # convert datetime.datetime to datetime.date
     else:
         l_date = p_date
     # print(PrettyFormatAny.form('{}'.format(l_a), 'AA'))
     l_sun = l_a.sun(date=l_date, local=True)
     l_ret = RiseSetData()
     l_ret.Dawn = l_sun['dawn']
     l_ret.SunRise = l_sun['sunrise']
     l_ret.Noon = l_sun['noon']
     l_ret.SunSet = l_sun['sunset']
     l_ret.Dusk = l_sun['dusk']
     p_pyhouse_obj.House.Location.RiseSet = l_ret
     LOG.info('Sunrise/Sunset Calculation')
     return l_ret
示例#4
0
 def RiseSet():
     l_ret = RiseSetData()
     l_ret.Dawn = 0
     l_ret.SunRise = 0
     l_ret.Noon = 0
     l_ret.SunSet = 0
     l_ret.Dusk = 0
     return l_ret
示例#5
0
 def RiseSet():
     l_ret = RiseSetData()
     l_ret.Dawn = TESTING_SCHEDULE_DAWN_0
     l_ret.SunRise = TESTING_SCHEDULE_SUNRISE_0
     l_ret.Noon = TESTING_SCHEDULE_NOON_0
     l_ret.SunSet = TESTING_SCHEDULE_SUNSET_0
     l_ret.Dusk = TESTING_SCHEDULE_DUSK_0
     return l_ret
示例#6
0
 def RiseSet():
     l_ret = RiseSetData()
     l_ret.SunRise = TESTING_SCHEDULE_SUNRISE_0
     l_ret.SunSet = TESTING_SCHEDULE_SUNSET_0
     return l_ret
示例#7
0
 def RiseSet():
     l_ret = RiseSetData()
     l_ret.SunRise = T_SUNRISE
     l_ret.SunSet = T_SUNSET
     return l_ret