boneIO 0.1.0.dev18__tar.gz → 0.1.0.dev21__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 (43) hide show
  1. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/PKG-INFO +2 -2
  2. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/helper/__init__.py +2 -0
  3. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/helper/gpio.py +3 -1
  4. boneio-0.1.0.dev21/boneio/helper/queue.py +32 -0
  5. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/helper/stats.py +3 -1
  6. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/manager.py +1 -1
  7. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/mqtt_client.py +2 -1
  8. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/oled.py +1 -1
  9. boneio-0.1.0.dev21/boneio/version.py +2 -0
  10. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio.egg-info/PKG-INFO +2 -2
  11. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio.egg-info/SOURCES.txt +3 -1
  12. boneio-0.1.0.dev21/boneio.egg-info/top_level.txt +2 -0
  13. boneio-0.1.0.dev21/example_config/__init__.py +0 -0
  14. boneio-0.1.0.dev18/boneio/version.py +0 -2
  15. boneio-0.1.0.dev18/boneio.egg-info/top_level.txt +0 -1
  16. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/MANIFEST.in +0 -0
  17. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/README.md +0 -0
  18. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/__init__.py +0 -0
  19. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/bonecli.py +0 -0
  20. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/const.py +0 -0
  21. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/fonts/danube__.ttf +0 -0
  22. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/helper/exceptions.py +0 -0
  23. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/helper/ha_discovery.py +0 -0
  24. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/helper/mqtt.py +0 -0
  25. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/helper/oled.py +0 -0
  26. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/helper/yaml.py +0 -0
  27. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/input/__init__.py +0 -0
  28. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/input/gpio.py +0 -0
  29. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/relay/__init__.py +0 -0
  30. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/relay/basic.py +0 -0
  31. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/relay/gpio.py +0 -0
  32. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/relay/mcp.py +0 -0
  33. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/schema.yaml +0 -0
  34. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/sensor/__init__.py +0 -0
  35. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/sensor/adc.py +0 -0
  36. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/sensor/gpio.py +0 -0
  37. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio/sensor/lm75.py +0 -0
  38. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio.egg-info/dependency_links.txt +0 -0
  39. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio.egg-info/entry_points.txt +0 -0
  40. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/boneio.egg-info/requires.txt +0 -0
  41. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/requirements.txt +0 -0
  42. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/setup.cfg +0 -0
  43. {boneio-0.1.0.dev18 → boneio-0.1.0.dev21}/setup.py +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneio
3
- Version: 0.1.0.dev18
3
+ Version: 0.1.0.dev21
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.dev18.zip
7
+ Download-URL: https://github.com/maciejk1984/boneIO/archive/0.1.0.dev21.zip
8
8
  Platform: UNKNOWN
9
9
  Classifier: Programming Language :: Python
10
10
  Classifier: Programming Language :: Python :: 3.7
@@ -21,6 +21,7 @@ from boneio.helper.ha_discovery import (
21
21
  ha_adc_sensor_availibilty_message,
22
22
  )
23
23
  from boneio.helper.exceptions import GPIOInputException, I2CError
24
+ from boneio.helper.queue import UniqueQueue
24
25
 
25
26
 
26
27
  __all__ = [
@@ -45,4 +46,5 @@ __all__ = [
45
46
  "GpioBaseClass",
46
47
  "configure_pin",
47
48
  "BasicMqtt",
49
+ "UniqueQueue",
48
50
  ]
@@ -52,7 +52,9 @@ def read_input(pin: str, on_state: Gpio_States = LOW):
52
52
  return GPIO.input(pin) is on_state
53
53
 
54
54
 
55
- def edge_detect(pin: str, callback: Callable, bounce: int, edge: Gpio_Edges = FALLING):
55
+ def edge_detect(
56
+ pin: str, callback: Callable, bounce: int = 0, edge: Gpio_Edges = FALLING
57
+ ):
56
58
  """Add detection for RISING and FALLING events."""
57
59
  try:
58
60
  GPIO.add_event_detect(gpio=pin, edge=edge, callback=callback, bouncetime=bounce)
@@ -0,0 +1,32 @@
1
+ """
2
+ Special unique implementation of asyncio.Queue for boneIO.
3
+ If MQTT is down then regular queue can append multiple ON/OFF for same topic.
4
+ After re-connection it would send all messages. It's not necessary, last payload of same topic is enough.
5
+ """
6
+ import asyncio
7
+
8
+
9
+ class UniqueQueue(asyncio.Queue):
10
+ """Unique implementation of asyncio.Queue."""
11
+
12
+ def _init(self, maxsize):
13
+ """Create unique dict of tuple[0]."""
14
+ super()._init(maxsize=maxsize)
15
+ self._unique_set = {}
16
+
17
+ def _put(self, item):
18
+ """If item does not exists add it.
19
+ If exists remove old one and put new one in the beginning of the queue."""
20
+ if item[0] not in self._unique_set:
21
+ super()._put(item)
22
+ self._unique_set[item[0]] = item
23
+ else:
24
+ self._queue.remove(self._unique_set[item[0]])
25
+ super()._put(item)
26
+ self._unique_set[item[0]] = item
27
+
28
+ def _get(self):
29
+ """Get item and remove it."""
30
+ item = super()._get()
31
+ del self._unique_set[item[0]]
32
+ return item
@@ -53,9 +53,11 @@ async def get_network_info(host_data):
53
53
  out["mask"] = addr.netmask
54
54
  elif addr.family == psutil.AF_LINK:
55
55
  out["mac"] = addr.address
56
+ return out
56
57
 
57
58
  while True:
58
- host_data.write(NETWORK, retrieve_from_psutil())
59
+ data = retrieve_from_psutil()
60
+ host_data.write(NETWORK, data)
59
61
  await asyncio.sleep(60)
60
62
 
61
63
 
@@ -312,7 +312,7 @@ class Manager:
312
312
  if relay:
313
313
  relay.toggle()
314
314
  # This is similar how Z2M is clearing click sensor.
315
- # self._loop.call_later(1, self.send_message, topic, "")
315
+ self._loop.call_soon_threadsafe(self.send_message, topic, "")
316
316
 
317
317
  def send_ha_autodiscovery(
318
318
  self,
@@ -13,6 +13,7 @@ from paho.mqtt.properties import Properties
13
13
  from paho.mqtt.subscribeoptions import SubscribeOptions
14
14
 
15
15
  from boneio.const import PAHO
16
+ from boneio.helper import UniqueQueue
16
17
 
17
18
  _LOGGER = logging.getLogger(__name__)
18
19
 
@@ -38,7 +39,7 @@ class MQTTClient:
38
39
  self.asyncio_client: AsyncioClient = None
39
40
  self.create_client()
40
41
  self.reconnect_interval = 1
41
- self.publish_queue: asyncio.Queue = asyncio.Queue()
42
+ self.publish_queue: UniqueQueue = UniqueQueue()
42
43
 
43
44
  def create_client(self) -> None:
44
45
  """Create the asyncio client."""
@@ -45,7 +45,7 @@ class Oled:
45
45
  self._host_data = host_data
46
46
  configure_pin(OLED_PIN)
47
47
  setup_input(OLED_PIN)
48
- edge_detect(pin=OLED_PIN, callback=self._handle_press, bounce=50)
48
+ edge_detect(pin=OLED_PIN, callback=self._handle_press, bounce=80)
49
49
  try:
50
50
  serial = i2c(port=2, address=0x3C)
51
51
  self._device = sh1106(serial)
@@ -0,0 +1,2 @@
1
+ # flake8: noqa
2
+ __version__ = "0.1.0.dev21"
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneio
3
- Version: 0.1.0.dev18
3
+ Version: 0.1.0.dev21
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.dev18.zip
7
+ Download-URL: https://github.com/maciejk1984/boneIO/archive/0.1.0.dev21.zip
8
8
  Platform: UNKNOWN
9
9
  Classifier: Programming Language :: Python
10
10
  Classifier: Programming Language :: Python :: 3.7
@@ -23,6 +23,7 @@ boneio/helper/gpio.py
23
23
  boneio/helper/ha_discovery.py
24
24
  boneio/helper/mqtt.py
25
25
  boneio/helper/oled.py
26
+ boneio/helper/queue.py
26
27
  boneio/helper/stats.py
27
28
  boneio/helper/yaml.py
28
29
  boneio/input/__init__.py
@@ -34,4 +35,5 @@ boneio/relay/mcp.py
34
35
  boneio/sensor/__init__.py
35
36
  boneio/sensor/adc.py
36
37
  boneio/sensor/gpio.py
37
- boneio/sensor/lm75.py
38
+ boneio/sensor/lm75.py
39
+ example_config/__init__.py
@@ -0,0 +1,2 @@
1
+ boneio
2
+ example_config
File without changes
@@ -1,2 +0,0 @@
1
- # flake8: noqa
2
- __version__ = "0.1.0.dev18"
@@ -1 +0,0 @@
1
- boneio
File without changes
File without changes
File without changes
File without changes