Skip to content

Commit

Permalink
fix new pylint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjiU committed Jul 28, 2024
1 parent 2f632dc commit 046d59d
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 151 deletions.
57 changes: 57 additions & 0 deletions mqtt_io/modules/gpio/sunxi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
Sunxi Board
"""
from typing import Optional
from ...types import ConfigType, PinType
from . import GenericGPIO, PinDirection, PinPUD

REQUIREMENTS = ("pySUNXI",)

class GPIO(GenericGPIO):
"""
Implementation of GPIO class for Sunxi native GPIO.
"""
def setup_module(self) -> None:
# pylint: disable=import-outside-toplevel,import-error
from pySUNXI import gpio

self.io: gpio = gpio
self.direction_map = {PinDirection.INPUT: gpio.INPUT, PinDirection.OUTPUT: gpio.OUTPUT}

self.pullup_map = {
PinPUD.OFF: gpio.PULLNONE,
PinPUD.UP: gpio.PULLUP,
PinPUD.DOWN: gpio.PULLDOWN,
}
gpio.init()

def setup_pin(
self,
pin: PinType,
direction: PinDirection,
pullup: PinPUD,
pin_config: ConfigType,
initial: Optional[str] = None,
) -> None:
direction = self.direction_map[direction]

if pullup is None:
pullup = self.pullup_map[PinPUD.OFF]
else:
pullup = self.pullup_map[pullup]

initial = {None: -1, "low": 0, "high": 1}[pin_config.get("initial")]
#self.io.setup(pin, direction, pull_up_down=pullup, initial=initial)
self.io.setcfg(pin, direction)
self.io.pullup(pin, pullup)
if direction==self.io.OUTPUT:
self.io.output(pin, initial)

def set_pin(self, pin, value):
self.io.output(pin, value)

def get_pin(self, pin):
return self.io.input(pin)

def cleanup(self):
pass
16 changes: 8 additions & 8 deletions mqtt_io/modules/sensor/bmp085.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

REQUIREMENTS = ("Adafruit_BMP",)
CONFIG_SCHEMA: CerberusSchemaType = {
"chip_addr": dict(type="integer", required=True, empty=False),
"chip_addr": {"type": 'integer', "required": True, "empty": False},
}
DATA_READER = {
"temperature": lambda bmp: bmp.read_temperature(),
Expand All @@ -24,13 +24,13 @@ class Sensor(GenericSensor):
"""

SENSOR_SCHEMA: CerberusSchemaType = {
"type": dict(
type="string",
required=False,
empty=False,
default="temperature",
allowed=["temperature", "pressure", "altitude"],
)
"type": {
"type": 'string',
"required": False,
"empty": False,
"default": 'temperature',
"allowed": ['temperature', 'pressure', 'altitude'],
}
}

def setup_module(self) -> None:
Expand Down
49 changes: 26 additions & 23 deletions mqtt_io/modules/sensor/ens160.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,24 @@

REQUIREMENTS = ("adafruit-circuitpython-ens160",)
CONFIG_SCHEMA: CerberusSchemaType = {
"chip_addr": dict(
type="integer", required=False, empty=False, default=DEFAULT_CHIP_ADDR
),
"temperature_compensation": dict(
type="float",
required=False,
empty=False,
default=DEFAULT_TEMPERATURE_COMPENSATION,
),
"humidity_compensation": dict(
type="float",
required=False,
empty=False,
default=DEFAULT_HUMIDITY_COMPENSATION,
),
"chip_addr": {
"type": 'integer',
"required": False,
"empty": False,
"default": 'DEFAULT_CHIP_ADDR',
},
"temperature_compensation": {
"type": 'float',
"required": False,
"empty": False,
"default": 'DEFAULT_TEMPERATURE_COMPENSATION',
},
"humidity_compensation": {
"type": 'float',
"required": False,
"empty": False,
"default": 'DEFAULT_HUMIDITY_COMPENSATION',
},
}


Expand All @@ -81,13 +84,13 @@ class Sensor(GenericSensor):
"""

SENSOR_SCHEMA: CerberusSchemaType = {
"type": dict(
type="string",
required=False,
empty=False,
default="aqi",
allowed=["aqi", "tvoc", "eco2"],
),
"type": {
"type": 'string',
"required": False,
"empty": False,
"default": 'aqi',
"allowed": ['aqi', 'tvoc', 'eco2'],
},
}

def setup_module(self) -> None:
Expand Down Expand Up @@ -119,7 +122,7 @@ def get_value(self, sens_conf: ConfigType) -> float:
sens_type = sens_conf["type"]
return cast(
int,
dict(aqi=self.ens160.AQI, tvoc=self.ens160.TVOC, eco2=self.ens160.eCO2)[
{"aqi": self.ens160.AQI, "tvoc": self.ens160.TVOC, "eco2": self.ens160.eCO2}[
sens_type
],
)
6 changes: 3 additions & 3 deletions mqtt_io/modules/sensor/mhz19.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

REQUIREMENTS = ("pyserial",)
CONFIG_SCHEMA: CerberusSchemaType = {
"device": dict(type="string", required=True, empty=False),
"range": dict(type="integer", required=False, empty=False, default=5000,
allowed=[2000, 5000, 10000]),
"device": {"type": 'string', "required": True, "empty": False},
"range": {"type": 'integer', "required": False, "empty": False, "default": 5000,
"allowed": [2000, 5000, 10000]},
}

class Sensor(GenericSensor):
Expand Down
10 changes: 5 additions & 5 deletions mqtt_io/modules/sensor/yfs201.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class Sensor(GenericSensor):
"""

SENSOR_SCHEMA: CerberusSchemaType = {
"pin": dict(
type="integer",
required=True,
empty=False,
)
"pin": {
"type": 'integer',
"required": True,
"empty": False,
}
}

def setup_module(self) -> None:
Expand Down
61 changes: 0 additions & 61 deletions pi_mqtt_gpio/modules/bme280.py

This file was deleted.

51 changes: 0 additions & 51 deletions pi_mqtt_gpio/modules/sunxi.py

This file was deleted.

0 comments on commit 046d59d

Please sign in to comment.