From dc8d4d2dd7cc046d5f3e0470911189b7a6cc0aff Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Wed, 28 Oct 2020 20:08:28 +0100 Subject: [PATCH 01/28] Codespell and flake8 warnings - including new todos for complex code --- CHANGELOG.md | 2 +- plugwise/connections/connection.py | 14 ++-- plugwise/connections/serial.py | 11 +-- plugwise/connections/socket.py | 2 +- plugwise/constants.py | 44 +++++++++--- plugwise/message.py | 8 +-- plugwise/messages/requests.py | 23 +++--- plugwise/messages/responses.py | 8 ++- plugwise/node.py | 38 +++++----- plugwise/nodes/circle.py | 24 +++---- plugwise/nodes/circle_plus.py | 2 +- plugwise/nodes/scan.py | 13 ++-- plugwise/nodes/sed.py | 10 ++- plugwise/nodes/sense.py | 2 +- plugwise/nodes/switch.py | 8 +-- plugwise/parser.py | 58 ++++++++-------- plugwise/smile.py | 21 +++--- plugwise/stick.py | 108 ++++++++++++++++------------- plugwise/util.py | 17 +++-- setup.py | 2 +- tests/INIT.md | 2 +- tests/test_smile.py | 7 +- 22 files changed, 219 insertions(+), 205 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9daca85b..2349a6ffc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -149,7 +149,7 @@ Changelogs below this line are separated in the former python-plugwise USB-only - Testing improvements - `dhw`-handling -## formerSmile#0.1.24 - Add handling erronous XML and/or timeouts +## formerSmile#0.1.24 - Add handling erroneous XML and/or timeouts - Favour exception raises above returning `False` - Restructure full device update accordingly - Add Plugwise Exceptions diff --git a/plugwise/connections/connection.py b/plugwise/connections/connection.py index 1c96d511a..b4b6ab290 100644 --- a/plugwise/connections/connection.py +++ b/plugwise/connections/connection.py @@ -14,7 +14,7 @@ _LOGGER = logging.getLogger(__name__) -class StickConnection(object): +class StickConnection: """ Generic Plugwise stick connection""" def __init__(self, port, stick=None): @@ -44,18 +44,18 @@ def _open_connection(self): def _reader_start(self, name): """Start the reader thread to receive data""" - self._reader_thread = threading.Thread(None, self._reader_deamon, name, (), {}) + self._reader_thread = threading.Thread(None, self._reader_daemon, name, (), {}) self.run_reader_thread = True self._reader_thread.start() - def _reader_deamon(self): + def _reader_daemon(self): """Thread to collect available data from connection""" while self.run_reader_thread: data = self._read_data() if data: self.stick.feed_parser(data) time.sleep(0.01) - _LOGGER.debug("Reader deamon stopped") + _LOGGER.debug("Reader daemon stopped") def _read_data(self): """Placeholder to receive message from the connection""" @@ -68,12 +68,12 @@ def _read_data(self): def _writer_start(self, name: str): """Start the writer thread to send data""" self._write_queue = queue.Queue() - self._writer_thread = threading.Thread(None, self._writer_deamon, name, (), {}) + self._writer_thread = threading.Thread(None, self._writer_daemon, name, (), {}) self._writer_thread.daemon = True self.run_writer_thread = True self._writer_thread.start() - def _writer_deamon(self): + def _writer_daemon(self): """Thread to write data from queue to existing connection.""" while self.run_writer_thread: try: @@ -90,7 +90,7 @@ def _writer_deamon(self): time.sleep(SLEEP_TIME) if callback: callback() - _LOGGER.debug("Writer deamon stopped") + _LOGGER.debug("Writer daemon stopped") def _write_data(self, data): """Placeholder to write message to the connection""" diff --git a/plugwise/connections/serial.py b/plugwise/connections/serial.py index 8ac830c77..828c08595 100644 --- a/plugwise/connections/serial.py +++ b/plugwise/connections/serial.py @@ -4,16 +4,11 @@ Serial connection """ import logging + import serial -from plugwise.constants import ( - BAUD_RATE, - BYTE_SIZE, - PARITY, - SLEEP_TIME, - STOPBITS, -) from plugwise.connections.connection import StickConnection +from plugwise.constants import BAUD_RATE, BYTE_SIZE, PARITY, SLEEP_TIME, STOPBITS from plugwise.exceptions import PortError from plugwise.message import PlugwiseMessage @@ -81,7 +76,7 @@ def _read_data(self): _LOGGER.debug("Error while reading data from serial port : %s", err) self._is_connected = False raise PortError(err) - except Exception as e: + except Exception as err: _LOGGER.debug("Error _read_data : %s", err) return serial_data return None diff --git a/plugwise/connections/socket.py b/plugwise/connections/socket.py index 0c18cd357..49b204cd3 100644 --- a/plugwise/connections/socket.py +++ b/plugwise/connections/socket.py @@ -6,8 +6,8 @@ import logging import socket -from plugwise.constants import SLEEP_TIME from plugwise.connections.connection import StickConnection +from plugwise.constants import SLEEP_TIME from plugwise.exceptions import PortError from plugwise.message import PlugwiseMessage diff --git a/plugwise/constants.py b/plugwise/constants.py index 467091fe7..3a871f7cb 100644 --- a/plugwise/constants.py +++ b/plugwise/constants.py @@ -65,7 +65,7 @@ # are allowed to drift in seconds MAX_TIME_DRIFT = 30 -# Default sleep time in seconds for watchdog deamon +# Default sleep time in seconds for watchdog daemon WATCHDOG_DEAMON = 60 # Automatically accept new join requests @@ -329,14 +329,40 @@ } SMILES = { - "smile_open_therm_v3": {"type": "thermostat", "friendly_name": "Adam",}, - "smile_open_therm_v2": {"type": "thermostat", "friendly_name": "Adam",}, - "smile_thermo_v4": {"type": "thermostat", "friendly_name": "Anna",}, - "smile_thermo_v3": {"type": "thermostat", "friendly_name": "Anna",}, - "smile_thermo_v1": {"type": "thermostat", "friendly_name": "Anna", "legacy": True,}, - "smile_v4": {"type": "power", "friendly_name": "P1",}, - "smile_v3": {"type": "power", "friendly_name": "P1",}, - "smile_v2": {"type": "power", "friendly_name": "P1", "legacy": True,}, + "smile_open_therm_v3": { + "type": "thermostat", + "friendly_name": "Adam", + }, + "smile_open_therm_v2": { + "type": "thermostat", + "friendly_name": "Adam", + }, + "smile_thermo_v4": { + "type": "thermostat", + "friendly_name": "Anna", + }, + "smile_thermo_v3": { + "type": "thermostat", + "friendly_name": "Anna", + }, + "smile_thermo_v1": { + "type": "thermostat", + "friendly_name": "Anna", + "legacy": True, + }, + "smile_v4": { + "type": "power", + "friendly_name": "P1", + }, + "smile_v3": { + "type": "power", + "friendly_name": "P1", + }, + "smile_v2": { + "type": "power", + "friendly_name": "P1", + "legacy": True, + }, "stretch_v3": {"type": "stretch", "friendly_name": "Stretch", "legacy": True}, "stretch_v2": {"type": "stretch", "friendly_name": "Stretch", "legacy": True}, } diff --git a/plugwise/message.py b/plugwise/message.py index b20b5ab65..24eb91c62 100644 --- a/plugwise/message.py +++ b/plugwise/message.py @@ -4,11 +4,7 @@ Base for Plugwise messages """ -from plugwise.constants import ( - MESSAGE_FOOTER, - MESSAGE_HEADER, - UTF8_DECODE, -) +from plugwise.constants import MESSAGE_FOOTER, MESSAGE_HEADER, UTF8_DECODE from plugwise.util import crc_fun @@ -20,7 +16,7 @@ class ParserError(Exception): pass -class PlugwiseMessage(object): +class PlugwiseMessage: def serialize(self): """ return message in a serialized format that can be sent out on wire diff --git a/plugwise/messages/requests.py b/plugwise/messages/requests.py index 8da22ffc8..2d182fbd6 100644 --- a/plugwise/messages/requests.py +++ b/plugwise/messages/requests.py @@ -3,10 +3,7 @@ All known request messages to be send to plugwise devices """ -from plugwise.constants import ( - MESSAGE_FOOTER, - MESSAGE_HEADER, -) +from plugwise.constants import MESSAGE_FOOTER, MESSAGE_HEADER from plugwise.message import PlugwiseMessage from plugwise.util import ( DateTime, @@ -73,7 +70,7 @@ class NodeAddRequest(NodeRequest): def __init__(self, mac, accept: bool): super().__init__(mac) - accept_value = 1 if accept == True else 0 + accept_value = 1 if accept is True else 0 self.args.append(Int(accept_value, length=2)) # This message has an exceptional format (MAC at end of message) @@ -98,7 +95,7 @@ class NodeAllowJoiningRequest(NodeRequest): def __init__(self, accept: bool): super().__init__("") # TODO: Make sure that '01' means enable, and '00' disable joining - val = 1 if accept == True else 0 + val = 1 if accept is True else 0 self.args.append(Int(val, length=2)) @@ -196,7 +193,7 @@ class CircleSwitchRelayRequest(NodeRequest): def __init__(self, mac, on): super().__init__(mac) - val = 1 if on == True else 0 + val = 1 if on is True else 0 self.args.append(Int(val, length=2)) @@ -299,7 +296,7 @@ class CircleEnableScheduleRequest(NodeRequest): def __init__(self, mac, on): super().__init__(mac) - val = 1 if on == True else 0 + val = 1 if on is True else 0 self.args.append(Int(val, length=2)) # the second parameter is always 0x01 self.args.append(Int(1, length=2)) @@ -348,7 +345,7 @@ class NodeBroadcastGroupSwitchRequest(NodeRequest): def __init__(self, group_mac, switch_state: bool): super().__init__(group_mac) - val = 1 if switch_state == True else 0 + val = 1 if switch_state is True else 0 self.args.append(Int(val, length=2)) @@ -395,7 +392,7 @@ def __init__( stay_active_val = Int(stay_active, length=2) sleep_for_val = Int(sleep_for, length=4) maintenance_interval_val = Int(maintenance_interval, length=4) - val = 1 if sync_clock == True else 0 + val = 1 if sync_clock is True else 0 clock_sync_val = Int(val, length=2) clock_interval_val = Int(clock_interval, length=4) self.args += [ @@ -492,7 +489,7 @@ def __init__(self, mac, reset_timer: int, sensitivity: int, light: bool): reset_timer_value = Int(reset_timer, length=2) # Sensitivity: HIGH(0x14), MEDIUM(0x1E), OFF(0xFF) sensitivity_value = Int(sensitivity, length=2) - light_temp = 1 if light == True else 0 + light_temp = 1 if light is True else 0 light_value = Int(light_temp, length=2) self.args += [ sensitivity_value, @@ -537,6 +534,6 @@ class CircleInitialRelaisStateRequest(NodeRequest): def __init__(self, mac, configure: bool, relais_state: bool): super().__init__(mac) - set_or_get = Int(1 if configure == True else 0, length=2) - relais = Int(1 if relais_state == True else 0, length=2) + set_or_get = Int(1 if configure is True else 0, length=2) + relais = Int(1 if relais_state is True else 0, length=2) self.args += [set_or_get, relais] diff --git a/plugwise/messages/responses.py b/plugwise/messages/responses.py index fcf606fcb..690cdadbd 100644 --- a/plugwise/messages/responses.py +++ b/plugwise/messages/responses.py @@ -4,6 +4,7 @@ All known response messages to be received from plugwise devices """ from datetime import datetime + from plugwise.constants import ( MESSAGE_FOOTER, MESSAGE_HEADER, @@ -20,8 +21,8 @@ RealClockDate, RealClockTime, String, - UnixTimestamp, Time, + UnixTimestamp, ) @@ -65,7 +66,8 @@ def deserialize(self, response): response = response[16:] response = self._parse_params(response) - crc = response[:4] + # TODO: unused crc + # crc = response[:4] if response[4:] != MESSAGE_FOOTER: raise ProtocolError("Invalid message footer") @@ -491,7 +493,7 @@ def __init__(self): class NodeJoinAckResponse(NodeResponse): """ - Notification mesage when node (re)joined existing network again. + Notification message when node (re)joined existing network again. Sent when a SED (re)joins the network e.g. when you reinsert the battery of a Scan Response to: or NodeAddRequest diff --git a/plugwise/node.py b/plugwise/node.py index d48edbf16..9f3476766 100644 --- a/plugwise/node.py +++ b/plugwise/node.py @@ -3,41 +3,41 @@ General node object to control associated plugwise nodes like: Circle+, Circle, Scan, Stealth """ -import logging from datetime import datetime +import logging from plugwise.constants import ( HA_SWITCH, HW_MODELS, SENSOR_AVAILABLE, + SENSOR_PING, SENSOR_RSSI_IN, SENSOR_RSSI_OUT, - SENSOR_PING, SWITCH_RELAY, UTF8_DECODE, ) from plugwise.message import PlugwiseMessage -from plugwise.messages.responses import ( - NodeFeaturesResponse, - NodeInfoResponse, - NodePingResponse, -) from plugwise.messages.requests import ( NodeFeaturesRequest, NodeInfoRequest, NodePingRequest, ) +from plugwise.messages.responses import ( + NodeFeaturesResponse, + NodeInfoResponse, + NodePingResponse, +) from plugwise.util import validate_mac _LOGGER = logging.getLogger(__name__) -class PlugwiseNode(object): +class PlugwiseNode: """ Base class for a Plugwise node """ def __init__(self, mac, address, stick): mac = mac.upper() - if validate_mac(mac) == False: + if validate_mac(mac) is False: _LOGGER.debug( "MAC address is in unexpected format: %s", str(mac), @@ -87,7 +87,7 @@ def is_sed(self) -> bool: return False def get_categories(self) -> tuple: - """ Return Home Assistant catagories supported by plugwise node """ + """ Return Home Assistant categories supported by plugwise node """ return self.categories def get_sensors(self) -> tuple: @@ -104,8 +104,8 @@ def get_available(self) -> bool: def set_available(self, state, request_info=False): """ Set current network state of plugwise node """ - if state == True: - if self._available == False: + if state is True: + if self._available is False: self._available = True _LOGGER.debug( "Mark node %s available", @@ -115,7 +115,7 @@ def set_available(self, state, request_info=False): if request_info: self._request_info() else: - if self._available == True: + if self._available is True: self._available = False _LOGGER.debug( "Mark node %s unavailable", @@ -133,13 +133,13 @@ def get_name(self) -> str: def get_hardware_version(self) -> str: """Return hardware version""" - if self._hardware_version != None: + if self._hardware_version is not None: return self._hardware_version return "Unknown" def get_firmware_version(self) -> str: """Return firmware version""" - if self._firmware_version != None: + if self._firmware_version is not None: return str(self._firmware_version) return "Unknown" @@ -149,19 +149,19 @@ def get_last_update(self) -> datetime: def get_in_RSSI(self) -> int: """Return inbound RSSI level""" - if self.in_RSSI != None: + if self.in_RSSI is not None: return self.in_RSSI return 0 def get_out_RSSI(self) -> int: """Return outbound RSSI level""" - if self.out_RSSI != None: + if self.out_RSSI is not None: return self.out_RSSI return 0 def get_ping(self) -> int: """Return ping roundtrip""" - if self.ping_ms != None: + if self.ping_ms is not None: return self.ping_ms return 0 @@ -192,7 +192,7 @@ def on_message(self, message): """ assert isinstance(message, PlugwiseMessage) if message.mac == self.mac: - if message.timestamp != None: + if message.timestamp is not None: _LOGGER.debug( "Last update %s of node %s, last message %s", str(self.last_update), diff --git a/plugwise/nodes/circle.py b/plugwise/nodes/circle.py index 04fbbd5f1..ba5c48c8c 100644 --- a/plugwise/nodes/circle.py +++ b/plugwise/nodes/circle.py @@ -3,31 +3,30 @@ Plugwise Circle node object """ -import logging from datetime import date, datetime, timedelta +import logging from plugwise.constants import ( ACK_OFF, ACK_ON, + HA_SENSOR, + HA_SWITCH, MAX_TIME_DRIFT, + PULSES_PER_KW_SECOND, SENSOR_AVAILABLE, SENSOR_PING, - SENSOR_POWER_USE, - SENSOR_POWER_USE_LAST_8_SEC, SENSOR_POWER_CONSUMPTION_CURRENT_HOUR, SENSOR_POWER_CONSUMPTION_PREVIOUS_HOUR, SENSOR_POWER_CONSUMPTION_TODAY, SENSOR_POWER_CONSUMPTION_YESTERDAY, SENSOR_POWER_PRODUCTION_CURRENT_HOUR, SENSOR_POWER_PRODUCTION_PREVIOUS_HOUR, + SENSOR_POWER_USE, + SENSOR_POWER_USE_LAST_8_SEC, SENSOR_RSSI_IN, SENSOR_RSSI_OUT, SWITCH_RELAY, - HA_SWITCH, - HA_SENSOR, - PULSES_PER_KW_SECOND, ) -from plugwise.node import PlugwiseNode from plugwise.message import PlugwiseMessage from plugwise.messages.requests import ( CircleCalibrationRequest, @@ -40,11 +39,12 @@ from plugwise.messages.responses import ( CircleCalibrationResponse, CircleClockResponse, + CirclePlusScanResponse, CirclePowerBufferResponse, CirclePowerUsageResponse, - CirclePlusScanResponse, NodeAckLargeResponse, ) +from plugwise.node import PlugwiseNode from plugwise.util import Int _LOGGER = logging.getLogger(__name__) @@ -325,9 +325,9 @@ def pulses_to_kWs(self, pulses, seconds=1): def _request_power_buffer(self, log_address=None, callback=None): """Request power log of specified address""" - if log_address == None: + if log_address is None: log_address = self._last_log_address - if log_address != None: + if log_address is not None: if bool(self.power_history): # Only request last 2 power buffer logs self.stick.send( @@ -357,7 +357,7 @@ def _response_power_buffer(self, message): self._last_log_collected = True # Collect logged power usage for i in range(1, 5): - if getattr(message, "logdate%d" % (i,)).value != None: + if getattr(message, "logdate%d" % (i,)).value is not None: dt = getattr(message, "logdate%d" % (i,)).value if getattr(message, "pulses%d" % (i,)).value == 0: self.power_history[dt] = 0.0 @@ -437,7 +437,7 @@ def set_clock(self, callback=None): def sync_clock(self, max_drift=0): """Resync clock of node if time has drifted more than MAX_TIME_DRIFT""" - if self._clock_offset != None: + if self._clock_offset is not None: if max_drift == 0: max_drift = MAX_TIME_DRIFT if (self._clock_offset > max_drift) or (self._clock_offset < -(max_drift)): diff --git a/plugwise/nodes/circle_plus.py b/plugwise/nodes/circle_plus.py index 07bce2389..0f19b378b 100644 --- a/plugwise/nodes/circle_plus.py +++ b/plugwise/nodes/circle_plus.py @@ -155,7 +155,7 @@ def set_real_time_clock(self, callback=None): def sync_realtime_clock(self, max_drift=0): """Sync real time clock of node if time has drifted more than max drifted""" - if self._realtime_clock_offset != None: + if self._realtime_clock_offset is not None: if max_drift == 0: max_drift = MAX_TIME_DRIFT if (self._realtime_clock_offset > max_drift) or ( diff --git a/plugwise/nodes/scan.py b/plugwise/nodes/scan.py index d0917cd3b..d73b6faf0 100644 --- a/plugwise/nodes/scan.py +++ b/plugwise/nodes/scan.py @@ -11,24 +11,21 @@ HA_SENSOR, NACK_SCAN_PARAMETERS_SET, SCAN_DAYLIGHT_MODE, + SCAN_MOTION_RESET_TIMER, + SCAN_SENSITIVITY, SCAN_SENSITIVITY_HIGH, SCAN_SENSITIVITY_MEDIUM, SCAN_SENSITIVITY_OFF, - SCAN_MOTION_RESET_TIMER, - SCAN_SENSITIVITY, SENSOR_AVAILABLE, + SENSOR_MOTION, SENSOR_PING, SENSOR_RSSI_IN, SENSOR_RSSI_OUT, - SENSOR_MOTION, ) -from plugwise.nodes.sed import NodeSED from plugwise.message import PlugwiseMessage +from plugwise.messages.requests import ScanConfigureRequest, ScanLightCalibrateRequest from plugwise.messages.responses import NodeAckResponse, NodeSwitchGroupResponse -from plugwise.messages.requests import ( - ScanConfigureRequest, - ScanLightCalibrateRequest, -) +from plugwise.nodes.sed import NodeSED _LOGGER = logging.getLogger(__name__) diff --git a/plugwise/nodes/sed.py b/plugwise/nodes/sed.py index 1d1d0069b..a1c454919 100644 --- a/plugwise/nodes/sed.py +++ b/plugwise/nodes/sed.py @@ -3,7 +3,7 @@ Plugwise SED (Sleeping Endpoint Device) base object -TODO: +TODO: - Expose awake state as sensor - Set available state after 2 missed awake messages @@ -28,14 +28,14 @@ SENSOR_RSSI_IN, SENSOR_RSSI_OUT, ) -from plugwise.node import PlugwiseNode from plugwise.message import PlugwiseMessage -from plugwise.messages.responses import NodeAckLargeResponse, NodeAwakeResponse from plugwise.messages.requests import ( NodeInfoRequest, NodePingRequest, NodeSleepConfigRequest, ) +from plugwise.messages.responses import NodeAckLargeResponse, NodeAwakeResponse +from plugwise.node import PlugwiseNode _LOGGER = logging.getLogger(__name__) @@ -94,9 +94,7 @@ def _process_awake_response(self, message): self._SED_requests = {} else: if message.awake_type.value == SED_AWAKE_STATE: - _LOGGER.debug( - "Node %s awake for state change", self.get_mac() - ) + _LOGGER.debug("Node %s awake for state change", self.get_mac()) else: _LOGGER.info( "Unknown awake message type (%s) received for node %s", diff --git a/plugwise/nodes/sense.py b/plugwise/nodes/sense.py index ba09396de..565bf23be 100644 --- a/plugwise/nodes/sense.py +++ b/plugwise/nodes/sense.py @@ -18,9 +18,9 @@ SENSOR_RSSI_OUT, SENSOR_TEMPERATURE, ) -from plugwise.nodes.sed import NodeSED from plugwise.message import PlugwiseMessage from plugwise.messages.responses import SenseReportResponse +from plugwise.nodes.sed import NodeSED _LOGGER = logging.getLogger(__name__) diff --git a/plugwise/nodes/switch.py b/plugwise/nodes/switch.py index 21d21ff34..a2843c331 100644 --- a/plugwise/nodes/switch.py +++ b/plugwise/nodes/switch.py @@ -5,13 +5,9 @@ """ import logging -from plugwise.constants import ( - HA_BINARY_SENSOR, - HA_SENSOR, - SENSOR_SWITCH, -) -from plugwise.nodes.sed import NodeSED +from plugwise.constants import HA_BINARY_SENSOR, HA_SENSOR, SENSOR_SWITCH from plugwise.messages.responses import NodeSwitchGroupResponse +from plugwise.nodes.sed import NodeSED _LOGGER = logging.getLogger(__name__) diff --git a/plugwise/parser.py b/plugwise/parser.py index f47a705b4..12b7e4964 100644 --- a/plugwise/parser.py +++ b/plugwise/parser.py @@ -2,40 +2,35 @@ import logging -from plugwise.constants import ( - MESSAGE_FOOTER, - MESSAGE_HEADER, -) +from plugwise.constants import MESSAGE_FOOTER, MESSAGE_HEADER from plugwise.message import PlugwiseMessage -from plugwise.messages.responses import ( - CircleCalibrationResponse, # 0027 - CirclePlusConnectResponse, # 0005 - CirclePlusQueryEndResponse, # 0003 - CirclePlusQueryResponse, # 0002 - CirclePlusRealTimeClockResponse, # 003A - CirclePlusScanResponse, # 0019 - CirclePowerBufferResponse, # 0049 - CirclePowerUsageResponse, # 0013 - CircleClockResponse, # 003F - NodeAckLargeResponse, # 0000 - NodeAckResponse, # 0100 - NodeAckSmallResponse, # 0000 - NodeFeaturesResponse, # 0060 - NodeInfoResponse, # 0024 - NodeJoinAvailableResponse, # 0006 - NodeJoinAckResponse, # 0061 - NodePingResponse, # 000E - NodeSwitchGroupResponse, # 0056 - NodeRemoveResponse, # 001D - NodeAwakeResponse, # 004F - SenseReportResponse, # 0105 - StickInitResponse, # 0011 -) +from plugwise.messages.responses import CircleCalibrationResponse # 0027 +from plugwise.messages.responses import CircleClockResponse # 003F +from plugwise.messages.responses import CirclePlusConnectResponse # 0005 +from plugwise.messages.responses import CirclePlusQueryEndResponse # 0003 +from plugwise.messages.responses import CirclePlusQueryResponse # 0002 +from plugwise.messages.responses import CirclePlusRealTimeClockResponse # 003A +from plugwise.messages.responses import CirclePlusScanResponse # 0019 +from plugwise.messages.responses import CirclePowerBufferResponse # 0049 +from plugwise.messages.responses import CirclePowerUsageResponse # 0013 +from plugwise.messages.responses import NodeAckLargeResponse # 0000 +from plugwise.messages.responses import NodeAckResponse # 0100 +from plugwise.messages.responses import NodeAckSmallResponse # 0000 +from plugwise.messages.responses import NodeAwakeResponse # 004F +from plugwise.messages.responses import NodeFeaturesResponse # 0060 +from plugwise.messages.responses import NodeInfoResponse # 0024 +from plugwise.messages.responses import NodeJoinAckResponse # 0061 +from plugwise.messages.responses import NodeJoinAvailableResponse # 0006 +from plugwise.messages.responses import NodePingResponse # 000E +from plugwise.messages.responses import NodeRemoveResponse # 001D +from plugwise.messages.responses import NodeSwitchGroupResponse # 0056 +from plugwise.messages.responses import SenseReportResponse # 0105 +from plugwise.messages.responses import StickInitResponse # 0011 _LOGGER = logging.getLogger(__name__) -class PlugwiseParser(object): +class PlugwiseParser: """ Transform Plugwise message from wire format to response message object """ @@ -69,12 +64,13 @@ def next_message(self, message): e, ) - def parse_data(self): + def parse_data(self): # noqa: C901 """ Process next set of packet data """ + # TODO: flake8 indicates scan is too complex, level 35 indenting is indeed too complex _LOGGER.debug("Parse data: %s ", str(self._buffer)) - if self._parsing == False: + if self._parsing is False: self._parsing = True # Lookup header of message in buffer diff --git a/plugwise/smile.py b/plugwise/smile.py index 792f5bc31..6b293170a 100644 --- a/plugwise/smile.py +++ b/plugwise/smile.py @@ -1,11 +1,11 @@ """Plugwise Home Assistant module.""" -import aiohttp import asyncio -import async_timeout import datetime as dt import logging +import aiohttp +import async_timeout from dateutil.parser import parse from lxml import etree @@ -31,22 +31,20 @@ SWITCH_GROUP_TYPES, SYSTEM, ) - from plugwise.exceptions import ( ConnectionFailedError, - InvalidAuthentication, - UnsupportedDeviceError, DeviceSetupError, DeviceTimeoutError, - ResponseError, + InvalidAuthentication, InvalidXMLError, + ResponseError, + UnsupportedDeviceError, XMLDataMissingError, ) - from plugwise.util import ( + determine_selected, escape_illegal_xml_characters, format_measure, - determine_selected, in_between, ) @@ -210,7 +208,12 @@ async def close_connection(self): await self.websession.close() async def request( - self, command, retry=3, method="get", data=None, headers=None, + self, + command, + retry=3, + method="get", + data=None, + headers=None, ): """Request data.""" resp = None diff --git a/plugwise/stick.py b/plugwise/stick.py index f83c460f9..8daa4aaac 100644 --- a/plugwise/stick.py +++ b/plugwise/stick.py @@ -3,50 +3,51 @@ Main stick object to control associated plugwise plugs """ +from datetime import datetime, timedelta import logging -import time -import serial +import queue import sys import threading -import queue -from datetime import datetime, timedelta +import time + +import serial +from plugwise.connections.serial import PlugwiseUSBConnection +from plugwise.connections.socket import SocketConnection from plugwise.constants import ( ACCEPT_JOIN_REQUESTS, + ACK_ACCEPT_JOINING_REQUEST, ACK_CLOCK_SET, ACK_ERROR, - ACK_ACCEPT_JOINING_REQUEST, - ACK_ON, ACK_OFF, - ACK_SLEEP_SET, - ACK_SUCCESS, + ACK_ON, ACK_REAL_TIME_CLOCK_SET, ACK_SCAN_PARAMETERS_SET, + ACK_SLEEP_SET, + ACK_SUCCESS, ACK_TIMEOUT, CB_JOIN_REQUEST, CB_NEW_NODE, MAX_TIME_DRIFT, - MESSAGE_TIME_OUT, MESSAGE_RETRY, + MESSAGE_TIME_OUT, NACK_ON_OFF, NACK_REAL_TIME_CLOCK_SET, NACK_SCAN_PARAMETERS_SET, NACK_SLEEP_SET, - NODE_TYPE_STICK, - NODE_TYPE_CELSIUS_SED, NODE_TYPE_CELSIUS_NR, - NODE_TYPE_CIRCLE_PLUS, + NODE_TYPE_CELSIUS_SED, NODE_TYPE_CIRCLE, - NODE_TYPE_SWITCH, - NODE_TYPE_SENSE, + NODE_TYPE_CIRCLE_PLUS, NODE_TYPE_SCAN, + NODE_TYPE_SENSE, NODE_TYPE_STEALTH, + NODE_TYPE_STICK, + NODE_TYPE_SWITCH, SLEEP_TIME, - WATCHDOG_DEAMON, UTF8_DECODE, + WATCHDOG_DEAMON, ) -from plugwise.connections.socket import SocketConnection -from plugwise.connections.serial import PlugwiseUSBConnection from plugwise.exceptions import ( CirclePlusError, NetworkDown, @@ -56,20 +57,20 @@ ) from plugwise.message import PlugwiseMessage from plugwise.messages.requests import ( + CircleCalibrationRequest, CircleClockGetRequest, CircleClockSetRequest, - CirclePlusScanRequest, - CircleCalibrationRequest, CirclePlusRealTimeClockGetRequest, CirclePlusRealTimeClockSetRequest, + CirclePlusScanRequest, CirclePowerUsageRequest, CircleSwitchRelayRequest, - NodeAllowJoiningRequest, NodeAddRequest, + NodeAllowJoiningRequest, NodeInfoRequest, NodePingRequest, - NodeRequest, NodeRemoveRequest, + NodeRequest, StickInitRequest, ) from plugwise.messages.responses import ( @@ -90,21 +91,21 @@ NodeResponse, StickInitResponse, ) -from plugwise.parser import PlugwiseParser from plugwise.node import PlugwiseNode from plugwise.nodes.circle import PlugwiseCircle from plugwise.nodes.circle_plus import PlugwiseCirclePlus -from plugwise.nodes.sed import NodeSED from plugwise.nodes.scan import PlugwiseScan +from plugwise.nodes.sed import NodeSED from plugwise.nodes.sense import PlugwiseSense from plugwise.nodes.stealth import PlugwiseStealth from plugwise.nodes.switch import PlugwiseSwitch +from plugwise.parser import PlugwiseParser from plugwise.util import inc_seq_id, validate_mac _LOGGER = logging.getLogger(__name__) -class stick(object): +class stick: """ Plugwise connection stick """ @@ -163,9 +164,9 @@ def init_finished(): _LOGGER.error("Failed to connect: '%s'", e) except StickInitError as e: _LOGGER.error("Failed to initialize USBstick: '%s'", e) - except NetworkDown as e: + except NetworkDown: _LOGGER.error("Failed to communicated: Plugwise Zigbee network") - except TimeoutException as e: + except TimeoutException: _LOGGER.error("Timeout exception while initializing USBstick") except Exception as e: _LOGGER.error("Unknown error : %s", e) @@ -183,14 +184,14 @@ def connect(self, callback=None): self.connection.connect() _LOGGER.debug("Starting threads...") - # receive timeout deamon + # receive timeout daemon self._run_receive_timeout_thread = True self._receive_timeout_thread = threading.Thread( None, self._receive_timeout_loop, "receive_timeout_thread", (), {} ) self._receive_timeout_thread.daemon = True self._receive_timeout_thread.start() - # send deamon + # send daemon self._send_message_queue = queue.Queue() self._run_send_message_thread = True self._send_message_thread = threading.Thread( @@ -198,7 +199,7 @@ def connect(self, callback=None): ) self._send_message_thread.daemon = True self._send_message_thread.start() - # update deamon + # update daemon self._run_update_thread = False self._auto_update_timer = 0 self._update_thread = threading.Thread( @@ -216,7 +217,7 @@ def cb_stick_initialized(): """ Callback when initialization of Plugwise USBstick is finished """ self._stick_initialized = True - # Start watchdog deamon + # Start watchdog daemon self._run_watchdog = True self._watchdog_thread = threading.Thread( None, self._watchdog_loop, "watchdog_thread", (), {} @@ -321,7 +322,7 @@ def node(self, mac: str) -> PlugwiseNode: def discover_node(self, mac: str, callback=None, force_discover=False) -> bool: """ Discovery of plugwise node """ - if validate_mac(mac) == True: + if validate_mac(mac) is True: if not self._plugwise_nodes.get(mac): if mac not in self._nodes_not_discovered.keys(): self._nodes_not_discovered[mac] = ( @@ -350,8 +351,9 @@ def discover_node(self, mac: str, callback=None, force_discover=False) -> bool: else: return False - def scan(self, callback=None): + def scan(self, callback=None): # noqa: C901 """ scan for connected plugwise nodes """ + # TODO: flake8 indicates scan is too complex, level 23 indenting is indeed complex def scan_finished(nodes_to_discover): """ Callback when scan is finished """ @@ -460,7 +462,7 @@ def allow_join_requests(self, enable: bool, accept: bool): def node_join(self, mac: str, callback=None) -> bool: """Accept node to join Plugwise network by adding it in Circle+ memory""" - if validate_mac(mac) == True: + if validate_mac(mac) is True: self.send(NodeAddRequest(bytes(mac, UTF8_DECODE), True), callback) return True else: @@ -471,7 +473,7 @@ def node_join(self, mac: str, callback=None) -> bool: def node_unjoin(self, mac: str, callback=None) -> bool: """Remove node from the Plugwise network by deleting it from the Circle+ memory""" - if validate_mac(mac) == True: + if validate_mac(mac) is True: self.send( NodeRemoveRequest(bytes(self.circle_plus_mac, UTF8_DECODE), mac), callback, @@ -582,7 +584,7 @@ def send(self, request, callback=None, retry_counter=0): ) def _send_message_loop(self): - """ deamon to send messages waiting in queue """ + """ daemon to send messages waiting in queue """ while self._run_send_message_thread: try: request_set = self._send_message_queue.get(block=True, timeout=1) @@ -590,7 +592,7 @@ def _send_message_loop(self): time.sleep(SLEEP_TIME) else: if self.last_ack_seq_id: - # Calc new seq_id based last received ack messsage + # Calc new seq_id based last received ack message seq_id = inc_seq_id(self.last_ack_seq_id) else: # first message, so use a fake seq_id @@ -633,7 +635,7 @@ def _send_message_loop(self): self.last_ack_seq_id != seq_id and timeout_counter <= 10 and seq_id != b"0000" - and self.last_ack_seq_id != None + and self.last_ack_seq_id is not None ): time.sleep(0.1) timeout_counter += 1 @@ -669,10 +671,10 @@ def _send_message_loop(self): _LOGGER.debug("Send message loop stopped") def _receive_timeout_loop(self): - """ deamon to time out requests without any (n)ack response message """ + """ daemon to time out requests without any (n)ack response message """ while self._run_receive_timeout_thread: for seq_id in list(self.expected_responses.keys()): - if self.expected_responses[seq_id][4] != None: + if self.expected_responses[seq_id][4] is not None: if self.expected_responses[seq_id][4] < ( datetime.now() - timedelta(seconds=MESSAGE_TIME_OUT) ): @@ -734,8 +736,9 @@ def _receive_timeout_loop(self): receive_timeout_checker += 1 _LOGGER.debug("Receive timeout loop stopped") - def new_message(self, message: NodeResponse): + def new_message(self, message: NodeResponse): # noqa: C901 """ Received message from Plugwise Zigbee network """ + # TODO: flake8 indicates scan is too complex, level 47! indenting is indeed overly complex # only save last seq_id and skip special ID's FFFD, FFFE, FFFF if self.last_ack_seq_id: @@ -923,7 +926,7 @@ def new_message(self, message: NodeResponse): self.network_online = True else: self.network_online = False - # Replace first 2 charactors by 00 for mac of circle+ node + # Replace first 2 characters by 00 for mac of circle+ node self.circle_plus_mac = "00" + message.circle_plus_mac.value[2:].decode( UTF8_DECODE ) @@ -941,7 +944,7 @@ def new_message(self, message: NodeResponse): mac, str(message.seq_id), ) - if not mac in self._plugwise_nodes: + if mac not in self._plugwise_nodes: if message.node_type.value == NODE_TYPE_CIRCLE_PLUS: self._circle_plus_discovered = True self._append_node(mac, 0, message.node_type.value) @@ -1003,7 +1006,7 @@ def new_message(self, message: NodeResponse): mac, ) elif isinstance(message, NodeJoinAckResponse): - # Notification mesage when node (re)joined existing network again. + # Notification message when node (re)joined existing network again. # Received when a SED (re)joins the network e.g. when you reinsert the battery of a Scan _LOGGER.info( "Received NodeJoinAckResponse from %s which has accepted or (re)joined this Plugwise network", @@ -1044,8 +1047,11 @@ def new_message(self, message: NodeResponse): self._messages_for_undiscovered_nodes.append(message) self.discover_node(mac) - def message_processed(self, seq_id, ack_response=None, ack_small=False): + def message_processed( # noqa: C901 + self, seq_id, ack_response=None, ack_small=False + ): """ Execute callback of received messages """ + # TODO: flake8 indicates scan is too complex, level 34! indenting is indeed too complex do_callback = False do_resend = False if seq_id in self.expected_responses: @@ -1320,7 +1326,7 @@ def _watchdog_loop(self): ) self._receive_timeout_thread.daemon = True self._receive_timeout_thread.start() - # send message deamon + # send message daemon if self._run_send_message_thread: if not self._send_message_thread.isAlive(): _LOGGER.warning( @@ -1344,7 +1350,7 @@ def _watchdog_loop(self): self._update_thread.daemon = True self._update_thread.start() # Circle+ discovery - if self._circle_plus_discovered == False: + if self._circle_plus_discovered is False: # First hour every once an hour if self._circle_plus_retries < 60 or circle_plus_retry_counter > 60: _LOGGER.info( @@ -1360,11 +1366,12 @@ def _watchdog_loop(self): watchdog_loop_checker += 1 _LOGGER.debug("watchdog loop stopped") - def _update_loop(self): + def _update_loop(self): # noqa: C901 """ When node has not received any message during last 2 update polls, reset availability """ + # TODO: flake8 indicates scan is too complex, level 28 indenting is indeed complex self._run_update_thread = True self._auto_update_first_run = True day_of_month = datetime.now().day @@ -1447,7 +1454,10 @@ def _update_loop(self): if not open_requests_found: self._plugwise_nodes[mac].update_power_usage() # Refresh node info once per hour and request power use afterwards - if self._plugwise_nodes[mac]._last_info_message != None: + if ( + self._plugwise_nodes[mac]._last_info_message + is not None + ): if self._plugwise_nodes[mac]._last_info_message < ( datetime.now().replace( minute=0, @@ -1537,7 +1547,7 @@ def auto_update(self, timer=None): self._auto_update_timer = 0 else: self._auto_update_timer = 5 - if timer == None: + if timer is not None: # Timer based on number of nodes and 3 seconds per node self._auto_update_timer = len(self._plugwise_nodes) * 3 elif timer > 5: diff --git a/plugwise/util.py b/plugwise/util.py index 2772071ac..43dd88061 100644 --- a/plugwise/util.py +++ b/plugwise/util.py @@ -4,19 +4,16 @@ Plugwise protocol helpers """ import binascii -import crcmod import datetime import logging import re import struct import sys -from .exceptions import * -from .constants import ( - PLUGWISE_EPOCH, - LOGADDR_OFFSET, - UTF8_DECODE, -) +import crcmod + +from .constants import LOGADDR_OFFSET, PLUGWISE_EPOCH, UTF8_DECODE +from .exceptions import * crc_fun = crcmod.mkCrcFun(0x11021, rev=False, initCrc=0x0000, xorOut=0x0000) @@ -107,7 +104,7 @@ def in_between(now, start, end): return start <= now or now < end -class BaseType(object): +class BaseType: def __init__(self, value, length): self.value = value self.length = length @@ -271,7 +268,9 @@ def __init__(self, hour=0, minute=0, second=0): def deserialize(self, val): CompositeType.deserialize(self, val) self.value = datetime.time( - int(self.hour.value), int(self.minute.value), int(self.second.value), + int(self.hour.value), + int(self.minute.value), + int(self.second.value), ) diff --git a/setup.py b/setup.py index ea51be44a..188b30089 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ import codecs import os.path -from setuptools import setup, find_packages +from setuptools import find_packages, setup def read(rel_path): diff --git a/tests/INIT.md b/tests/INIT.md index ef4427c4b..c800a719a 100644 --- a/tests/INIT.md +++ b/tests/INIT.md @@ -44,7 +44,7 @@ Then reconfigure your tokens on the pypi website accordingly (only allowing proj ## Travis -Go to [travis repositories](https://travis-ci.org/account/repositories) and click on the 'organisations' to view whats in our organisation. +Go to [travis repositories](https://travis-ci.org/account/repositories) and click on the 'organisations' to view what's in our organisation. Travis needs the PYPI production token for [PyPI deployment](https://docs.travis-ci.com/user/deployment/pypi/) diff --git a/tests/test_smile.py b/tests/test_smile.py index 29cd7f7f3..9b0870ca2 100644 --- a/tests/test_smile.py +++ b/tests/test_smile.py @@ -13,15 +13,14 @@ import jsonpickle as json import pytest -from plugwise.smile import Smile - from plugwise.exceptions import ( ConnectionFailedError, - ErrorSendingCommandError, DeviceTimeoutError, - ResponseError, + ErrorSendingCommandError, InvalidXMLError, + ResponseError, ) +from plugwise.smile import Smile pp = PrettyPrinter(indent=8) From 87918959ea4df1d93408ec2137a06f74e2db6fec Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 00:43:01 +0100 Subject: [PATCH 02/28] Add Github Actions --- .github/workflows/python.yml | 229 +++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 .github/workflows/python.yml diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 000000000..5fc16e1c9 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,229 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python Plugwise CI + +env: + CACHE_VERSION: 1 + DEFAULT_PYTHON: 3.9 + PRE_COMMIT_HOME: ~/.cache/pre-commit + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * 0' # weekly + +jobs: + + prepare: + runs-on: ubuntu-latest + name: Prepare + steps: + - name: Check out committed code + uses: actions/checkout@v2 + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment + id: cache-venv + uses: actions/cache@v2 + with: + path: venv + key: >- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ + steps.python.outputs.python-version }}-${{ + hashFiles('requirements_test.txt') }}-${{ + hashFiles('setup.py') }} + restore-keys: | + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_test.txt') }}-${{ hashFiles('setup.py') }}- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_test.txt') }} + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}- + - name: Create Python virtual environment + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + python -m venv venv + . venv/bin/activate + pip install -U pip setuptools + pip install -e . + pip install -r requirements_test.txt + - name: Restore pre-commit environment from cache + id: cache-precommit + uses: actions/cache@v2 + with: + path: ${{ env.PRE_COMMIT_HOME }} + key: | + ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + restore-keys: | + ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit- + - name: Install pre-commit dependencies + if: steps.cache-precommit.outputs.cache-hit != 'true' + run: | + . venv/bin/activate + pre-commit install-hooks + + + commitcheck: + runs-on: ubuntu-latest + name: Check commit + needs: prepare + steps: + - name: Check out committed code + uses: actions/checkout@v2 + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment + id: cache-venv + uses: actions/cache@v2 + with: + path: venv + key: >- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ + steps.python.outputs.python-version }}-${{ + hashFiles('requirements_test.txt') }}-${{ + hashFiles('setup.py') }} + - name: Fail job if Python cache restore failed + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + echo "Failed to restore Python ${{ env.DEFAULT_PYTHON }} virtual environment from cache" + exit 1 + - name: Restore pre-commit environment from cache + id: cache-precommit + uses: actions/cache@v2 + with: + path: ${{ env.PRE_COMMIT_HOME }} + key: | + ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + - name: Fail job if cache restore failed + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + echo "Failed to restore Python ${{ env.DEFAULT_PYTHON }} virtual environment from cache" + exit 1 + - name: Install dependencies + run: | + . venv/bin/activate + if [ -f requirements_commit.txt ]; then pip install -r requirements_commit.txt; fi + - name: Verify commit + run: | + . venv/bin/activate + pre-commit run --show-diff-on-failure --color=always --all-files + + prepare-test-cache: + runs-on: ubuntu-latest + name: Create pytest cache for Python ${{ matrix.python-version }} + needs: commitcheck + strategy: + matrix: + python-version: [3.8, 3.9] + steps: + - name: Check out committed code + uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + id: python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Restore full Python ${{ matrix.python-version }} virtual environment + id: cache-venv + uses: actions/cache@v2 + with: + path: venv + key: >- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ + matrix.python-version }}-${{ hashFiles('requirements_test.txt') + }}-${{ hashFiles('setup.py') }} + restore-keys: | + ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('requirements_test.txt') }}-${{ hashFiles('setup.py') }} + ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('requirements_test.txt') }} + ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ matrix.python-version }}- + - name: Create full Python ${{ matrix.python-version }} virtual environment + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + python -m venv venv + . venv/bin/activate + pip install -U pip setuptools wheel + pip install -e . + pip install -r requirements_test.txt + + pytest: + runs-on: ubuntu-latest + name: Run pytest using Python ${{ matrix.python-version }} + needs: prepare-test-cache + strategy: + matrix: + python-version: [3.8, 3.9] + + steps: + - name: Check out committed code + uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + id: python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Restore full Python ${{ matrix.python-version }} virtual environment + id: cache-venv + uses: actions/cache@v2 + with: + path: venv + key: >- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-venv-${{ + matrix.python-version }}-${{ hashFiles('requirements_test.txt') + }}-${{ hashFiles('setup.py') }} + - name: Fail job if Python cache restore failed + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + echo "Failed to restore Python virtual environment from cache" + exit 1 + - name: Run all tests + run: | + . venv/bin/activate + pytest --log-level info tests/*.py --cov='.' + - name: Upload coverage artifact + uses: actions/upload-artifact@v2.2.0 + with: + name: coverage-${{ matrix.python-version }} + path: .coverage + + coverage: + name: Process test coverage + runs-on: ubuntu-latest + needs: pytest + steps: + - name: Check out code from GitHub + uses: actions/checkout@v2 + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment + id: cache-venv + uses: actions/cache@v2 + with: + path: venv + key: >- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ + steps.python.outputs.python-version }}-${{ + hashFiles('requirements_test.txt') }}-${{ + hashFiles('setup.py') }} + - name: Fail job if Python cache restore failed + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + echo "Failed to restore Python virtual environment from cache" + exit 1 + - name: Download all coverage artifacts + uses: actions/download-artifact@v2 + - name: Combine coverage results + run: | + . venv/bin/activate + coverage combine coverage*/.coverage* + coverage report --fail-under=94 + coverage xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 From 3e68e43d1e9cd8463c4d019f811222a55eda4473 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 00:45:13 +0100 Subject: [PATCH 03/28] Remove blunt publishing to testpypi --- .github/workflows/publish-to-test-pypi.yml | 28 ---------------------- 1 file changed, 28 deletions(-) delete mode 100644 .github/workflows/publish-to-test-pypi.yml diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml deleted file mode 100644 index 0033ba8b9..000000000 --- a/.github/workflows/publish-to-test-pypi.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Publish Python 🐍 distributions đŸ“Ļ to PyPI and TestPyPI - -on: - push: - branches: - - main - paths: - - 'setup.py' - -jobs: - build-n-publish: - name: Build and publish Python 🐍 distributions đŸ“Ļ to PyPI and TestPyPI - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@main - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Build a distribution - run: >- - python setup.py sdist - - name: Publish distribution đŸ“Ļ to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.testpypi_token }} - repository_url: https://test.pypi.org/legacy/ - From ed1b6cf4f8d97531e0d44fb6e6d3f72aaf36a631 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 10:01:07 +0100 Subject: [PATCH 04/28] Scaffold and testpy --- .github/workflows/merge.yml | 103 +++++++++++++++++++ .github/workflows/{python.yml => verify.yml} | 80 +++++++++++++- 2 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/merge.yml rename .github/workflows/{python.yml => verify.yml} (74%) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml new file mode 100644 index 000000000..c2afcf5a9 --- /dev/null +++ b/.github/workflows/merge.yml @@ -0,0 +1,103 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python Plugwise release to PyPi + +env: + CACHE_VERSION: 1 + DEFAULT_PYTHON: 3.9 + PRE_COMMIT_HOME: ~/.cache/pre-commit + +# Only run on merges +on: + pull_request: + types: closed + branches: + - main + +jobs: + # Prepare default python version environment + prepare: + runs-on: ubuntu-latest + name: Prepare + steps: + - name: Check out committed code + uses: actions/checkout@v2 + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment + id: cache-venv + uses: actions/cache@v2 + with: + path: venv + key: >- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ + steps.python.outputs.python-version }}-${{ + hashFiles('requirements_test.txt') }}-${{ + hashFiles('setup.py') }} + restore-keys: | + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_test.txt') }}-${{ hashFiles('setup.py') }}- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_test.txt') }} + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}- + - name: Create Python virtual environment + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + python -m venv venv + . venv/bin/activate + pip install -U pip setuptools + pip install -e . + pip install -r requirements_test.txt + - name: Restore pre-commit environment from cache + id: cache-precommit + uses: actions/cache@v2 + with: + path: ${{ env.PRE_COMMIT_HOME }} + key: | + ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + restore-keys: | + ${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit- + - name: Install pre-commit dependencies + if: steps.cache-precommit.outputs.cache-hit != 'true' + run: | + . venv/bin/activate + pre-commit install-hooks + + publishing: + name: Build and publish Python 🐍 distributions đŸ“Ļ to PyPI + runs-on: ubuntu-latest + needs: prepare + steps: + - name: Check out committed code + uses: actions/checkout@main + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment + id: cache-venv + uses: actions/cache@v2 + with: + path: venv + key: >- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ + steps.python.outputs.python-version }}-${{ + hashFiles('requirements_test.txt') }}-${{ + hashFiles('setup.py') }} + - name: Fail job if Python cache restore failed + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + echo "Failed to restore Python virtual environment from cache" + exit 1 +# - name: Build a distribution +# run: >- +# python setup.py sdist +# - name: Publish distribution đŸ“Ļ to Test PyPI +# uses: pypa/gh-action-pypi-publish@master +# with: +# password: ${{ secrets.pypi_token }} +# repository_url: https://test.pypi.org/legacy/ +# skip_existing: true diff --git a/.github/workflows/python.yml b/.github/workflows/verify.yml similarity index 74% rename from .github/workflows/python.yml rename to .github/workflows/verify.yml index 5fc16e1c9..b0cd20c6d 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/verify.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Python Plugwise CI +name: Python Plugwise CI verification env: CACHE_VERSION: 1 @@ -10,12 +10,12 @@ env: on: push: - pull_request: schedule: - cron: '0 0 * * 0' # weekly +# pull_request: jobs: - + # Prepare default python version environment prepare: runs-on: ubuntu-latest name: Prepare @@ -227,3 +227,77 @@ jobs: coverage xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 + + test-publishing: + name: Build and publish Python 🐍 distributions đŸ“Ļ to TestPyPI + runs-on: ubuntu-latest + needs: pytest + steps: + - name: Check out code from GitHub + uses: actions/checkout@v2 + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment + id: cache-venv + uses: actions/cache@v2 + with: + path: venv + key: >- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ + steps.python.outputs.python-version }}-${{ + hashFiles('requirements_test.txt') }}-${{ + hashFiles('setup.py') }} + - name: Fail job if Python cache restore failed + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + echo "Failed to restore Python virtual environment from cache" + exit 1 + - name: Build a distribution + run: >- + python setup.py sdist + - name: Publish distribution đŸ“Ļ to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.testpypi_token }} + repository_url: https://test.pypi.org/legacy/ + skip_existing: false + + publishing: + name: Build and publish Python 🐍 distributions đŸ“Ļ to PyPI + runs-on: ubuntu-latest + needs: [pytest, coverage] + steps: + - name: Check out code from GitHub + uses: actions/checkout@v2 + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment + id: cache-venv + uses: actions/cache@v2 + with: + path: venv + key: >- + ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ + steps.python.outputs.python-version }}-${{ + hashFiles('requirements_test.txt') }}-${{ + hashFiles('setup.py') }} + - name: Fail job if Python cache restore failed + if: steps.cache-venv.outputs.cache-hit != 'true' + run: | + echo "Failed to restore Python virtual environment from cache" + exit 1 +# - name: Build a distribution +# run: >- +# python setup.py sdist +# - name: Publish distribution đŸ“Ļ to Test PyPI +# uses: pypa/gh-action-pypi-publish@master +# with: +# password: ${{ secrets.testpypi_token }} +# repository_url: https://test.pypi.org/legacy/ +# skip_existing: false From a75eca89381a52ecae29b065c3f63327a377cfbf Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 10:13:38 +0100 Subject: [PATCH 05/28] Scaffold and testpy --- .github/workflows/verify.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index b0cd20c6d..0efef4943 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -9,10 +9,10 @@ env: PRE_COMMIT_HOME: ~/.cache/pre-commit on: - push: schedule: - cron: '0 0 * * 0' # weekly -# pull_request: + push: + pull_request: jobs: # Prepare default python version environment From ebf1c2bff67d9323a4924fde88aeeec1761faf2c Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 10:14:57 +0100 Subject: [PATCH 06/28] Scaffold and testpy - indent typo --- .github/workflows/verify.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 0efef4943..e57afd0a4 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -12,7 +12,7 @@ on: schedule: - cron: '0 0 * * 0' # weekly push: - pull_request: + #pull_request: jobs: # Prepare default python version environment @@ -255,15 +255,15 @@ jobs: run: | echo "Failed to restore Python virtual environment from cache" exit 1 - - name: Build a distribution - run: >- - python setup.py sdist - - name: Publish distribution đŸ“Ļ to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.testpypi_token }} - repository_url: https://test.pypi.org/legacy/ - skip_existing: false + - name: Build a distribution + run: >- + python setup.py sdist + - name: Publish distribution đŸ“Ļ to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.testpypi_token }} + repository_url: https://test.pypi.org/legacy/ + skip_existing: false publishing: name: Build and publish Python 🐍 distributions đŸ“Ļ to PyPI From 91f2896ad3f47296a75296a495f2a58eafde656f Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 10:15:30 +0100 Subject: [PATCH 07/28] Scaffold and testpy - disable travis --- .travis.yml => .travis.yml.disabled | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .travis.yml => .travis.yml.disabled (100%) diff --git a/.travis.yml b/.travis.yml.disabled similarity index 100% rename from .travis.yml rename to .travis.yml.disabled From a1dccb7bfd12ae73fc5ecf7e6e6f63f1a6e5842a Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 10:20:56 +0100 Subject: [PATCH 08/28] Scaffold and testpy - add testpypi --- .github/workflows/verify.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index e57afd0a4..5921202f7 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -292,12 +292,12 @@ jobs: run: | echo "Failed to restore Python virtual environment from cache" exit 1 -# - name: Build a distribution -# run: >- -# python setup.py sdist -# - name: Publish distribution đŸ“Ļ to Test PyPI -# uses: pypa/gh-action-pypi-publish@master -# with: -# password: ${{ secrets.testpypi_token }} -# repository_url: https://test.pypi.org/legacy/ -# skip_existing: false + - name: Build a distribution + run: >- + python setup.py sdist + - name: Publish distribution đŸ“Ļ to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.testpypi_token }} + repository_url: https://test.pypi.org/legacy/ + skip_existing: false From f7f8d4defb2ec9ed3f84fbe412c0424fcd1c4341 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 10:28:48 +0100 Subject: [PATCH 09/28] Scaffold and testpy - add testpypi and let it soft fail --- .github/workflows/verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 5921202f7..a4d1110f7 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -300,4 +300,4 @@ jobs: with: password: ${{ secrets.testpypi_token }} repository_url: https://test.pypi.org/legacy/ - skip_existing: false + skip_existing: true From d8a2f796542fe993119c0e5c9ef27ddcd9eabf68 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 10:32:51 +0100 Subject: [PATCH 10/28] Scaffold and testpy - force order --- .github/workflows/verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index a4d1110f7..d3ef12ed1 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -268,7 +268,7 @@ jobs: publishing: name: Build and publish Python 🐍 distributions đŸ“Ļ to PyPI runs-on: ubuntu-latest - needs: [pytest, coverage] + needs: coverage steps: - name: Check out code from GitHub uses: actions/checkout@v2 From 55df418b38d02a3585bdb85185e9c9349e6d3fc6 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 10:45:23 +0100 Subject: [PATCH 11/28] Scaffold and testpy - remove faulty merge publish --- .github/workflows/merge.yml | 2 +- .github/workflows/verify.yml | 36 ------------------------------------ 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index c2afcf5a9..6c17fe4d7 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -99,5 +99,5 @@ jobs: # uses: pypa/gh-action-pypi-publish@master # with: # password: ${{ secrets.pypi_token }} -# repository_url: https://test.pypi.org/legacy/ +# repository_url: https://pypi.org/legacy/ # skip_existing: true diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index d3ef12ed1..af637fdea 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -265,39 +265,3 @@ jobs: repository_url: https://test.pypi.org/legacy/ skip_existing: false - publishing: - name: Build and publish Python 🐍 distributions đŸ“Ļ to PyPI - runs-on: ubuntu-latest - needs: coverage - steps: - - name: Check out code from GitHub - uses: actions/checkout@v2 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} - id: python - uses: actions/setup-python@v2 - with: - python-version: ${{ env.DEFAULT_PYTHON }} - - name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment - id: cache-venv - uses: actions/cache@v2 - with: - path: venv - key: >- - ${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ - steps.python.outputs.python-version }}-${{ - hashFiles('requirements_test.txt') }}-${{ - hashFiles('setup.py') }} - - name: Fail job if Python cache restore failed - if: steps.cache-venv.outputs.cache-hit != 'true' - run: | - echo "Failed to restore Python virtual environment from cache" - exit 1 - - name: Build a distribution - run: >- - python setup.py sdist - - name: Publish distribution đŸ“Ļ to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.testpypi_token }} - repository_url: https://test.pypi.org/legacy/ - skip_existing: true From fa070d635527b1bd1eacd45dc09d2da3ac81ed3b Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 11:02:09 +0100 Subject: [PATCH 12/28] Scaffold and testpy - remove faulty merge publish - swap for correctness --- .github/workflows/merge.yml | 2 +- .github/workflows/verify.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 6c17fe4d7..a6b68e428 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -100,4 +100,4 @@ jobs: # with: # password: ${{ secrets.pypi_token }} # repository_url: https://pypi.org/legacy/ -# skip_existing: true +# skip_existing: false diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index af637fdea..a05d4c12f 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -231,7 +231,7 @@ jobs: test-publishing: name: Build and publish Python 🐍 distributions đŸ“Ļ to TestPyPI runs-on: ubuntu-latest - needs: pytest + needs: coverage steps: - name: Check out code from GitHub uses: actions/checkout@v2 @@ -263,5 +263,5 @@ jobs: with: password: ${{ secrets.testpypi_token }} repository_url: https://test.pypi.org/legacy/ - skip_existing: false + skip_existing: true From d9ee778d3d64af09e18c9cd3b8b36e179ab79b6f Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 11:15:42 +0100 Subject: [PATCH 13/28] Allow merge to pypi (still softfailing if already exists --- .github/workflows/merge.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index a6b68e428..e9ed7750b 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -92,12 +92,12 @@ jobs: run: | echo "Failed to restore Python virtual environment from cache" exit 1 -# - name: Build a distribution -# run: >- -# python setup.py sdist -# - name: Publish distribution đŸ“Ļ to Test PyPI -# uses: pypa/gh-action-pypi-publish@master -# with: -# password: ${{ secrets.pypi_token }} -# repository_url: https://pypi.org/legacy/ -# skip_existing: false + - name: Build a distribution + run: >- + python setup.py sdist + - name: Publish distribution đŸ“Ļ to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.pypi_token }} + repository_url: https://pypi.org/legacy/ + skip_existing: true From bd04953387a72e0899442ca62f7f86990dffa816 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 11:17:29 +0100 Subject: [PATCH 14/28] Allow merge to pypi (still softfailing if already exists) - typo --- .github/workflows/merge.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index e9ed7750b..cd8809f3a 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -92,12 +92,12 @@ jobs: run: | echo "Failed to restore Python virtual environment from cache" exit 1 - - name: Build a distribution - run: >- - python setup.py sdist - - name: Publish distribution đŸ“Ļ to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.pypi_token }} - repository_url: https://pypi.org/legacy/ - skip_existing: true + - name: Build a distribution + run: >- + python setup.py sdist + - name: Publish distribution đŸ“Ļ to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.pypi_token }} + repository_url: https://pypi.org/legacy/ + skip_existing: true From 76ab993fdd0ec28c727191ad81f8268acf595762 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 12:18:31 +0100 Subject: [PATCH 15/28] Version bump --- plugwise/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugwise/__init__.py b/plugwise/__init__.py index 4ab9d251c..1b05cd9f3 100644 --- a/plugwise/__init__.py +++ b/plugwise/__init__.py @@ -1,6 +1,6 @@ """Plugwise module.""" -__version__ = "0.8.1" +__version__ = "0.8.2a0" from plugwise.smile import Smile from plugwise.stick import stick From 1030446cc3b890229fb311193d66ea811deb9126 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 16:15:14 +0100 Subject: [PATCH 16/28] Update badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 51629375e..f522e8ab5 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ This module is the backend for the [`plugwise` component](https://github.com/hom Our main usage for this module is supporting [Home Assistant](https://www.home-assistant.io) / [home-assistant](http://github.com/home-assistant/core/) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/plugwise) +[![Build Status](https://github.com/plugwise/python-plugwise/workflows/Python%20Plugwise%20CI%20verification/badge.svg)](https://github.com/plugwise/python-plugwise/actions) [![Build Status](https://travis-ci.org/plugwise/python-plugwise.svg?branch=main)](https://travis-ci.org/plugwise/python-plugwise) [![codecov](https://codecov.io/gh/plugwise/python-plugwise/branch/main/graph/badge.svg)](https://codecov.io/gh/plugwise/python-plugwise) [![PyPI version fury.io](https://badge.fury.io/py/plugwise.svg)](https://pypi.python.org/pypi/plugwise/) From 876d66a3998cb7c01180052ae632d4a1e2ad9593 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 16:29:17 +0100 Subject: [PATCH 17/28] Update badge --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index f522e8ab5..a4f5dcbf1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ Our main usage for this module is supporting [Home Assistant](https://www.home-a [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/plugwise) [![Build Status](https://github.com/plugwise/python-plugwise/workflows/Python%20Plugwise%20CI%20verification/badge.svg)](https://github.com/plugwise/python-plugwise/actions) -[![Build Status](https://travis-ci.org/plugwise/python-plugwise.svg?branch=main)](https://travis-ci.org/plugwise/python-plugwise) [![codecov](https://codecov.io/gh/plugwise/python-plugwise/branch/main/graph/badge.svg)](https://codecov.io/gh/plugwise/python-plugwise) [![PyPI version fury.io](https://badge.fury.io/py/plugwise.svg)](https://pypi.python.org/pypi/plugwise/) From 07643be32967cd54f7bd40350e269d74df8ef11f Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 29 Oct 2020 18:48:51 +0100 Subject: [PATCH 18/28] Correct badges --- .github/workflows/merge.yml | 2 +- .github/workflows/verify.yml | 2 +- README.md | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index cd8809f3a..8888fbf13 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Python Plugwise release to PyPi +name: Latest release env: CACHE_VERSION: 1 diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index a05d4c12f..087a482e3 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Python Plugwise CI verification +name: Latest commit env: CACHE_VERSION: 1 diff --git a/README.md b/README.md index a4f5dcbf1..4c902e8d9 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,10 @@ This module is the backend for the [`plugwise` component](https://github.com/hom Our main usage for this module is supporting [Home Assistant](https://www.home-assistant.io) / [home-assistant](http://github.com/home-assistant/core/) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/plugwise) -[![Build Status](https://github.com/plugwise/python-plugwise/workflows/Python%20Plugwise%20CI%20verification/badge.svg)](https://github.com/plugwise/python-plugwise/actions) +[![Latest release](https://github.com/plugwise/python-plugwise/workflows/Latest%20release/badge.svg)](https://github.com/plugwise/python-plugwise/actions) [![codecov](https://codecov.io/gh/plugwise/python-plugwise/branch/main/graph/badge.svg)](https://codecov.io/gh/plugwise/python-plugwise) [![PyPI version fury.io](https://badge.fury.io/py/plugwise.svg)](https://pypi.python.org/pypi/plugwise/) +[![Newest commit](https://github.com/plugwise/python-plugwise/workflows/Newest%20commit/badge.svg)](https://github.com/plugwise/python-plugwise/actions) ## Integration From 83875423753cfb1ae3c6b352956b23da57fdc6f6 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Fri, 30 Oct 2020 08:51:42 +0100 Subject: [PATCH 19/28] Rerun commit From ef2fe885ed03f7de0125c53cce12ba5cab8dc78e Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Fri, 30 Oct 2020 19:36:01 +0100 Subject: [PATCH 20/28] Automatically detect common vulnerabilities and coding errors --- .github/workflows/codeql-analysis.yml | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..a4ead8322 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,69 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# ******** NOTE ******** + +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '24 14 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more... + # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 + From 8abdc5366b58c261a8583f68fb430341ea48a467 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Fri, 30 Oct 2020 19:52:02 +0100 Subject: [PATCH 21/28] Add security notice as advised --- SECURITY.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..8afcda43c --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,25 @@ +# Security Policy + +## Supported Versions + +As spare-time/free-time developers we support this python module as best +as we can. We will support released versions as old as the module version +included in the `manifest.json` of the current and previous releases of +[Home Assistant Core](https://github.com/home-assistant/core) and/or +[`plugwise-beta`](https://github.com/plugwise/plugwise-beta) +(whichever used release is the oldest). + +## Reporting a Vulnerability + +Create an issue in this repository using the `bug` template. We're +frequent visitors of our own repositories and will try to provide a +solution as quick as we can. We are available on discourse using our +github aliases for quicker response, but always file an issue so other +users are also informed. + +(Security) fixes will always be pre-released and released through +[`plugwise-beta`](https://github.com/plugwise/plugwise-beta) for +testing. A PR to HA Core will follow either in parallel or as soon as +possible. + +Thanks in advance for helping us keeping the community safe. From e64a2f560df3cd216fd78dd9dfd5c59b19d283b6 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Fri, 30 Oct 2020 21:16:56 +0100 Subject: [PATCH 22/28] Reset codacy part --- .github/workflows/verify.yml | 5 ++++ plugwise/connections/serial.py | 5 ++-- plugwise/node.py | 54 ++++++++++++++++------------------ plugwise/stick.py | 4 +-- 4 files changed, 36 insertions(+), 32 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 087a482e3..a02fd5bea 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -227,6 +227,11 @@ jobs: coverage xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 + - name: Run codacy-coverage-reporter + uses: codacy/codacy-coverage-reporter-action@master + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} + coverage-reports: coverage.xml test-publishing: name: Build and publish Python 🐍 distributions đŸ“Ļ to TestPyPI diff --git a/plugwise/connections/serial.py b/plugwise/connections/serial.py index 828c08595..d98378866 100644 --- a/plugwise/connections/serial.py +++ b/plugwise/connections/serial.py @@ -8,9 +8,10 @@ import serial from plugwise.connections.connection import StickConnection -from plugwise.constants import BAUD_RATE, BYTE_SIZE, PARITY, SLEEP_TIME, STOPBITS +from plugwise.constants import BAUD_RATE, BYTE_SIZE, STOPBITS from plugwise.exceptions import PortError -from plugwise.message import PlugwiseMessage + +# from plugwise.message import PlugwiseMessage _LOGGER = logging.getLogger(__name__) diff --git a/plugwise/node.py b/plugwise/node.py index 9f3476766..a7b619db5 100644 --- a/plugwise/node.py +++ b/plugwise/node.py @@ -33,7 +33,7 @@ class PlugwiseNode: - """ Base class for a Plugwise node """ + """Base class for a Plugwise node.""" def __init__(self, mac, address, stick): mac = mac.upper() @@ -65,7 +65,7 @@ def __init__(self, mac, address, stick): self._features = None def get_node_type(self) -> str: - """Return hardware model""" + """Return hardware model.""" if self._hardware_version: hw_model = HW_MODELS.get(self._hardware_version[4:10], None) if hw_model: @@ -83,27 +83,27 @@ def get_node_type(self) -> str: return "Unknown" def is_sed(self) -> bool: - """ Return True if node SED (battery powered)""" + """Return True if node SED (battery powered).""" return False def get_categories(self) -> tuple: - """ Return Home Assistant categories supported by plugwise node """ + """Return Home Assistant categories supported by plugwise node.""" return self.categories def get_sensors(self) -> tuple: - """ Return sensors supported by plugwise node """ + """Return sensors supported by plugwise node.""" return self.sensors def get_switches(self) -> tuple: - """ Return switches supported by plugwise node """ + """Return switches supported by plugwise node.""" return self.switches def get_available(self) -> bool: - """ Return current network state of plugwise node """ + """Return current network state of plugwise node.""" return self._available def set_available(self, state, request_info=False): - """ Set current network state of plugwise node """ + """Set current network state of plugwise node.""" if state is True: if self._available is False: self._available = True @@ -124,72 +124,70 @@ def set_available(self, state, request_info=False): self.do_callback(SENSOR_AVAILABLE["id"]) def get_mac(self) -> str: - """Return mac address""" + """Return mac address.""" return self.mac.decode(UTF8_DECODE) def get_name(self) -> str: - """Return unique name""" + """Return unique name.""" return self.get_node_type() + " (" + str(self._address) + ")" def get_hardware_version(self) -> str: - """Return hardware version""" + """Return hardware version.""" if self._hardware_version is not None: return self._hardware_version return "Unknown" def get_firmware_version(self) -> str: - """Return firmware version""" + """Return firmware version.""" if self._firmware_version is not None: return str(self._firmware_version) return "Unknown" def get_last_update(self) -> datetime: - """Return version""" + """Return version.""" return self.last_update def get_in_RSSI(self) -> int: - """Return inbound RSSI level""" + """Return inbound RSSI level.""" if self.in_RSSI is not None: return self.in_RSSI return 0 def get_out_RSSI(self) -> int: - """Return outbound RSSI level""" + """Return outbound RSSI level.""" if self.out_RSSI is not None: return self.out_RSSI return 0 def get_ping(self) -> int: - """Return ping roundtrip""" + """Return ping roundtrip.""" if self.ping_ms is not None: return self.ping_ms return 0 def _request_info(self, callback=None): - """ Request info from node""" + """Request info from node""" self.stick.send( NodeInfoRequest(self.mac), callback, ) def _request_features(self, callback=None): - """ Request supported features for this node""" + """Request supported features for this node.""" self.stick.send( NodeFeaturesRequest(self.mac), callback, ) def ping(self, callback=None): - """ Ping node""" + """Ping node.""" self.stick.send( NodePingRequest(self.mac), callback, ) def on_message(self, message): - """ - Process received message - """ + """Process received message.""" assert isinstance(message, PlugwiseMessage) if message.mac == self.mac: if message.timestamp is not None: @@ -220,7 +218,7 @@ def _on_message(self, message): pass def subscribe_callback(self, callback, sensor) -> bool: - """ Subscribe callback to execute when state change happens """ + """Subscribe callback to execute when state change happens.""" if sensor in self.sensors: if sensor not in self._callbacks: self._callbacks[sensor] = [] @@ -229,12 +227,12 @@ def subscribe_callback(self, callback, sensor) -> bool: return False def unsubscribe_callback(self, callback, sensor): - """ Unsubscribe callback to execute when state change happens """ + """Unsubscribe callback to execute when state change happens.""" if sensor in self._callbacks: self._callbacks[sensor].remove(callback) def do_callback(self, sensor): - """ Execute callbacks registered for specified callback type """ + """Execute callbacks registered for specified callback type.""" if sensor in self._callbacks: for callback in self._callbacks[sensor]: try: @@ -246,7 +244,7 @@ def do_callback(self, sensor): ) def _process_ping_response(self, message): - """ Process ping response message""" + """Process ping response message.""" self.set_available(True, True) if self.in_RSSI != message.in_RSSI.value: self.in_RSSI = message.in_RSSI.value @@ -259,7 +257,7 @@ def _process_ping_response(self, message): self.do_callback(SENSOR_PING["id"]) def _process_info_response(self, message): - """ Process info response message""" + """Process info response message.""" _LOGGER.debug("Response info message for node %s", self.get_mac()) self.set_available(True) if message.relay_state.serialize() == b"01": @@ -284,7 +282,7 @@ def _process_info_response(self, message): _LOGGER.debug("Firmware version = %s", str(self._firmware_version)) def _process_features_response(self, message): - """ Process features message """ + """Process features message.""" _LOGGER.info( "Node %s supports features %s", self.get_mac(), str(message.features.value) ) diff --git a/plugwise/stick.py b/plugwise/stick.py index 8daa4aaac..7e2602a58 100644 --- a/plugwise/stick.py +++ b/plugwise/stick.py @@ -584,7 +584,7 @@ def send(self, request, callback=None, retry_counter=0): ) def _send_message_loop(self): - """ daemon to send messages waiting in queue """ + """Daemon to send messages waiting in queue.""" while self._run_send_message_thread: try: request_set = self._send_message_queue.get(block=True, timeout=1) @@ -671,7 +671,7 @@ def _send_message_loop(self): _LOGGER.debug("Send message loop stopped") def _receive_timeout_loop(self): - """ daemon to time out requests without any (n)ack response message """ + """Daemon to time out requests without any (n)ack response message.""" while self._run_receive_timeout_thread: for seq_id in list(self.expected_responses.keys()): if self.expected_responses[seq_id][4] is not None: From ba697062dc5eef189df983296891f4a57a58e3e7 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 31 Oct 2020 09:52:44 +0100 Subject: [PATCH 23/28] Change code ql to weekly only --- .github/workflows/codeql-analysis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a4ead8322..27d229fac 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,11 +13,11 @@ name: "CodeQL" on: - push: - branches: [ main ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ main ] +# push: +# branches: [ main ] +# pull_request: +# # The branches below must be a subset of the branches above +# branches: [ main ] schedule: - cron: '24 14 * * 5' From d14082dd8162f82f8e00c39dc2ffc6ae9e1ae017 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 31 Oct 2020 09:59:19 +0100 Subject: [PATCH 24/28] Improve merge action --- .github/workflows/merge.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 8888fbf13..520b8bb7c 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -69,6 +69,8 @@ jobs: name: Build and publish Python 🐍 distributions đŸ“Ļ to PyPI runs-on: ubuntu-latest needs: prepare + # Only trigger on merges, not just closes + if: github.event.pull_request.merged == true steps: - name: Check out committed code uses: actions/checkout@main @@ -99,5 +101,4 @@ jobs: uses: pypa/gh-action-pypi-publish@master with: password: ${{ secrets.pypi_token }} - repository_url: https://pypi.org/legacy/ skip_existing: true From 2b5f3bc00c0a74365217e805b30b964ff8bd04fd Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 31 Oct 2020 11:34:41 +0100 Subject: [PATCH 25/28] Remove codacy --- .github/workflows/verify.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index a02fd5bea..087a482e3 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -227,11 +227,6 @@ jobs: coverage xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 - - name: Run codacy-coverage-reporter - uses: codacy/codacy-coverage-reporter-action@master - with: - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} - coverage-reports: coverage.xml test-publishing: name: Build and publish Python 🐍 distributions đŸ“Ļ to TestPyPI From bdf21b4f19a35d59d6b1c91c0192d728bfb2a216 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 31 Oct 2020 11:46:25 +0100 Subject: [PATCH 26/28] Attempt to improve pre-commit environment restore (and fix duplicate and typos) --- .github/workflows/verify.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 087a482e3..35012fd31 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -102,12 +102,8 @@ jobs: - name: Fail job if cache restore failed if: steps.cache-venv.outputs.cache-hit != 'true' run: | - echo "Failed to restore Python ${{ env.DEFAULT_PYTHON }} virtual environment from cache" + echo "Failed to restore pre-commit environment from cache" exit 1 - - name: Install dependencies - run: | - . venv/bin/activate - if [ -f requirements_commit.txt ]; then pip install -r requirements_commit.txt; fi - name: Verify commit run: | . venv/bin/activate From 852e103cb9e7dd01e7060a68c806267eead90793 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 31 Oct 2020 13:07:50 +0100 Subject: [PATCH 27/28] Include codefactor --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4c902e8d9..63fbd40a9 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ This module is the backend for the [`plugwise` component](https://github.com/hom Our main usage for this module is supporting [Home Assistant](https://www.home-assistant.io) / [home-assistant](http://github.com/home-assistant/core/) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/plugwise) +[![CodeFactor](https://www.codefactor.io/repository/github/plugwise/python-plugwise/badge)](https://www.codefactor.io/repository/github/plugwise/python-plugwise) [![Latest release](https://github.com/plugwise/python-plugwise/workflows/Latest%20release/badge.svg)](https://github.com/plugwise/python-plugwise/actions) [![codecov](https://codecov.io/gh/plugwise/python-plugwise/branch/main/graph/badge.svg)](https://codecov.io/gh/plugwise/python-plugwise) [![PyPI version fury.io](https://badge.fury.io/py/plugwise.svg)](https://pypi.python.org/pypi/plugwise/) From 689b132829a2e9ef9ea979637fe80e95a7c73d00 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 31 Oct 2020 13:13:01 +0100 Subject: [PATCH 28/28] Correct badge label --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 63fbd40a9..b2c5eb4fd 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Our main usage for this module is supporting [Home Assistant](https://www.home-a [![Latest release](https://github.com/plugwise/python-plugwise/workflows/Latest%20release/badge.svg)](https://github.com/plugwise/python-plugwise/actions) [![codecov](https://codecov.io/gh/plugwise/python-plugwise/branch/main/graph/badge.svg)](https://codecov.io/gh/plugwise/python-plugwise) [![PyPI version fury.io](https://badge.fury.io/py/plugwise.svg)](https://pypi.python.org/pypi/plugwise/) -[![Newest commit](https://github.com/plugwise/python-plugwise/workflows/Newest%20commit/badge.svg)](https://github.com/plugwise/python-plugwise/actions) +[![Newest commit](https://github.com/plugwise/python-plugwise/workflows/Latest%20commit/badge.svg)](https://github.com/plugwise/python-plugwise/actions) ## Integration