boneIO 0.1.0.dev23__tar.gz → 0.1.0.dev25__tar.gz
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.
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/MANIFEST.in +0 -1
- {boneio-0.1.0.dev23/boneio.egg-info → boneio-0.1.0.dev25}/PKG-INFO +2 -2
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/bonecli.py +2 -2
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/const.py +1 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/helper/stats.py +6 -5
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/manager.py +22 -11
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/schema.yaml +17 -0
- boneio-0.1.0.dev25/boneio/sensor/__init__.py +6 -0
- boneio-0.1.0.dev23/boneio/sensor/lm75.py → boneio-0.1.0.dev25/boneio/sensor/temp/__init__.py +26 -6
- boneio-0.1.0.dev25/boneio/version.py +2 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25/boneio.egg-info}/PKG-INFO +2 -2
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio.egg-info/SOURCES.txt +7 -7
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio.egg-info/requires.txt +1 -0
- boneio-0.1.0.dev25/boneio.egg-info/top_level.txt +1 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/requirements.txt +1 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/setup.py +1 -0
- boneio-0.1.0.dev23/boneio/sensor/__init__.py +0 -6
- boneio-0.1.0.dev23/boneio/version.py +0 -2
- boneio-0.1.0.dev23/boneio.egg-info/top_level.txt +0 -2
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/LICENSE +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/README.md +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/__init__.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25/boneio}/example_config/__init__.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25/boneio}/example_config/adc.yaml +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25/boneio}/example_config/config.yaml +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25/boneio}/example_config/input.yaml +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25/boneio}/example_config/output24x16A.yaml +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25/boneio}/example_config/output32x5A.yaml +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/fonts/danube__.ttf +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/helper/__init__.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/helper/exceptions.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/helper/gpio.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/helper/ha_discovery.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/helper/mqtt.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/helper/oled.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/helper/queue.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/helper/yaml.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/input/__init__.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/input/gpio.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/mqtt_client.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/oled.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/relay/__init__.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/relay/basic.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/relay/gpio.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/relay/mcp.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/sensor/adc.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio/sensor/gpio.py +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio.egg-info/dependency_links.txt +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/boneio.egg-info/entry_points.txt +0 -0
- {boneio-0.1.0.dev23 → boneio-0.1.0.dev25}/setup.cfg +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: boneio
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev25
|
|
4
4
|
Summary: Python Helper for BoneIO
|
|
5
5
|
Home-page: https://github.com/maciejk1984/boneIO
|
|
6
6
|
License: GNU General Public License v3.0
|
|
7
|
-
Download-URL: https://github.com/maciejk1984/boneIO/archive/0.1.0.
|
|
7
|
+
Download-URL: https://github.com/maciejk1984/boneIO/archive/0.1.0.dev25.zip
|
|
8
8
|
Platform: UNKNOWN
|
|
9
9
|
Classifier: Programming Language :: Python
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.7
|
|
@@ -12,6 +12,7 @@ from boneio.const import (
|
|
|
12
12
|
HA_DISCOVERY,
|
|
13
13
|
HOST,
|
|
14
14
|
MCP23017,
|
|
15
|
+
MCP_TEMP_9808,
|
|
15
16
|
MQTT,
|
|
16
17
|
OLED,
|
|
17
18
|
OUTPUT,
|
|
@@ -121,8 +122,6 @@ async def run(ctx, debug: int, config: str, mqttpassword: str = ""):
|
|
|
121
122
|
schema = load_yaml_file(os.path.join(MAINPATH, "schema.yaml"))
|
|
122
123
|
v = CustomValidator(schema, purge_unknown=True)
|
|
123
124
|
config_yaml = load_yaml_file(config)
|
|
124
|
-
print("aaa", schema)
|
|
125
|
-
print("bbb", config_yaml)
|
|
126
125
|
if not config_yaml:
|
|
127
126
|
_LOGGER.info("Missing file.")
|
|
128
127
|
return
|
|
@@ -143,6 +142,7 @@ async def run(ctx, debug: int, config: str, mqttpassword: str = ""):
|
|
|
143
142
|
ha_discovery_prefix=_config[MQTT][HA_DISCOVERY][TOPIC_PREFIX],
|
|
144
143
|
mcp23017=_config.get(MCP23017, []),
|
|
145
144
|
lm75=_config.get(LM75),
|
|
145
|
+
mcp9808=_config.get(MCP_TEMP_9808),
|
|
146
146
|
oled=_config.get(OLED),
|
|
147
147
|
adc_list=_config.get(ADC, []),
|
|
148
148
|
)
|
|
@@ -22,7 +22,8 @@ from boneio.const import (
|
|
|
22
22
|
MAC,
|
|
23
23
|
NONE,
|
|
24
24
|
)
|
|
25
|
-
from boneio.sensor import LM75Sensor
|
|
25
|
+
from boneio.sensor import LM75Sensor, MCP9808Sensor
|
|
26
|
+
|
|
26
27
|
|
|
27
28
|
intervals = (("d", 86400), ("h", 3600), ("m", 60))
|
|
28
29
|
|
|
@@ -144,11 +145,11 @@ class HostData:
|
|
|
144
145
|
|
|
145
146
|
data = {UPTIME: {}, NETWORK: {}, CPU: {}, DISK: {}, MEMORY: {}, SWAP: {}}
|
|
146
147
|
|
|
147
|
-
def __init__(self, output: dict, callback: Callable,
|
|
148
|
+
def __init__(self, output: dict, callback: Callable, temp_sensor: Callable[[LM75Sensor, MCP9808Sensor], None]) -> None:
|
|
148
149
|
"""Initialize HostData."""
|
|
149
150
|
self._hostname = socket.gethostname()
|
|
150
151
|
self.data[UPTIME] = {HOST: self._hostname, UPTIME: 0}
|
|
151
|
-
self.
|
|
152
|
+
self._temp_sensor = temp_sensor
|
|
152
153
|
self._output = output
|
|
153
154
|
self._callback = callback
|
|
154
155
|
self._loop = asyncio.get_running_loop()
|
|
@@ -161,8 +162,8 @@ class HostData:
|
|
|
161
162
|
def write_uptime(self, uptime: str) -> None:
|
|
162
163
|
"""Write uptime."""
|
|
163
164
|
self.data[UPTIME][UPTIME] = uptime
|
|
164
|
-
if self.
|
|
165
|
-
self.data[UPTIME][self.
|
|
165
|
+
if self._temp_sensor:
|
|
166
|
+
self.data[UPTIME][self._temp_sensor.name] = self._temp_sensor.state
|
|
166
167
|
self._loop.call_soon_threadsafe(partial(self._callback, UPTIME))
|
|
167
168
|
|
|
168
169
|
def get(self, type: str) -> dict:
|
|
@@ -18,8 +18,10 @@ from boneio.const import (
|
|
|
18
18
|
INIT_SLEEP,
|
|
19
19
|
INPUT,
|
|
20
20
|
KIND,
|
|
21
|
+
LM75,
|
|
21
22
|
MCP,
|
|
22
23
|
MCP_ID,
|
|
24
|
+
MCP_TEMP_9808,
|
|
23
25
|
OFF,
|
|
24
26
|
ON,
|
|
25
27
|
ONLINE,
|
|
@@ -64,6 +66,7 @@ class Manager:
|
|
|
64
66
|
relay_pins: List,
|
|
65
67
|
input_pins: List,
|
|
66
68
|
lm75: dict = None,
|
|
69
|
+
mcp9808: dict = None,
|
|
67
70
|
ha_discovery: bool = True,
|
|
68
71
|
ha_discovery_prefix: str = HOMEASSISTANT,
|
|
69
72
|
mcp23017: Optional[List] = None,
|
|
@@ -84,20 +87,24 @@ class Manager:
|
|
|
84
87
|
self._grouped_outputs = {}
|
|
85
88
|
self._oled = None
|
|
86
89
|
self._tasks: List[asyncio.Task] = []
|
|
87
|
-
self.
|
|
90
|
+
self._temp_sensors = []
|
|
88
91
|
|
|
89
|
-
def
|
|
92
|
+
def create_temp_sensor(sensor_type: str, temp_def: dict = {}):
|
|
90
93
|
"""Create LM sensor in manager."""
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
if sensor_type == LM75:
|
|
95
|
+
from .sensor import LM75Sensor as TempSensor
|
|
96
|
+
elif sensor_type == MCP_TEMP_9808:
|
|
97
|
+
from .sensor import MCP9808Sensor as TempSensor
|
|
98
|
+
else:
|
|
99
|
+
return
|
|
100
|
+
name = temp_def.get(ID)
|
|
94
101
|
id = name.replace(" ", "")
|
|
95
102
|
try:
|
|
96
|
-
|
|
103
|
+
temp_sensor = TempSensor(
|
|
97
104
|
id=id,
|
|
98
105
|
name=name,
|
|
99
106
|
i2c=self._i2cbusio,
|
|
100
|
-
address=
|
|
107
|
+
address=temp_def[ADDRESS],
|
|
101
108
|
send_message=self.send_message,
|
|
102
109
|
topic_prefix=topic_prefix,
|
|
103
110
|
)
|
|
@@ -108,9 +115,10 @@ class Manager:
|
|
|
108
115
|
prefix=ha_discovery_prefix,
|
|
109
116
|
availibilty_msg_func=ha_sensor_temp_availibilty_message,
|
|
110
117
|
)
|
|
111
|
-
self._tasks.append(asyncio.create_task(
|
|
118
|
+
self._tasks.append(asyncio.create_task(temp_sensor.send_state()))
|
|
119
|
+
self._temp_sensors.append(temp_sensor)
|
|
112
120
|
except I2CError as err:
|
|
113
|
-
_LOGGER.error("Can't configure
|
|
121
|
+
_LOGGER.error("Can't configure Temp sensor. %s", err)
|
|
114
122
|
pass
|
|
115
123
|
|
|
116
124
|
def create_mcp23017():
|
|
@@ -163,7 +171,10 @@ class Manager:
|
|
|
163
171
|
return True
|
|
164
172
|
|
|
165
173
|
if lm75:
|
|
166
|
-
|
|
174
|
+
create_temp_sensor(sensor_type=LM75, temp_def=lm75)
|
|
175
|
+
|
|
176
|
+
if mcp9808:
|
|
177
|
+
create_temp_sensor(sensor_type=MCP_TEMP_9808, temp_def=mcp9808)
|
|
167
178
|
|
|
168
179
|
if mcp23017:
|
|
169
180
|
create_mcp23017()
|
|
@@ -274,7 +285,7 @@ class Manager:
|
|
|
274
285
|
|
|
275
286
|
self._host_data = HostData(
|
|
276
287
|
output=self._grouped_outputs,
|
|
277
|
-
|
|
288
|
+
temp_sensor=self._temp_sensors[0] if self._temp_sensors else None,
|
|
278
289
|
callback=self._host_data_callback,
|
|
279
290
|
)
|
|
280
291
|
for f in host_stats.values():
|
|
@@ -68,6 +68,23 @@ lm75:
|
|
|
68
68
|
meta:
|
|
69
69
|
label: GPIO of I2C SDA
|
|
70
70
|
|
|
71
|
+
|
|
72
|
+
mcp9808:
|
|
73
|
+
type: dict
|
|
74
|
+
required: False
|
|
75
|
+
schema:
|
|
76
|
+
id:
|
|
77
|
+
type: string
|
|
78
|
+
required: False
|
|
79
|
+
meta:
|
|
80
|
+
label: Id of I2C to use in pin config
|
|
81
|
+
address:
|
|
82
|
+
type: string
|
|
83
|
+
required: True
|
|
84
|
+
default: 0x18
|
|
85
|
+
meta:
|
|
86
|
+
label: GPIO of I2C SDA
|
|
87
|
+
|
|
71
88
|
mcp23017:
|
|
72
89
|
type: list
|
|
73
90
|
required: False
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Sensor module."""
|
|
2
|
+
from boneio.sensor.temp import LM75Sensor, MCP9808Sensor
|
|
3
|
+
from boneio.sensor.gpio import GpioInputSensor
|
|
4
|
+
from boneio.sensor.adc import initialize_adc, GpioADCSensor
|
|
5
|
+
|
|
6
|
+
__all__ = ["LM75Sensor", "MCP9808Sensor", "GpioInputSensor", "initialize_adc", "GpioADCSensor"]
|
boneio-0.1.0.dev23/boneio/sensor/lm75.py → boneio-0.1.0.dev25/boneio/sensor/temp/__init__.py
RENAMED
|
@@ -1,21 +1,30 @@
|
|
|
1
|
-
"""Manage
|
|
1
|
+
"""Manage BoneIO onboard temp sensors."""
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
from adafruit_pct2075 import PCT2075
|
|
5
|
+
from adafruit_mcp9808 import MCP9808
|
|
6
|
+
from boneio.const import STATE, SENSOR, LM75, MCP_TEMP_9808, TEMPERATURE
|
|
7
|
+
|
|
8
|
+
from boneio.helper.exceptions import I2CError
|
|
9
|
+
from boneio.helper import BasicMqtt
|
|
10
|
+
|
|
11
|
+
|
|
5
12
|
from boneio.const import STATE, SENSOR, LM75
|
|
6
13
|
|
|
7
14
|
from boneio.helper.exceptions import I2CError
|
|
8
15
|
from boneio.helper import BasicMqtt
|
|
9
16
|
|
|
10
17
|
|
|
11
|
-
class
|
|
12
|
-
"""Represent
|
|
18
|
+
class TempSensor(BasicMqtt):
|
|
19
|
+
"""Represent Temp sensor in BoneIO."""
|
|
20
|
+
SensorClass = None
|
|
21
|
+
DefaultName = TEMPERATURE
|
|
13
22
|
|
|
14
|
-
def __init__(self, i2c, address, id: str =
|
|
15
|
-
"""Initialize
|
|
23
|
+
def __init__(self, i2c, address, id: str = DefaultName, **kwargs):
|
|
24
|
+
"""Initialize Temp class."""
|
|
16
25
|
super().__init__(id=id, topic_type=SENSOR, **kwargs)
|
|
17
26
|
try:
|
|
18
|
-
self._pct =
|
|
27
|
+
self._pct = self.SensorClass(i2c_bus=i2c, address=address)
|
|
19
28
|
except ValueError as err:
|
|
20
29
|
raise I2CError(err)
|
|
21
30
|
|
|
@@ -32,3 +41,14 @@ class LM75Sensor(BasicMqtt):
|
|
|
32
41
|
payload={STATE: self.state},
|
|
33
42
|
)
|
|
34
43
|
await asyncio.sleep(60)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class LM75Sensor(TempSensor):
|
|
47
|
+
"""Represent LM75 sensor in BoneIO."""
|
|
48
|
+
SensorClass = PCT2075
|
|
49
|
+
DefaultName = LM75
|
|
50
|
+
|
|
51
|
+
class MCP9808Sensor(TempSensor):
|
|
52
|
+
"""Represent MCP9808 sensor in BoneIO."""
|
|
53
|
+
SensorClass = MCP9808
|
|
54
|
+
DefaultName = MCP_TEMP_9808
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: boneio
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev25
|
|
4
4
|
Summary: Python Helper for BoneIO
|
|
5
5
|
Home-page: https://github.com/maciejk1984/boneIO
|
|
6
6
|
License: GNU General Public License v3.0
|
|
7
|
-
Download-URL: https://github.com/maciejk1984/boneIO/archive/0.1.0.
|
|
7
|
+
Download-URL: https://github.com/maciejk1984/boneIO/archive/0.1.0.dev25.zip
|
|
8
8
|
Platform: UNKNOWN
|
|
9
9
|
Classifier: Programming Language :: Python
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.7
|
|
@@ -17,6 +17,12 @@ boneio.egg-info/dependency_links.txt
|
|
|
17
17
|
boneio.egg-info/entry_points.txt
|
|
18
18
|
boneio.egg-info/requires.txt
|
|
19
19
|
boneio.egg-info/top_level.txt
|
|
20
|
+
boneio/example_config/__init__.py
|
|
21
|
+
boneio/example_config/adc.yaml
|
|
22
|
+
boneio/example_config/config.yaml
|
|
23
|
+
boneio/example_config/input.yaml
|
|
24
|
+
boneio/example_config/output24x16A.yaml
|
|
25
|
+
boneio/example_config/output32x5A.yaml
|
|
20
26
|
boneio/fonts/danube__.ttf
|
|
21
27
|
boneio/helper/__init__.py
|
|
22
28
|
boneio/helper/exceptions.py
|
|
@@ -36,10 +42,4 @@ boneio/relay/mcp.py
|
|
|
36
42
|
boneio/sensor/__init__.py
|
|
37
43
|
boneio/sensor/adc.py
|
|
38
44
|
boneio/sensor/gpio.py
|
|
39
|
-
boneio/sensor/
|
|
40
|
-
example_config/__init__.py
|
|
41
|
-
example_config/adc.yaml
|
|
42
|
-
example_config/config.yaml
|
|
43
|
-
example_config/input.yaml
|
|
44
|
-
example_config/output24x16A.yaml
|
|
45
|
-
example_config/output32x5A.yaml
|
|
45
|
+
boneio/sensor/temp/__init__.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
boneio
|
|
@@ -4,6 +4,7 @@ adafruit-circuitpython-busdevice==5.1.1
|
|
|
4
4
|
adafruit-circuitpython-framebuf==1.4.8
|
|
5
5
|
adafruit-circuitpython-mcp230xx==2.5.1
|
|
6
6
|
adafruit-circuitpython-pct2075==1.1.11
|
|
7
|
+
adafruit-circuitpython-mcp9808==3.3.9
|
|
7
8
|
Adafruit-PlatformDetect==3.17.2
|
|
8
9
|
Adafruit-PureIO==1.1.9
|
|
9
10
|
asyncio-mqtt==0.10.0
|
|
@@ -33,6 +33,7 @@ setup(
|
|
|
33
33
|
"Adafruit-Blinka==6.15.0",
|
|
34
34
|
"adafruit-circuitpython-mcp230xx==2.5.1",
|
|
35
35
|
"adafruit-circuitpython-pct2075==1.1.11",
|
|
36
|
+
"adafruit-circuitpython-mcp9808==3.3.9",
|
|
36
37
|
"Adafruit-PlatformDetect==3.17.2",
|
|
37
38
|
"Adafruit-PureIO==1.1.9",
|
|
38
39
|
"asyncio-mqtt==0.10.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|