コード例 #1
0
    def run(self, wcd, wci):
        """
        Displaying expected temperature
        """
        # Get current forecast
        if self.weather_service == "yahoo":
            current_weather_forecast = pywapi.get_weather_from_yahoo(self.location_id)
        elif self.weather_service == "weather_dot_com":
            current_weather_forecast = pywapi.get_weather_from_weather_com(self.location_id)
        else:
            print("Warning: No valid weather_forecast found!")
            return
        outdoor_temp = current_weather_forecast["current_conditions"]["temperature"]
        if self.temp_sensor_registered:
            try:
                indoor_temp = str(int(round(am2302_ths.get_temperature(4))))
                wcd.showText(outdoor_temp + "*", count=1, fps=8)
                wcd.showText(indoor_temp + "*", count=1, fg_color=wcc.GREEN, fps=8)
                wcd.showText(outdoor_temp + "*", count=1, fps=8)
                wcd.showText(indoor_temp + "*", count=1, fg_color=wcc.GREEN, fps=8)
            except:
                print("  Failed to read temperature sensor!")
                wcd.showText(outdoor_temp + "*   " + outdoor_temp + "*   " + outdoor_temp + "*", count=1, fps=8)
        else:
            wcd.showText(outdoor_temp + "*   " + outdoor_temp + "*   " + outdoor_temp + "*", count=1, fps=8)

        time.sleep(1)
コード例 #2
0
ファイル: plugin.py プロジェクト: plotaBot/rpi_wordclock
    def run(self, wcd, wci):
        """
        Displaying expected temperature
        """
        # Get current forecast
        if self.weather_service == 'yahoo':
            current_weather_forecast = pywapi.get_weather_from_yahoo(self.location_id)
        elif self.weather_service == 'weather_dot_com':
            current_weather_forecast = pywapi.get_weather_from_weather_com(self.location_id)
        else:
            print('Warning: No valid weather_forecast found!')
            return
        outdoor_temp = current_weather_forecast['current_conditions']['temperature']
        if self.temp_sensor_registered:
            try:
                indoor_temp = str(int(round(am2302_ths.get_temperature(self.pin_temp_sensor))))
                wcd.showText(outdoor_temp + '*', count=1, fps=8)
                wcd.showText(indoor_temp + '*', count=1, fg_color=wcc.GREEN, fps=8)
                wcd.showText(outdoor_temp + '*', count=1, fps=8)
                wcd.showText(indoor_temp + '*', count=1, fg_color=wcc.GREEN, fps=8)
            except:
                print('  Failed to read temperature sensor!')
                wcd.showText(outdoor_temp + '*   ' + outdoor_temp + '*   ' + outdoor_temp + '*', count=1, fps=8)
        else:
            wcd.showText(outdoor_temp + '*   ' + outdoor_temp + '*   ' + outdoor_temp + '*', count=1, fps=8)

        if wci.waitForExit(1.0):
            return
コード例 #3
0
    def run(self, wcd, wci):
        """
        Displaying expected temperature
        """
        # Get current forecast
        if self.weather_service == 'yahoo':
            current_weather_forecast = pywapi.get_weather_from_yahoo(
                self.location_id)
            outdoor_temp = current_weather_forecast['current_conditions'][
                'temperature']
        elif self.weather_service == 'weather_dot_com':
            current_weather_forecast = pywapi.get_weather_from_weather_com(
                self.location_id)
            outdoor_temp = current_weather_forecast['current_conditions'][
                'temperature']
        elif self.weather_service == 'meteoswiss':
            outdoor_temp = (json.loads(
                requests.get(
                    'https://www.meteoschweiz.admin.ch/product/output/weather-widget/forecast/version__20210514_1034/de/'
                    + zipcode + '00.json',
                    headers={
                        'referer':
                        'https://www.meteoschweiz.admin.ch/home/service-und-publikationen/produkte.html'
                    }).text))['data']['current']['temperature']
        else:
            logging.warning('No valid weather_forecast found!')
            return
        if self.temp_sensor_registered:
            try:
                indoor_temp = str(
                    int(round(am2302_ths.get_temperature(
                        self.pin_temp_sensor))))
                wcd.showText(outdoor_temp + '*', count=1, fps=8)
                wcd.showText(indoor_temp + '*',
                             count=1,
                             fg_color=wcc.GREEN,
                             fps=8)
                wcd.showText(outdoor_temp + '*', count=1, fps=8)
                wcd.showText(indoor_temp + '*',
                             count=1,
                             fg_color=wcc.GREEN,
                             fps=8)
            except:
                logging.error('Failed to read temperature sensor!')
                wcd.showText(outdoor_temp + '*   ' + outdoor_temp + '*   ' +
                             outdoor_temp + '*',
                             count=1,
                             fps=8)
        else:
            wcd.showText(outdoor_temp + '*   ' + outdoor_temp + '*   ' +
                         outdoor_temp + '*',
                         count=1,
                         fps=8)

        if wci.waitForExit(1.0):
            return
コード例 #4
0
ファイル: am2302_rpi.py プロジェクト: vanniuner/wechat-ai
 def _tick(self):
     try:
         temp = am2302_ths.get_temperature(self.INPUT)
         if temp:
             self.last_time = datetime.datetime.now()
             self.temp = temp
         self.timer = threading.Timer(10, self._tick)
         self.timer.start()
     except:
         self.off()
         print("Error reading from sensor.")
コード例 #5
0
    def run(self, wcd, wci):
        """
        Displaying expected temperature
        """
        # Get current forecast
        if self.weather_service == 'yahoo':
            current_weather_forecast = pywapi.get_weather_from_yahoo(
                self.location_id)
        elif self.weather_service == 'weather_dot_com':
            current_weather_forecast = pywapi.get_weather_from_weather_com(
                self.location_id)
        else:
            logging.warning('No valid weather_forecast found!')
            return
        outdoor_temp = current_weather_forecast['current_conditions'][
            'temperature']
        if self.temp_sensor_registered:
            try:
                indoor_temp = str(
                    int(round(am2302_ths.get_temperature(
                        self.pin_temp_sensor))))
                wcd.showText(outdoor_temp + '*', count=1, fps=8)
                wcd.showText(indoor_temp + '*',
                             count=1,
                             fg_color=wcc.GREEN,
                             fps=8)
                wcd.showText(outdoor_temp + '*', count=1, fps=8)
                wcd.showText(indoor_temp + '*',
                             count=1,
                             fg_color=wcc.GREEN,
                             fps=8)
            except:
                logging.error('Failed to read temperature sensor!')
                wcd.showText(outdoor_temp + '*   ' + outdoor_temp + '*   ' +
                             outdoor_temp + '*',
                             count=1,
                             fps=8)
        else:
            wcd.showText(outdoor_temp + '*   ' + outdoor_temp + '*   ' +
                         outdoor_temp + '*',
                         count=1,
                         fps=8)

        if wci.waitForExit(1.0):
            return
コード例 #6
0
ファイル: plugin.py プロジェクト: standi01/rpi_wordclock
    def run(self, wcd, wci):
        '''
        Displaying expected temperature
        '''
        # Get current forecast
        if self.weather_service == 'yahoo':
            current_weather_forecast = pywapi.get_weather_from_yahoo(
                self.location_id)
        elif self.weather_service == 'weather_dot_com':
            current_weather_forecast = pywapi.get_weather_from_weather_com(
                self.location_id)
        else:
            print('Warning: No valid weather_forecast found!')
            return
        outdoor_temp = current_weather_forecast['current_conditions'][
            'temperature']
        if self.temp_sensor_registered:
            try:
                indoor_temp = str(int(round(am2302_ths.get_temperature(4))))
                wcd.showText(outdoor_temp + '*', count=1, fps=8)
                wcd.showText(indoor_temp + '*',
                             count=1,
                             fg_color=wcc.GREEN,
                             fps=8)
                wcd.showText(outdoor_temp + '*', count=1, fps=8)
                wcd.showText(indoor_temp + '*',
                             count=1,
                             fg_color=wcc.GREEN,
                             fps=8)
            except:
                print('  Failed to read temperature sensor!')
                wcd.showText(outdoor_temp + '*   ' + outdoor_temp + '*   ' +
                             outdoor_temp + '*',
                             count=1,
                             fps=8)
        else:
            wcd.showText(outdoor_temp + '*   ' + outdoor_temp + '*   ' +
                         outdoor_temp + '*',
                         count=1,
                         fps=8)

        time.sleep(1)
コード例 #7
0
def get_stats():
    # temperature = randint(1, 100)
    # humidity = randint(1, 100)
    temperature = am.get_temperature(PIN)
    humidity = am.get_humidity(PIN)
    return temperature, humidity
コード例 #8
0
ファイル: zelenaSoba.py プロジェクト: TomazLicen/ZelenaSoba
  if tenMinutesRun!=tenMinutes:
    if tenMinutes: 
      handle_light()
      handle_heating()
      handle_pomp()
      handle_pomp2()
  tenMinutesRun=tenMinutes

t=None; h=None; moisture=False;

GPIO.setup(LED1, LedOFF)
handle_light()

while True: # Main loop begin
  if blinkTick % NumSensors == 0:
    t=ths.get_temperature(THS);
    if t: # handle empty variable
      temperature=t;
    sleep(0.5)
  if blinkTick % NumSensors == 1:
    h=ths.get_humidity(THS); 
    if h:
      humidity=h;
    sleep(0.5)
  if blinkTick % NumSensors == 2:
    moisture = (GPIO.input(MOIST) == GPIO.LOW)
    sleep(0.5)
    sleep(0.5)
  if blinkTick % 2== 0: #every second tick conditionally turns leds on to blink
    if temperature<stgs.temperature:
      GPIO.setup(LED2, LedON)