Skip to content

Commit 304409b

Browse files
theyoshgithub-actions[bot]
authored andcommitted
Python code is blacked
1 parent 4974dd1 commit 304409b

File tree

8 files changed

+19
-22
lines changed

8 files changed

+19
-22
lines changed

hardware/io_expander.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# pip install i2crelay (git)
88
from i2crelay import I2CRelayBoard
9+
910
# pip install pcf8575
1011
from pcf8575 import PCF8575
1112

@@ -98,11 +99,11 @@ class terrariumPCF8575IOExpander(terrariumIOExpander):
9899
# Keep own internal state
99100
# Relays starting at number 1 (human counting)
100101
def __set_relay(self, port, action):
101-
self.__internal_state[port-1] = action
102+
self.__internal_state[port - 1] = action
102103
self.__device.port = self.__internal_state
103104

104105
def __get_relay(self, port):
105-
return self.__internal_state[port-1]
106+
return self.__internal_state[port - 1]
106107

107108
def _load_device(self, address):
108109
device = PCF8575(address[1], address[0])
@@ -122,4 +123,4 @@ def is_on(self, port):
122123
return self.__get_relay(port) == True
123124

124125
def is_off(self, port):
125-
return not self.is_on(port)
126+
return not self.is_on(port)

hardware/relay/8relay-stack_relay.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ def _load_hardware(self):
4545
return (int(address[1]), int(address[0]))
4646

4747
def _set_hardware_value(self, state):
48-
(device, nr) = self.device
48+
device, nr = self.device
4949
self._device_set(device, nr, 1 if state == self.ON else 0)
5050
return True
5151

5252
def _get_hardware_value(self):
53-
(device, nr) = self.device
53+
device, nr = self.device
5454
data = self._device_get(device, nr)
5555
if data is None:
5656
return None

hardware/relay/ftdi_relay.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _load_hardware(self):
5757
return (serial, device_type)
5858

5959
def _set_hardware_value(self, state):
60-
(serial, device_type) = self.device
60+
serial, device_type = self.device
6161

6262
if device_type == terrariumRelayFTDI.SERIAL:
6363
with SerialDevice(serial) as device:
@@ -99,7 +99,7 @@ def testBit(int_type, offset):
9999
return testBit(data, 8)
100100

101101
data = None
102-
(serial, device_type) = self.device
102+
serial, device_type = self.device
103103
if device_type == terrariumRelayFTDI.SERIAL:
104104
# As we cannot read out this device, we borrow the current state as the new state....
105105
data = 1 if self.state == self.ON else 0

hardware/sensor/as7331_sensor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
import board
1111
import iorodeo_as7331 as as7331
1212

13+
1314
class terrariumAS7331Sensor(terrariumI2CSensor):
1415
HARDWARE = "AS7331"
1516
TYPES = ["uva", "uvb", "uvc", "temperature"]
1617
NAME = "AS7331 UVA, UVB, UVC light and temperature sensor"
1718

1819
def _load_hardware(self):
1920
i2c = board.I2C()
20-
device = as7331.AS7331(i2c,self._address[1])
21+
device = as7331.AS7331(i2c, self._address[1])
2122

2223
device.gain = as7331.GAIN_512X
2324
device.integration_time = as7331.INTEGRATION_TIME_128MS
@@ -26,7 +27,6 @@ def _load_hardware(self):
2627

2728
def _get_data(self):
2829
uva, uvb, uvc, temp = self.device.values
29-
data = {"uva": uva, "uvb": uvb, "uvc" : uvc, "temperature": temp}
30+
data = {"uva": uva, "uvb": uvb, "uvc": uvc, "temperature": temp}
3031

3132
return data
32-

hardware/webcam/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,10 @@ def motion_capture(self, motion_frame="last", motion_threshold=25, motion_area=5
621621

622622
# Different OpenCV versions (docker vs native)
623623
try:
624-
(cnts, _) = cv2.findContours(threshold.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
624+
cnts, _ = cv2.findContours(threshold.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
625625
except Exception as ex:
626626
logger.debug(f"Wrong CV2 version. Retry: {ex}")
627-
(_, cnts, _) = cv2.findContours(threshold.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
627+
_, cnts, _ = cv2.findContours(threshold.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
628628

629629
# don't draw if motion boxes is disabled
630630
# Color Red and Blue are swapped... very strange...
@@ -648,7 +648,7 @@ def motion_capture(self, motion_frame="last", motion_threshold=25, motion_area=5
648648
motion_detected = True
649649
# compute the bounding box for the contour, draw it on the frame with the selected color,
650650
if box_color is not None:
651-
(x, y, w, h) = cv2.boundingRect(c)
651+
x, y, w, h = cv2.boundingRect(c)
652652
cv2.rectangle(raw_image, (x, y), (x + w, y + h), box_color, 2)
653653

654654
if motion_detected:

terrariumAudio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def available_soundcards(__cls__):
2222
soundcards = []
2323
for i in alsaaudio.card_indexes():
2424
try:
25-
(_, longname) = alsaaudio.card_name(i)
25+
_, longname = alsaaudio.card_name(i)
2626
soundcards.append({"index": int(i), "name": longname})
2727

2828
except Exception as ex:

terrariumEngine.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,8 +2011,7 @@ def total_power_and_water_usage(self, force=False, background=False, thread_retu
20112011
else:
20122012
# We are using total() vs sum() as total() will always return a number. https://sqlite.org/lang_aggfunc.html#sumunc
20132013
with orm.db_session():
2014-
data = db.select(
2015-
"""SELECT
2014+
data = db.select("""SELECT
20162015
TOTAL(total_wattage) AS wattage,
20172016
TOTAL(total_flow) AS flow,
20182017
IFNULL((JulianDay(MAX(off)) - JulianDay(MIN(`on`))) * 24 * 60 * 60,0) AS duration
@@ -2029,8 +2028,7 @@ def total_power_and_water_usage(self, force=False, background=False, thread_retu
20292028
ON RH2.relay = RH1.relay
20302029
AND RH2.timestamp = (SELECT MIN(timestamp) FROM RelayHistory WHERE timestamp > RH1.timestamp AND relay = RH1.relay)
20312030
WHERE RH1.value > 0
2032-
)"""
2033-
)
2031+
)""")
20342032

20352033
totals = {"total_watt": data[0][0], "total_flow": data[0][1], "duration": data[0][2]}
20362034
thread_return[0] = totals

terrariumNotification.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,17 +2675,15 @@ async def area(self, update, context, enclosure_id=None):
26752675

26762676
async def help(self, update, context):
26772677
if await self._authenticate(update.message):
2678-
await update.message.reply_text(
2679-
"""The following commands are supported:
2678+
await update.message.reply_text("""The following commands are supported:
26802679
26812680
/start : This will start listening for notifications.
26822681
/webcam [webcam_id] : will show the latest image of the webcam ID.
26832682
/sensor [sensor_id] : will show the current sensor state. Sensor id is optional.
26842683
/relay [relay_id] : will show the current relay state. Relay id is optional.
26852684
/button [button_id] : will show the current button state. button id is optional.
26862685
/enclosure [enclosure_id] : will show the current area state of the enclosure ID
2687-
/status : will show the current system status."""
2688-
)
2686+
/status : will show the current system status.""")
26892687

26902688
# function to handle normal text
26912689
async def text(self, update, context):

0 commit comments

Comments
 (0)