From d0fb2bcedb76b0c3f2f6c1eac83e1b87b6ff6b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Rasztabiga?= Date: Thu, 22 Jul 2021 20:32:51 +0200 Subject: [PATCH 1/2] Add getting actual MAC address --- requirements.txt | 1 + thingooConnector/device_info.py | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2ca071e..578ef2f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -46,3 +46,4 @@ typed-ast==1.4.2 typing-extensions==3.7.4.3 urllib3==1.26.4 webencodings==0.5.1 +getmac==0.8.2 diff --git a/thingooConnector/device_info.py b/thingooConnector/device_info.py index 220f092..13f0481 100644 --- a/thingooConnector/device_info.py +++ b/thingooConnector/device_info.py @@ -1,6 +1,4 @@ -def get_mac_address(): - # TODO Get real MAC address from device - return "00:00:00:00:00:00" +from getmac import get_mac_address class DeviceInfo: From bbf31ad7473419d1ee84161366ffc559da92a6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Rasztabiga?= Date: Thu, 22 Jul 2021 20:34:36 +0200 Subject: [PATCH 2/2] Fix test --- tests/test_connector.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_connector.py b/tests/test_connector.py index f994364..d75ebdc 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -1,3 +1,5 @@ +from getmac import get_mac_address + from thingooConnector.device_info import DeviceInfo from thingooConnector.entity import Entity from thingooConnector.httpconnector import HTTPCredentials, HTTPConnector @@ -18,7 +20,7 @@ def test_json(): connector = HTTPConnector("#", device_info, [temp, hum], credentials) data = connector._create_registration_form() - # FIXME Testing with real macAddress + mac = get_mac_address() if str( - data) != "{'key': 'test', 'macAddress': '00:00:00:00:00:00', 'displayName': 'test device', 'entities': [{'key': 'temp', 'type': 'SENSOR', 'valueType': 'DECIMAL', 'unitDisplayName': 'C'}, {'key': 'hum', 'type': 'SENSOR', 'valueType': 'DECIMAL', 'unitDisplayName': '%'}]}": + data) != "{'key': 'test', 'macAddress': '" + mac + "', 'displayName': 'test device', 'entities': [{'key': 'temp', 'type': 'SENSOR', 'valueType': 'DECIMAL', 'unitDisplayName': 'C'}, {'key': 'hum', 'type': 'SENSOR', 'valueType': 'DECIMAL', 'unitDisplayName': '%'}]}": raise AssertionError