Skip to content

Commit

Permalink
fixing pylint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjiU authored Jul 31, 2024
1 parent c5a79de commit 0afb556
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions mqtt_io/modules/sensor/veml6075.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
VEML 6075 UV sensor
"""

import logging
from mqtt_io.types import ConfigType, SensorValueType
from . import GenericSensor
import logging

REQUIREMENTS = ("smbus2", "veml6075",)

Expand All @@ -14,7 +14,8 @@


# UV COEFFICIENTS AND RESPONSIVITY
# See https://web.archive.org/web/20190416120825/http://www.vishay.com/docs/84339/designingveml6075.pdf
# See https://web.archive.org/web/20190416120825/
# http://www.vishay.com/docs/84339/designingveml6075.pdf
# For more details
##################################################################################
# Configuration # a # b # c # d # UVAresp # UVBresp #
Expand Down Expand Up @@ -49,7 +50,7 @@ class Sensor(GenericSensor):
"UVAresp": {"type": "float", "required": False, "empty": False, "default": 0.001461},
"UVBresp": {"type": "float", "required": False, "empty": False, "default": 0.002591},
}

def setup_module(self) -> None:
# pylint: disable=import-outside-toplevel,import-error
from smbus2 import SMBus # type: ignore
Expand All @@ -60,15 +61,19 @@ def setup_module(self) -> None:


def calculate_uv_index(self, sens_conf, uva, uvb, uv_comp1, uv_comp2) -> float:

uva_calc = uva - ((sens_conf["a"] * sens_conf["alpha"] * uv_comp1) / sens_conf["gamma"]) - ((sens_conf["b"] * sens_conf["alpha"] * uv_comp2) / sens_conf["delta"])
_LOG.info("uva_calc " + str(uva_calc))
uvb_calc = uvb - ((sens_conf["c"] * sens_conf["beta"] * uv_comp1) / sens_conf["gamma"]) - ((sens_conf["d"] * sens_conf["beta"] * uv_comp2) / sens_conf["delta"])
_LOG.info("uvb_calc " + str(uvb_calc))
"""
Calculate uv index from given values
"""
uva_calc = uva - ((sens_conf["a"] * sens_conf["alpha"] * uv_comp1) / sens_conf["gamma"]) -
((sens_conf["b"] * sens_conf["alpha"] * uv_comp2) / sens_conf["delta"])
_LOG.debug("uva_calc %s", str(uva_calc))
uvb_calc = uvb - ((sens_conf["c"] * sens_conf["beta"] * uv_comp1) / sens_conf["gamma"]) -
((sens_conf["d"] * sens_conf["beta"] * uv_comp2) / sens_conf["delta"])
_LOG.debug("uvb_calc %s", str(uvb_calc))
uva_index = uva_calc * (1 / sens_conf["alpha"]) * sens_conf["UVAresp"]
_LOG.info("uva_index " + str(uva_index))
_LOG.debug("uva_index %s", str(uva_index))
uvb_index = uvb_calc * (1 / sens_conf["beta"]) * sens_conf["UVBresp"]
_LOG.info("uvb_index " + str(uvb_index))
_LOG.debug("uvb_index %s", str(uvb_index))
uv_index = (uva_index + uvb_index) / 2
return uv_index

Expand Down

0 comments on commit 0afb556

Please sign in to comment.