Skip to content

Commit

Permalink
fix pylint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mschlenstedt committed Aug 5, 2024
1 parent 503a44b commit e4636bc
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mqtt_io/modules/sensor/tsl2561.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ...types import CerberusSchemaType, ConfigType, SensorValueType
from . import GenericSensor

REQUIREMENTS = ("adafruit-circuitpython-tsl2561",) # type: ignore
REQUIREMENTS = ("adafruit-circuitpython-tsl2561",)
CONFIG_SCHEMA: CerberusSchemaType = {
"chip_addr": {
"type": 'integer',
Expand Down Expand Up @@ -48,7 +48,7 @@ def setup_module(self) -> None:
# pylint: disable=import-error,no-member
import board # type: ignore
import busio # type: ignore
import adafruit_tsl2561
import adafruit_tsl2561 # type: ignore
# Create the I2C bus
self.i2c = busio.I2C(board.SCL, board.SDA)

Expand All @@ -63,7 +63,6 @@ def setup_module(self) -> None:

self.tsl = adafruit_tsl2561.TSL2561(self.i2c, self.address)


# Set gain 0=1x, 1=16x
if self.config["gain"] == 1:
self.tsl.gain = 0
Expand All @@ -85,15 +84,22 @@ def setup_module(self) -> None:
#print("tsl2561 Integration time = {}".format(self.tsl.integration_time))

def get_value(self, sens_conf: ConfigType) -> SensorValueType:
"""
Get the values from the sensor
"""
# pylint: disable=import-outside-toplevel,attribute-defined-outside-init
# pylint: disable=import-error,no-member
import time

self.tsl.enabled = True
time.sleep(1)

sens_type = sens_conf["type"]
data = {
"broadband": self.tsl.broadband,
"infrared": self.tsl.infrared,
"lux": self.tsl.lux
}

self.tsl.enabled = False

if data[sens_type] is None: # Possible sensor underrange or overrange.
data[sens_type] = -1

Expand Down

0 comments on commit e4636bc

Please sign in to comment.