py-ccm15 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccm15/CCM15Device.py +41 -0
- ccm15/CCM15DeviceState.py +9 -0
- ccm15/CCM15SlaveDevice.py +54 -0
- ccm15/__init__.py +8 -0
- py_ccm15-0.0.3.dist-info/LICENSE +21 -0
- py_ccm15-0.0.3.dist-info/METADATA +17 -0
- py_ccm15-0.0.3.dist-info/RECORD +9 -0
- py_ccm15-0.0.3.dist-info/WHEEL +5 -0
- py_ccm15-0.0.3.dist-info/top_level.txt +1 -0
ccm15/CCM15Device.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import httpx
|
|
2
|
+
import xmltodict
|
|
3
|
+
from .CCM15DeviceState import CCM15DeviceState
|
|
4
|
+
from .CCM15SlaveDevice import CCM15SlaveDevice
|
|
5
|
+
|
|
6
|
+
BASE_URL = "http://{0}:{1}/{2}"
|
|
7
|
+
CONF_URL_STATUS = "status.xml"
|
|
8
|
+
DEFAULT_TIMEOUT = 10
|
|
9
|
+
|
|
10
|
+
class CCM15Device:
|
|
11
|
+
def __init__(self, host: str, port: int, timeout = DEFAULT_TIMEOUT):
|
|
12
|
+
self.host = host
|
|
13
|
+
self.port = port
|
|
14
|
+
self.timeout = timeout
|
|
15
|
+
|
|
16
|
+
async def _fetch_xml_data(self) -> str:
|
|
17
|
+
url = BASE_URL.format(self.host, self.port, CONF_URL_STATUS)
|
|
18
|
+
async with httpx.AsyncClient() as client:
|
|
19
|
+
response = await client.get(url, self.timeout)
|
|
20
|
+
return response.text
|
|
21
|
+
|
|
22
|
+
async def _fetch_data(self) -> CCM15DeviceState:
|
|
23
|
+
"""Get the current status of all AC devices."""
|
|
24
|
+
str_data = await self._fetch_xml_data()
|
|
25
|
+
doc = xmltodict.parse(str_data)
|
|
26
|
+
data = doc["response"]
|
|
27
|
+
ac_data = CCM15DeviceState(devices={})
|
|
28
|
+
ac_index = 0
|
|
29
|
+
for ac_name, ac_binary in data.items():
|
|
30
|
+
if ac_binary == "-":
|
|
31
|
+
break
|
|
32
|
+
bytesarr = bytes.fromhex(ac_binary.strip(","))
|
|
33
|
+
ac_slave = CCM15SlaveDevice(bytesarr)
|
|
34
|
+
ac_data.devices[ac_index] = ac_slave
|
|
35
|
+
ac_index += 1
|
|
36
|
+
return ac_data
|
|
37
|
+
|
|
38
|
+
async def get_status_async(self) -> CCM15DeviceState:
|
|
39
|
+
return await self._fetch_data()
|
|
40
|
+
|
|
41
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Data model to represent state of a CCM15 device."""
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
@dataclass
|
|
6
|
+
class TemperatureUnit(Enum):
|
|
7
|
+
CELSIUS = 1
|
|
8
|
+
FAHRENHEIT = 2
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class CCM15SlaveDevice:
|
|
12
|
+
"""Data retrieved from a CCM15 slave device."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, bytesarr: bytes) -> None:
|
|
15
|
+
"""Initialize the slave device."""
|
|
16
|
+
self.unit = TemperatureUnit.CELSIUS
|
|
17
|
+
buf = bytesarr[0]
|
|
18
|
+
if (buf >> 0) & 1:
|
|
19
|
+
self.unit = TemperatureUnit.FAHRENHEIT
|
|
20
|
+
self.locked_cool_temperature: int = (buf >> 3) & 0x1F
|
|
21
|
+
|
|
22
|
+
buf = bytesarr[1]
|
|
23
|
+
self.locked_heat_temperature: int = (buf >> 0) & 0x1F
|
|
24
|
+
self.locked_wind: int = (buf >> 5) & 7
|
|
25
|
+
|
|
26
|
+
buf = bytesarr[2]
|
|
27
|
+
self.locked_ac_mode: int = (buf >> 0) & 3
|
|
28
|
+
self.error_code: int = (buf >> 2) & 0x3F
|
|
29
|
+
|
|
30
|
+
buf = bytesarr[3]
|
|
31
|
+
self.ac_mode: int = (buf >> 2) & 7
|
|
32
|
+
self.fan_mode: int = (buf >> 5) & 7
|
|
33
|
+
|
|
34
|
+
buf = (buf >> 1) & 1
|
|
35
|
+
self.is_ac_mode_locked: bool = buf != 0
|
|
36
|
+
|
|
37
|
+
buf = bytesarr[4]
|
|
38
|
+
self.temperature_setpoint: int = (buf >> 3) & 0x1F
|
|
39
|
+
if self.unit == TemperatureUnit.FAHRENHEIT:
|
|
40
|
+
self.temperature_setpoint += 62
|
|
41
|
+
self.locked_cool_temperature += 62
|
|
42
|
+
self.locked_heat_temperature += 62
|
|
43
|
+
self.is_swing_on: bool = (buf >> 1) & 1 != 0
|
|
44
|
+
|
|
45
|
+
buf = bytesarr[5]
|
|
46
|
+
if ((buf >> 3) & 1) == 0:
|
|
47
|
+
self.locked_cool_temperature = 0
|
|
48
|
+
if ((buf >> 4) & 1) == 0:
|
|
49
|
+
self.locked_heat_temperature = 0
|
|
50
|
+
self.fan_locked: bool = buf >> 5 & 1 != 0
|
|
51
|
+
self.is_remote_locked: bool = ((buf >> 6) & 1) != 0
|
|
52
|
+
|
|
53
|
+
buf = bytesarr[6]
|
|
54
|
+
self.temperature: int = buf if buf < 128 else buf - 256
|
ccm15/__init__.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Oscar Calvo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: py-ccm15
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: A package to control Midea CCM15 data converter modules
|
|
5
|
+
Home-page: https://github.com/ocalvo/py-ccm15
|
|
6
|
+
Author: Oscar Calvo
|
|
7
|
+
Author-email: oscar@calvonet.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: httpx >=0.24.1
|
|
14
|
+
Requires-Dist: xmltodict >=0.13.0
|
|
15
|
+
|
|
16
|
+
# py-ccm15
|
|
17
|
+
Python Library to access a Midea CCM15 data converter
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
ccm15/CCM15Device.py,sha256=MZsa-i7fQPM9wPacVHK18520XvOEscs3Ig53eSO7k-k,1384
|
|
2
|
+
ccm15/CCM15DeviceState.py,sha256=CRDD4A4N6xaLrt81Qz178M6PPPu1tmIMlEgMZpQbqZM,244
|
|
3
|
+
ccm15/CCM15SlaveDevice.py,sha256=5z2SOn_OlLbDQffEjSwC8iSq8CC5FCpjRBRWRqkaDY8,1743
|
|
4
|
+
ccm15/__init__.py,sha256=hHgQhen9MXWrZn-jTbUZ_AwiGjFiC3KvmeJrHXZgkxE,262
|
|
5
|
+
py_ccm15-0.0.3.dist-info/LICENSE,sha256=_GTXQn40nzoMBOtvpqPCWPUlWirv0-5jJZEbrEhvU70,1089
|
|
6
|
+
py_ccm15-0.0.3.dist-info/METADATA,sha256=43K0sLjYyO0_20D5gg7HTJ_aDVPMiZTTXkv5C3ar2AU,571
|
|
7
|
+
py_ccm15-0.0.3.dist-info/WHEEL,sha256=5sUXSg9e4bi7lTLOHcm6QEYwO5TIF1TNbTSVFVjcJcc,92
|
|
8
|
+
py_ccm15-0.0.3.dist-info/top_level.txt,sha256=fgKSrt9y6pIO3BeOiypouBwCm0msiT6sdoSRG3zJy4s,6
|
|
9
|
+
py_ccm15-0.0.3.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ccm15
|