diff --git a/fake_bme280/basic.py b/fake_bme280/basic.py index 223191e..8224e08 100644 --- a/fake_bme280/basic.py +++ b/fake_bme280/basic.py @@ -26,10 +26,10 @@ https://circuitpython.org/downloads """ import math -import os import socket as pool import ssl import typing # pylint: disable=unused-import +import toml from micropython import const import adafruit_requests from fake_bme280.protocol import I2C_Impl, SPI_Impl @@ -75,17 +75,19 @@ _BME280_REGISTER_TEMPDATA = const(0xFA) _BME280_REGISTER_HUMIDDATA = const(0xFD) +# Load the settings.toml file +toml_config = toml.load("settings.toml") + # OpenWeatherMap API # GET weather data for a specific location -# TODO: this could be cleaned up a bit.. DATA_SOURCE = ( "http://api.openweathermap.org/data/2.5/weather?q=" - + os.getenv("openweather_location") + + toml_config["openweather_location"] + "&units=" - + os.getenv("openweather_units") + + toml_config["openweather_units"] + "&mode=json" + "&appid=" - + os.getenv("openweather_token") + + toml_config["openweather_token"] ) @@ -113,11 +115,6 @@ def __init__(self, bus_implementation: typing.Union[I2C_Impl, SPI_Impl]) -> None self.sea_level_pressure = 1013.25 """Pressure in hectoPascals at sea level. Used to calibrate `altitude`.""" self._t_fine = None - # Configure OpenWeather for mock data - self.openweather_token = os.getenv("OPENWEATHER_TOKEN", "default_token") - self.openweather_location = os.getenv( - "OPENWEATHER_LOCATION", "default_location" - ) # Configure a CPython adafruit_requests session self.requests = adafruit_requests.Session(pool, ssl.create_default_context()) self._current_forcast = None diff --git a/fake_bme280/protocol.py b/fake_bme280/protocol.py index 717513d..aa1f409 100644 --- a/fake_bme280/protocol.py +++ b/fake_bme280/protocol.py @@ -10,13 +10,13 @@ class I2C_Impl: "Protocol implementation for the I2C bus." - # pylint: disable=too-few-public-methods + # pylint: disable=too-few-public-methods, unused-argument, unused-import def __init__(self, i2c: I2C, address: int) -> None: from adafruit_bus_device import ( # pylint: disable=import-outside-toplevel i2c_device, ) - self._i2c = i2c_device.I2CDevice(i2c, address) + # self._i2c = i2c_device.I2CDevice(i2c, address) class SPI_Impl: