Skip to content

Commit 0879a57

Browse files
committed
actually load the toml
1 parent e0dfe57 commit 0879a57

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

fake_bme280/basic.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"""
2828
import math
2929
import os
30+
import toml
3031
import socket as pool
3132
import ssl
3233
import typing # pylint: disable=unused-import
@@ -75,17 +76,19 @@
7576
_BME280_REGISTER_TEMPDATA = const(0xFA)
7677
_BME280_REGISTER_HUMIDDATA = const(0xFD)
7778

79+
# Load the settings.toml file
80+
config = toml.load("settings.toml")
81+
7882
# OpenWeatherMap API
7983
# GET weather data for a specific location
80-
# TODO: this could be cleaned up a bit..
8184
DATA_SOURCE = (
8285
"http://api.openweathermap.org/data/2.5/weather?q="
83-
+ os.getenv("openweather_location")
86+
+ config["openweather_location"]
8487
+ "&units="
85-
+ os.getenv("openweather_units")
88+
+ config["openweather_units"]
8689
+ "&mode=json"
8790
+ "&appid="
88-
+ os.getenv("openweather_token")
91+
+ config["openweather_token"]
8992
)
9093

9194

@@ -113,11 +116,6 @@ def __init__(self, bus_implementation: typing.Union[I2C_Impl, SPI_Impl]) -> None
113116
self.sea_level_pressure = 1013.25
114117
"""Pressure in hectoPascals at sea level. Used to calibrate `altitude`."""
115118
self._t_fine = None
116-
# Configure OpenWeather for mock data
117-
self.openweather_token = os.getenv("OPENWEATHER_TOKEN", "default_token")
118-
self.openweather_location = os.getenv(
119-
"OPENWEATHER_LOCATION", "default_location"
120-
)
121119
# Configure a CPython adafruit_requests session
122120
self.requests = adafruit_requests.Session(pool, ssl.create_default_context())
123121
self._current_forcast = None

fake_bme280/protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, i2c: I2C, address: int) -> None:
1616
i2c_device,
1717
)
1818

19-
self._i2c = i2c_device.I2CDevice(i2c, address)
19+
# self._i2c = i2c_device.I2CDevice(i2c, address)
2020

2121

2222
class SPI_Impl:

0 commit comments

Comments
 (0)