boneIO 0.1.0.dev23__tar.gz → 0.1.0.dev24__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.
Files changed (49) hide show
  1. {boneio-0.1.0.dev23/boneio.egg-info → boneio-0.1.0.dev24}/PKG-INFO +2 -2
  2. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/bonecli.py +2 -2
  3. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/const.py +1 -0
  4. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/helper/stats.py +6 -5
  5. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/manager.py +22 -11
  6. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/schema.yaml +17 -0
  7. boneio-0.1.0.dev24/boneio/sensor/__init__.py +6 -0
  8. boneio-0.1.0.dev23/boneio/sensor/lm75.py → boneio-0.1.0.dev24/boneio/sensor/temp/__init__.py +26 -6
  9. boneio-0.1.0.dev24/boneio/version.py +2 -0
  10. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24/boneio.egg-info}/PKG-INFO +2 -2
  11. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio.egg-info/SOURCES.txt +1 -1
  12. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio.egg-info/requires.txt +1 -0
  13. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/requirements.txt +1 -0
  14. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/setup.py +1 -0
  15. boneio-0.1.0.dev23/boneio/sensor/__init__.py +0 -6
  16. boneio-0.1.0.dev23/boneio/version.py +0 -2
  17. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/LICENSE +0 -0
  18. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/MANIFEST.in +0 -0
  19. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/README.md +0 -0
  20. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/__init__.py +0 -0
  21. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/fonts/danube__.ttf +0 -0
  22. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/helper/__init__.py +0 -0
  23. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/helper/exceptions.py +0 -0
  24. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/helper/gpio.py +0 -0
  25. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/helper/ha_discovery.py +0 -0
  26. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/helper/mqtt.py +0 -0
  27. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/helper/oled.py +0 -0
  28. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/helper/queue.py +0 -0
  29. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/helper/yaml.py +0 -0
  30. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/input/__init__.py +0 -0
  31. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/input/gpio.py +0 -0
  32. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/mqtt_client.py +0 -0
  33. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/oled.py +0 -0
  34. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/relay/__init__.py +0 -0
  35. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/relay/basic.py +0 -0
  36. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/relay/gpio.py +0 -0
  37. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/relay/mcp.py +0 -0
  38. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/sensor/adc.py +0 -0
  39. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio/sensor/gpio.py +0 -0
  40. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio.egg-info/dependency_links.txt +0 -0
  41. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio.egg-info/entry_points.txt +0 -0
  42. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/boneio.egg-info/top_level.txt +0 -0
  43. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/example_config/__init__.py +0 -0
  44. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/example_config/adc.yaml +0 -0
  45. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/example_config/config.yaml +0 -0
  46. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/example_config/input.yaml +0 -0
  47. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/example_config/output24x16A.yaml +0 -0
  48. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/example_config/output32x5A.yaml +0 -0
  49. {boneio-0.1.0.dev23 → boneio-0.1.0.dev24}/setup.cfg +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneio
3
- Version: 0.1.0.dev23
3
+ Version: 0.1.0.dev24
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.dev23.zip
7
+ Download-URL: https://github.com/maciejk1984/boneIO/archive/0.1.0.dev24.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
  )
@@ -84,6 +84,7 @@ TEMPERATURE = "temperature"
84
84
  SENSOR = "sensor"
85
85
  BINARY_SENSOR = "binary_sensor"
86
86
  LM75 = "lm75"
87
+ MCP_TEMP_9808 = "mcp9808"
87
88
  INPUT_SENSOR = "inputsensor"
88
89
 
89
90
  # TYPING
@@ -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, lm75: LM75Sensor) -> None:
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._lm75 = lm75
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._lm75:
165
- self.data[UPTIME][self._lm75.name] = self._lm75.state
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._lm75 = None
90
+ self._temp_sensors = []
88
91
 
89
- def create_lm75_sensor():
92
+ def create_temp_sensor(sensor_type: str, temp_def: dict = {}):
90
93
  """Create LM sensor in manager."""
91
- from .sensor.lm75 import LM75Sensor
92
-
93
- name = lm75.get(ID)
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
- self._lm75 = LM75Sensor(
103
+ temp_sensor = TempSensor(
97
104
  id=id,
98
105
  name=name,
99
106
  i2c=self._i2cbusio,
100
- address=lm75[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(self._lm75.send_state()))
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 LM75 sensor. %s", err)
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
- create_lm75_sensor()
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
- lm75=self._lm75,
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"]
@@ -1,21 +1,30 @@
1
- """Manage LM75 sensor."""
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 LM75Sensor(BasicMqtt):
12
- """Represent LM75 sensor in BoneIO."""
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 = LM75, **kwargs):
15
- """Initialize LM75 class."""
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 = PCT2075(i2c_bus=i2c, address=address)
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
@@ -0,0 +1,2 @@
1
+ # flake8: noqa
2
+ __version__ = "0.1.0.dev24"
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneio
3
- Version: 0.1.0.dev23
3
+ Version: 0.1.0.dev24
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.dev23.zip
7
+ Download-URL: https://github.com/maciejk1984/boneIO/archive/0.1.0.dev24.zip
8
8
  Platform: UNKNOWN
9
9
  Classifier: Programming Language :: Python
10
10
  Classifier: Programming Language :: Python :: 3.7
@@ -36,7 +36,7 @@ boneio/relay/mcp.py
36
36
  boneio/sensor/__init__.py
37
37
  boneio/sensor/adc.py
38
38
  boneio/sensor/gpio.py
39
- boneio/sensor/lm75.py
39
+ boneio/sensor/temp/__init__.py
40
40
  example_config/__init__.py
41
41
  example_config/adc.yaml
42
42
  example_config/config.yaml
@@ -2,6 +2,7 @@ Adafruit-BBIO==1.2.0
2
2
  Adafruit-Blinka==6.15.0
3
3
  adafruit-circuitpython-mcp230xx==2.5.1
4
4
  adafruit-circuitpython-pct2075==1.1.11
5
+ adafruit-circuitpython-mcp9808==3.3.9
5
6
  Adafruit-PlatformDetect==3.17.2
6
7
  Adafruit-PureIO==1.1.9
7
8
  asyncio-mqtt==0.10.0
@@ -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",
@@ -1,6 +0,0 @@
1
- """Sensor module."""
2
- from boneio.sensor.lm75 import LM75Sensor
3
- from boneio.sensor.gpio import GpioInputSensor
4
- from boneio.sensor.adc import initialize_adc, GpioADCSensor
5
-
6
- __all__ = ["LM75Sensor", "GpioInputSensor", "initialize_adc", "GpioADCSensor"]
@@ -1,2 +0,0 @@
1
- # flake8: noqa
2
- __version__ = "0.1.0.dev23"
File without changes
File without changes
File without changes
File without changes