boneIO 0.1.0.dev12__tar.gz → 0.1.0.dev14__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 (38) hide show
  1. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/PKG-INFO +2 -2
  2. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/bonecli.py +10 -9
  3. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/const.py +1 -0
  4. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/helper/__init__.py +9 -5
  5. boneio-0.1.0.dev14/boneio/helper/exceptions.py +13 -0
  6. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/helper/gpio.py +11 -3
  7. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/helper/ha_discovery.py +2 -2
  8. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/helper/oled.py +1 -1
  9. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/helper/stats.py +3 -4
  10. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/helper/yaml.py +1 -1
  11. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/input/__init__.py +1 -1
  12. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/input/gpio.py +3 -2
  13. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/manager.py +69 -50
  14. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/mqtt_client.py +1 -1
  15. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/oled.py +3 -3
  16. boneio-0.1.0.dev14/boneio/relay/__init__.py +5 -0
  17. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/relay/basic.py +1 -1
  18. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/relay/gpio.py +2 -2
  19. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/relay/mcp.py +1 -1
  20. boneio-0.1.0.dev14/boneio/sensor/__init__.py +4 -0
  21. boneio-0.1.0.dev14/boneio/sensor/lm75.py +50 -0
  22. boneio-0.1.0.dev14/boneio/version.py +2 -0
  23. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio.egg-info/PKG-INFO +2 -2
  24. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio.egg-info/SOURCES.txt +4 -1
  25. boneio-0.1.0.dev12/boneio/relay/__init__.py +0 -5
  26. boneio-0.1.0.dev12/boneio/version.py +0 -2
  27. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/MANIFEST.in +0 -0
  28. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/README.md +0 -0
  29. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/__init__.py +0 -0
  30. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/fonts/danube__.ttf +0 -0
  31. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio/schema.yaml +0 -0
  32. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio.egg-info/dependency_links.txt +0 -0
  33. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio.egg-info/entry_points.txt +0 -0
  34. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio.egg-info/requires.txt +0 -0
  35. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/boneio.egg-info/top_level.txt +0 -0
  36. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/requirements.txt +0 -0
  37. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/setup.cfg +0 -0
  38. {boneio-0.1.0.dev12 → boneio-0.1.0.dev14}/setup.py +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneio
3
- Version: 0.1.0.dev12
3
+ Version: 0.1.0.dev14
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.dev12.zip
7
+ Download-URL: https://github.com/maciejk1984/boneIO/archive/0.1.0.dev14.zip
8
8
  Platform: UNKNOWN
9
9
  Classifier: Programming Language :: Python
10
10
  Classifier: Programming Language :: Python :: 3.7
@@ -6,7 +6,7 @@ from functools import wraps
6
6
  import click
7
7
  from colorlog import ColoredFormatter
8
8
 
9
- from .const import (
9
+ from boneio.const import (
10
10
  ENABLED,
11
11
  GPIO_INPUT,
12
12
  HA_DISCOVERY,
@@ -19,11 +19,12 @@ from .const import (
19
19
  PASSWORD,
20
20
  TOPIC_PREFIX,
21
21
  USERNAME,
22
+ LM75,
22
23
  )
23
- from .helper import CustomValidator, load_yaml_file
24
- from .manager import Manager
25
- from .mqtt_client import MQTTClient
26
- from .version import __version__
24
+ from boneio.helper import CustomValidator, load_yaml_file
25
+ from boneio.manager import Manager
26
+ from boneio.mqtt_client import MQTTClient
27
+ from boneio.version import __version__
27
28
 
28
29
  _LOGGER = logging.getLogger(__name__)
29
30
  logging.basicConfig(level=logging.INFO)
@@ -133,12 +134,12 @@ async def run(ctx, debug: int, config: str, mqttpassword: str = ""):
133
134
  manager = Manager(
134
135
  send_message=client.send_message,
135
136
  topic_prefix=_config[MQTT][TOPIC_PREFIX],
136
- relay_pins=_config[OUTPUT],
137
- input_pins=_config[GPIO_INPUT],
137
+ relay_pins=_config.get(OUTPUT, []),
138
+ input_pins=_config.get(GPIO_INPUT, []),
138
139
  ha_discovery=_config[MQTT][HA_DISCOVERY][ENABLED],
139
140
  ha_discovery_prefix=_config[MQTT][HA_DISCOVERY][TOPIC_PREFIX],
140
- mcp23017=_config[MCP23017],
141
- lm75=_config.get("lm75"),
141
+ mcp23017=_config.get(MCP23017, []),
142
+ lm75=_config.get(LM75),
142
143
  oled=_config.get(OLED),
143
144
  )
144
145
  tasks = set()
@@ -60,3 +60,4 @@ INIT_SLEEP = "init_sleep"
60
60
  INPUT = "input"
61
61
  TEMPERATURE = "temperature"
62
62
  SENSOR = "sensor"
63
+ LM75="lm75"
@@ -1,13 +1,14 @@
1
1
  """Helper dir for BoneIO."""
2
- from .gpio import edge_detect, setup_input
3
- from .oled import make_font
4
- from .stats import HostData, host_stats
5
- from .yaml import CustomValidator, load_yaml_file
6
- from .ha_discovery import (
2
+ from boneio.helper.gpio import edge_detect, setup_input, read_input
3
+ from boneio.helper.oled import make_font
4
+ from boneio.helper.stats import HostData, host_stats
5
+ from boneio.helper.yaml import CustomValidator, load_yaml_file
6
+ from boneio.helper.ha_discovery import (
7
7
  ha_relay_availibilty_message,
8
8
  ha_sensor_availibilty_message,
9
9
  ha_sensor_temp_availibilty_message,
10
10
  )
11
+ from boneio.helper.exceptions import GPIOInputException, I2CError
11
12
 
12
13
  __all__ = [
13
14
  "CustomValidator",
@@ -16,8 +17,11 @@ __all__ = [
16
17
  "host_stats",
17
18
  "setup_input",
18
19
  "edge_detect",
20
+ "read_input",
19
21
  "make_font",
20
22
  "ha_relay_availibilty_message",
21
23
  "ha_sensor_availibilty_message",
22
24
  "ha_sensor_temp_availibilty_message",
25
+ "GPIOInputException",
26
+ "I2CError",
23
27
  ]
@@ -0,0 +1,13 @@
1
+ """BoneIO Errors"""
2
+
3
+
4
+ class BoneIOException(Exception):
5
+ """BoneIO standard exception."""
6
+
7
+
8
+ class GPIOInputException(BoneIOException):
9
+ """GPIOInput Exception."""
10
+
11
+
12
+ class I2CError(BoneIOException):
13
+ """I2C Exception."""
@@ -1,6 +1,9 @@
1
+ import logging
1
2
  from Adafruit_BBIO import GPIO
2
3
  from Adafruit_BBIO.GPIO import HIGH, LOW
3
4
 
5
+ from boneio.helper.exceptions import GPIOInputException
6
+
4
7
 
5
8
  def setup_output(pin: str):
6
9
  """Set up a GPIO as output."""
@@ -10,7 +13,10 @@ def setup_output(pin: str):
10
13
 
11
14
  def setup_input(pin: str, pull_mode: str = "UP"):
12
15
  """Set up a GPIO as input."""
13
- GPIO.setup(pin, GPIO.IN, GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP)
16
+ try:
17
+ GPIO.setup(pin, GPIO.IN, GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP)
18
+ except (ValueError, SystemError) as err:
19
+ raise GPIOInputException(err)
14
20
 
15
21
 
16
22
  def write_output(pin: str, value: str):
@@ -26,5 +32,7 @@ def read_input(pin: str, on_state=LOW):
26
32
 
27
33
  def edge_detect(pin, callback, bounce):
28
34
  """Add detection for RISING and FALLING events."""
29
-
30
- GPIO.add_event_detect(pin, GPIO.FALLING, callback=callback, bouncetime=bounce)
35
+ try:
36
+ GPIO.add_event_detect(pin, GPIO.FALLING, callback=callback, bouncetime=bounce)
37
+ except RuntimeError as err:
38
+ raise GPIOInputException(err)
@@ -1,7 +1,7 @@
1
- from ..version import __version__
1
+ from boneio.version import __version__
2
2
 
3
3
 
4
- from ..const import INPUT, OFF, ON, RELAY, STATE, SENSOR
4
+ from boneio.const import INPUT, OFF, ON, RELAY, STATE, SENSOR
5
5
 
6
6
 
7
7
  def ha_relay_availibilty_message(id: str, name: str, topic: str = "boneio"):
@@ -2,7 +2,7 @@ import os
2
2
 
3
3
  from PIL import ImageFont
4
4
 
5
- from ..const import FONTS
5
+ from boneio.const import FONTS
6
6
 
7
7
 
8
8
  def make_font(name: str, size: int, local: bool = False):
@@ -7,7 +7,7 @@ from typing import Callable
7
7
 
8
8
  import psutil
9
9
 
10
- from ..const import (
10
+ from boneio.const import (
11
11
  CPU,
12
12
  DISK,
13
13
  GIGABYTE,
@@ -16,10 +16,9 @@ from ..const import (
16
16
  MEMORY,
17
17
  NETWORK,
18
18
  SWAP,
19
- TEMPERATURE,
20
19
  UPTIME,
21
20
  )
22
- from ..sensor.lm75 import LM75
21
+ from boneio.sensor import LM75Sensor
23
22
 
24
23
  intervals = (("d", 86400), ("h", 3600), ("m", 60))
25
24
 
@@ -132,7 +131,7 @@ class HostData:
132
131
 
133
132
  data = {UPTIME: {}, NETWORK: {}, CPU: {}, DISK: {}, MEMORY: {}, SWAP: {}}
134
133
 
135
- def __init__(self, output: dict, callback: Callable, lm75: LM75) -> None:
134
+ def __init__(self, output: dict, callback: Callable, lm75: LM75Sensor) -> None:
136
135
  """Initialize HostData."""
137
136
  self._hostname = socket.gethostname()
138
137
  self.data[UPTIME] = {HOST: self._hostname, UPTIME: 0}
@@ -1,7 +1,7 @@
1
1
  from typing import Any
2
2
  import os
3
3
  from cerberus import Validator
4
- from ..const import ID, OLED, OUTPUT
4
+ from boneio.const import ID, OLED, OUTPUT
5
5
  from yaml import load, YAMLError, SafeLoader
6
6
 
7
7
 
@@ -1,5 +1,5 @@
1
1
  """Input classes."""
2
2
 
3
- from .gpio import GpioInputButton, configure_pin
3
+ from boneio.input.gpio import GpioInputButton, configure_pin
4
4
 
5
5
  __all__ = ["GpioInputButton", "configure_pin"]
@@ -6,7 +6,7 @@ from datetime import datetime
6
6
  from functools import partial
7
7
  from typing import Callable
8
8
 
9
- from ..const import (
9
+ from boneio.const import (
10
10
  CONFIG_PIN,
11
11
  DEBOUNCE_DURATION,
12
12
  DELAY_DURATION,
@@ -18,7 +18,7 @@ from ..const import (
18
18
  SINGLE,
19
19
  ClickTypes,
20
20
  )
21
- from ..helper.gpio import edge_detect, read_input, setup_input
21
+ from boneio.helper import edge_detect, read_input, setup_input
22
22
 
23
23
  _LOGGER = logging.getLogger(__name__)
24
24
 
@@ -30,6 +30,7 @@ def configure_pin(pin: str) -> None:
30
30
  [CONFIG_PIN, pin, GPIO],
31
31
  stdout=subprocess.DEVNULL,
32
32
  stderr=subprocess.STDOUT,
33
+ timeout=1,
33
34
  )
34
35
 
35
36
 
@@ -7,7 +7,7 @@ from adafruit_mcp230xx.mcp23017 import MCP23017
7
7
  from board import SCL, SDA
8
8
  from busio import I2C
9
9
 
10
- from .const import (
10
+ from boneio.const import (
11
11
  ACTION,
12
12
  ACTIONS,
13
13
  ADDRESS,
@@ -29,16 +29,18 @@ from .const import (
29
29
  STATE,
30
30
  ClickTypes,
31
31
  )
32
- from .helper import (
32
+ from boneio.helper import (
33
33
  HostData,
34
34
  ha_relay_availibilty_message,
35
35
  ha_sensor_availibilty_message,
36
36
  ha_sensor_temp_availibilty_message,
37
37
  host_stats,
38
+ GPIOInputException,
39
+ I2CError,
38
40
  )
39
- from .input import GpioInputButton
40
- from .oled import Oled
41
- from .relay import GpioRelay, MCPRelay
41
+ from boneio.input import GpioInputButton
42
+ from boneio.oled import Oled
43
+ from boneio.relay import GpioRelay, MCPRelay
42
44
 
43
45
  _LOGGER = logging.getLogger(__name__)
44
46
 
@@ -76,38 +78,46 @@ class Manager:
76
78
 
77
79
  def create_lm75_sensor():
78
80
  """Create LM sensor in manager."""
79
- from .sensor.lm75 import LM75
81
+ from .sensor.lm75 import LM75Sensor
80
82
 
81
83
  name = lm75.get(ID)
82
84
  id = name.replace(" ", "")
83
- self._lm75 = LM75(
84
- id=id,
85
- name=name,
86
- i2c=self._i2cbusio,
87
- address=lm75[ADDRESS],
88
- send_message=self.send_message,
89
- topic_prefix=topic_prefix,
90
- )
91
- self.send_ha_autodiscovery(
92
- id=id,
93
- name=name,
94
- ha_type="sensor",
95
- prefix=ha_discovery_prefix,
96
- availibilty_msg_func=ha_sensor_temp_availibilty_message,
97
- )
98
- self._tasks.append(asyncio.create_task(self._lm75.send_state()))
85
+ try:
86
+ self._lm75 = LM75Sensor(
87
+ id=id,
88
+ name=name,
89
+ i2c=self._i2cbusio,
90
+ address=lm75[ADDRESS],
91
+ send_message=self.send_message,
92
+ topic_prefix=topic_prefix,
93
+ )
94
+ self.send_ha_autodiscovery(
95
+ id=id,
96
+ name=name,
97
+ ha_type="sensor",
98
+ prefix=ha_discovery_prefix,
99
+ availibilty_msg_func=ha_sensor_temp_availibilty_message,
100
+ )
101
+ self._tasks.append(asyncio.create_task(self._lm75.send_state()))
102
+ except I2CError as err:
103
+ _LOGGER.error("Can't configure LM75 sensor. %s", err)
104
+ pass
99
105
 
100
106
  def create_mcp23017():
101
107
  """Create MCP23017."""
102
108
  for mcp in mcp23017:
103
109
  id = mcp[ID] or mcp[ADDRESS]
104
- self._mcp[id] = MCP23017(i2c=self._i2cbusio, address=mcp[ADDRESS])
105
- sleep_time = mcp.get(INIT_SLEEP, 0)
106
- _LOGGER.debug(
107
- f"Sleeping for {sleep_time}s while MCP {id} is initializing."
108
- )
109
- time.sleep(sleep_time)
110
- self._grouped_outputs[id] = {}
110
+ try:
111
+ self._mcp[id] = MCP23017(i2c=self._i2cbusio, address=mcp[ADDRESS])
112
+ sleep_time = mcp.get(INIT_SLEEP, 0)
113
+ _LOGGER.debug(
114
+ f"Sleeping for {sleep_time}s while MCP {id} is initializing."
115
+ )
116
+ time.sleep(sleep_time)
117
+ self._grouped_outputs[id] = {}
118
+ except TimeoutError as err:
119
+ _LOGGER.error("Can't connect to MCP %s. %s", id, err)
120
+ pass
111
121
 
112
122
  if lm75:
113
123
  create_lm75_sensor()
@@ -168,22 +178,28 @@ class Manager:
168
178
  )
169
179
 
170
180
  def configure_button(gpio):
171
- pin = gpio[PIN]
172
- button = GpioInputButton(
173
- pin=pin,
174
- press_callback=lambda x, i: self.press_callback(x, i, gpio[ACTIONS]),
175
- rest_pin=gpio,
176
- )
177
- self.send_ha_autodiscovery(
178
- id=pin,
179
- name=gpio.get(ID, pin),
180
- ha_type="sensor",
181
- prefix=ha_discovery_prefix,
182
- availibilty_msg_func=ha_sensor_availibilty_message,
183
- )
184
- return button
181
+ try:
182
+ pin = gpio[PIN]
183
+ GpioInputButton(
184
+ pin=pin,
185
+ press_callback=lambda x, i: self.press_callback(
186
+ x, i, gpio.get(ACTIONS, {})
187
+ ),
188
+ rest_pin=gpio,
189
+ )
190
+ self.send_ha_autodiscovery(
191
+ id=pin,
192
+ name=gpio.get(ID, pin),
193
+ ha_type="sensor",
194
+ prefix=ha_discovery_prefix,
195
+ availibilty_msg_func=ha_sensor_availibilty_message,
196
+ )
197
+ except GPIOInputException as err:
198
+ _LOGGER.error("This PIN %s can't be configured. %s", pin, err)
199
+ pass
185
200
 
186
- self.buttons = [configure_button(gpio=gpio) for gpio in self._input_pins]
201
+ for gpio in self._input_pins:
202
+ configure_button(gpio=gpio)
187
203
 
188
204
  if oled:
189
205
  self._host_data = HostData(
@@ -194,9 +210,12 @@ class Manager:
194
210
  for f in host_stats.values():
195
211
  self._tasks.append(asyncio.create_task(f(self._host_data)))
196
212
  _LOGGER.debug("Gathering host data enabled.")
197
- self._oled = Oled(
198
- host_data=self._host_data, output_groups=list(self._grouped_outputs)
199
- )
213
+ try:
214
+ self._oled = Oled(
215
+ host_data=self._host_data, output_groups=list(self._grouped_outputs)
216
+ )
217
+ except GPIOInputException as err:
218
+ _LOGGER.error("Can't configure OLED display. %s", err)
200
219
 
201
220
  self.send_message(topic=f"{topic_prefix}/{STATE}", payload=ONLINE)
202
221
  _LOGGER.info("BoneIO manager is ready.")
@@ -217,9 +236,9 @@ class Manager:
217
236
  if action:
218
237
  if action[ACTION] == OUTPUT:
219
238
  """For now only output type is supported"""
220
- output_gpio = self.output.get(action[PIN])
221
- if output_gpio:
222
- output_gpio.toggle()
239
+ relay = self.output.get(action[PIN].replace(" ", ""))
240
+ if relay:
241
+ relay.toggle()
223
242
  # This is similar how Z2M is clearing click sensor.
224
243
  # self._loop.call_later(1, self.send_message, topic, "")
225
244
 
@@ -12,7 +12,7 @@ from asyncio_mqtt import MqttError
12
12
  from paho.mqtt.properties import Properties
13
13
  from paho.mqtt.subscribeoptions import SubscribeOptions
14
14
 
15
- from .const import PAHO
15
+ from boneio.const import PAHO
16
16
 
17
17
  _LOGGER = logging.getLogger(__name__)
18
18
 
@@ -7,9 +7,9 @@ from luma.core.render import canvas
7
7
  from luma.oled.device import sh1106
8
8
  from PIL import ImageDraw
9
9
 
10
- from .const import CPU, DISK, MEMORY, NETWORK, OLED_PIN, SWAP, UPTIME, WHITE
11
- from .helper import HostData, edge_detect, make_font, setup_input
12
- from .input import configure_pin
10
+ from boneio.const import CPU, DISK, MEMORY, NETWORK, OLED_PIN, SWAP, UPTIME, WHITE
11
+ from boneio.helper import HostData, edge_detect, make_font, setup_input
12
+ from boneio.input import configure_pin
13
13
 
14
14
  _LOGGER = logging.getLogger(__name__)
15
15
 
@@ -0,0 +1,5 @@
1
+ """Relay module."""
2
+ from boneio.relay.gpio import GpioRelay
3
+ from boneio.relay.mcp import MCPRelay
4
+
5
+ __all__ = ["MCPRelay", "GpioRelay"]
@@ -4,7 +4,7 @@ import asyncio
4
4
  import logging
5
5
  from typing import Callable, Union
6
6
 
7
- from ..const import OFF, ON, RELAY, STATE, SWITCH
7
+ from boneio.const import OFF, ON, RELAY, STATE, SWITCH
8
8
 
9
9
  _LOGGER = logging.getLogger(__name__)
10
10
 
@@ -5,8 +5,8 @@ Created just in case.
5
5
 
6
6
  import logging
7
7
 
8
- from ..helper.gpio import HIGH, LOW, read_input, setup_output, write_output
9
- from .basic import BasicRelay
8
+ from boneio.helper.gpio import HIGH, LOW, read_input, setup_output, write_output
9
+ from boneio.relay.basic import BasicRelay
10
10
 
11
11
  _LOGGER = logging.getLogger(__name__)
12
12
 
@@ -4,7 +4,7 @@ import logging
4
4
 
5
5
  from adafruit_mcp230xx.mcp23017 import MCP23017
6
6
 
7
- from .basic import BasicRelay
7
+ from boneio.relay.basic import BasicRelay
8
8
 
9
9
  _LOGGER = logging.getLogger(__name__)
10
10
 
@@ -0,0 +1,4 @@
1
+ """Sensor module."""
2
+ from boneio.sensor.lm75 import LM75Sensor
3
+
4
+ __all__ = ["LM75Sensor"]
@@ -0,0 +1,50 @@
1
+ """Manage LM75 sensor."""
2
+
3
+ import asyncio
4
+ from adafruit_pct2075 import PCT2075
5
+ from typing import Callable, Union
6
+ from boneio.const import STATE, SENSOR, LM75
7
+
8
+ from boneio.helper.exceptions import I2CError
9
+
10
+
11
+ class LM75Sensor:
12
+ """Represent LM75 sensor in BoneIO."""
13
+
14
+ def __init__(
15
+ self,
16
+ i2c,
17
+ address,
18
+ topic_prefix: str,
19
+ name: str,
20
+ send_message: Callable[[str, Union[str, dict]], None],
21
+ id: str = LM75,
22
+ ):
23
+ """Initialize LM75 class."""
24
+ self._id = id
25
+ self._name = name
26
+ self._send_message = send_message
27
+ self._send_topic = f"{topic_prefix}/{SENSOR}/{self._id}"
28
+ try:
29
+ self._pct = PCT2075(i2c_bus=i2c, address=address)
30
+ except ValueError as err:
31
+ raise I2CError(err)
32
+
33
+ @property
34
+ def name(self):
35
+ """Return name of the sensor."""
36
+ return self._name
37
+
38
+ @property
39
+ def state(self):
40
+ """Give rounded value of temperature."""
41
+ return round(self._pct.temperature, 2)
42
+
43
+ async def send_state(self):
44
+ """Fetch temperature periodically and send to MQTT."""
45
+ while True:
46
+ self._send_message(
47
+ topic=self._send_topic,
48
+ payload={STATE: self.state},
49
+ )
50
+ await asyncio.sleep(60)
@@ -0,0 +1,2 @@
1
+ # flake8: noqa
2
+ __version__ = "0.1.0.dev14"
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneio
3
- Version: 0.1.0.dev12
3
+ Version: 0.1.0.dev14
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.dev12.zip
7
+ Download-URL: https://github.com/maciejk1984/boneIO/archive/0.1.0.dev14.zip
8
8
  Platform: UNKNOWN
9
9
  Classifier: Programming Language :: Python
10
10
  Classifier: Programming Language :: Python :: 3.7
@@ -18,6 +18,7 @@ boneio.egg-info/requires.txt
18
18
  boneio.egg-info/top_level.txt
19
19
  boneio/fonts/danube__.ttf
20
20
  boneio/helper/__init__.py
21
+ boneio/helper/exceptions.py
21
22
  boneio/helper/gpio.py
22
23
  boneio/helper/ha_discovery.py
23
24
  boneio/helper/oled.py
@@ -28,4 +29,6 @@ boneio/input/gpio.py
28
29
  boneio/relay/__init__.py
29
30
  boneio/relay/basic.py
30
31
  boneio/relay/gpio.py
31
- boneio/relay/mcp.py
32
+ boneio/relay/mcp.py
33
+ boneio/sensor/__init__.py
34
+ boneio/sensor/lm75.py
@@ -1,5 +0,0 @@
1
- """Relay module."""
2
- from .gpio import GpioRelay
3
- from .mcp import MCPRelay
4
-
5
- __all__ = ["MCPRelay", "GpioRelay"]
@@ -1,2 +0,0 @@
1
- # flake8: noqa
2
- __version__ = "0.1.0.dev12"
File without changes
File without changes
File without changes
File without changes