boneIO 0.3.0.dev6__tar.gz → 0.3.0.dev8__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 (72) hide show
  1. {boneio-0.3.0.dev6/boneio.egg-info → boneio-0.3.0.dev8}/PKG-INFO +2 -2
  2. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/const.py +5 -6
  3. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/example_config/config.yaml +2 -2
  4. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/example_config/cover.yaml +2 -2
  5. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/config.py +11 -0
  6. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/exceptions.py +4 -0
  7. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/gpio.py +1 -1
  8. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/loader.py +0 -1
  9. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/input/gpio.py +8 -7
  10. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/manager.py +13 -5
  11. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/modbus.py +7 -2
  12. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/schema/schema.yaml +1 -0
  13. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/modbus/__init__.py +13 -13
  14. boneio-0.3.0.dev8/boneio/version.py +2 -0
  15. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8/boneio.egg-info}/PKG-INFO +2 -2
  16. boneio-0.3.0.dev6/boneio/version.py +0 -2
  17. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/LICENSE +0 -0
  18. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/MANIFEST.in +0 -0
  19. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/README.md +0 -0
  20. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/__init__.py +0 -0
  21. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/bonecli.py +0 -0
  22. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/cover.py +0 -0
  23. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/example_config/__init__.py +0 -0
  24. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/example_config/adc.yaml +0 -0
  25. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/example_config/input.yaml +0 -0
  26. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/example_config/output24x16A.yaml +0 -0
  27. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/example_config/output32x5A.yaml +0 -0
  28. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/fonts/danube__.ttf +0 -0
  29. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/__init__.py +0 -0
  30. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/ds2482/__init__.py +0 -0
  31. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/ds2482/ds2482.py +0 -0
  32. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/ds2482/onewire.py +0 -0
  33. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/events.py +0 -0
  34. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/ha_discovery.py +0 -0
  35. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/logger.py +0 -0
  36. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/mqtt.py +0 -0
  37. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/oled.py +0 -0
  38. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/queue.py +0 -0
  39. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/state_manager.py +0 -0
  40. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/stats.py +0 -0
  41. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/timeperiod.py +0 -0
  42. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/util.py +0 -0
  43. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/helper/yaml_util.py +0 -0
  44. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/input/__init__.py +0 -0
  45. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/mqtt_client.py +0 -0
  46. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/oled.py +0 -0
  47. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/relay/__init__.py +0 -0
  48. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/relay/basic.py +0 -0
  49. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/relay/gpio.py +0 -0
  50. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/relay/mcp.py +0 -0
  51. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/runner.py +0 -0
  52. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/schema/actions.yaml +0 -0
  53. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/schema/actions_sensor.yaml +0 -0
  54. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/schema/actions_switch.yaml +0 -0
  55. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/__init__.py +0 -0
  56. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/adc.py +0 -0
  57. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/gpio.py +0 -0
  58. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/modbus/sdm120.json +0 -0
  59. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/modbus/sdm630.json +0 -0
  60. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/modbus/sofar.json +0 -0
  61. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/temp/__init__.py +0 -0
  62. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/temp/dallas.py +0 -0
  63. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/temp/lm75.py +0 -0
  64. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio/sensor/temp/mcp9808.py +0 -0
  65. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio.egg-info/SOURCES.txt +0 -0
  66. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio.egg-info/dependency_links.txt +0 -0
  67. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio.egg-info/entry_points.txt +0 -0
  68. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio.egg-info/requires.txt +0 -0
  69. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/boneio.egg-info/top_level.txt +0 -0
  70. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/requirements.txt +0 -0
  71. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/setup.cfg +0 -0
  72. {boneio-0.3.0.dev6 → boneio-0.3.0.dev8}/setup.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneio
3
- Version: 0.3.0.dev6
3
+ Version: 0.3.0.dev8
4
4
  Summary: Python App for BoneIO
5
5
  Home-page: https://github.com/boneIO-eu/app_bbb
6
- Download-URL: https://github.com/boneIO-eu/app_bbb/archive/0.3.0.dev6.zip
6
+ Download-URL: https://github.com/boneIO-eu/app_bbb/archive/0.3.0.dev8.zip
7
7
  License: GNU General Public License v3.0
8
8
  Platform: UNKNOWN
9
9
  Classifier: Programming Language :: Python
@@ -2,12 +2,13 @@
2
2
  from datetime import timedelta
3
3
 
4
4
  try:
5
- from Adafruit_BBIO.GPIO import HIGH, LOW, BOTH, FALLING
5
+ from Adafruit_BBIO.GPIO import HIGH, LOW, BOTH, FALLING, RISING
6
6
  except ModuleNotFoundError:
7
7
  HIGH = "high"
8
8
  LOW = "low"
9
9
  BOTH = "both"
10
10
  FALLING = "falling"
11
+ RISING = "rising"
11
12
  pass
12
13
  from typing_extensions import Literal
13
14
 
@@ -47,14 +48,12 @@ RESTORE_STATE = "restore_state"
47
48
  MODEL = "model"
48
49
  UARTS = {
49
50
  "uart1": {ID: "/dev/ttyS1", TX: "P9.24", RX: "P9.26"},
51
+ "uart2": {ID: "/dev/ttyS2", TX: "P9.21", RX: "P9.22"},
52
+ "uart3": {ID: "/dev/ttyS3", TX: "P9.42", RX: None},
50
53
  "uart4": {ID: "/dev/ttyS4", TX: "P9.13", RX: "P9.11"},
54
+ "uart5": {ID: "/dev/ttyS5", TX: "P8.37", RX: "P8.38"},
51
55
  }
52
56
 
53
- # TIMINGS FOR BUTTONS
54
- DEBOUNCE_DURATION = timedelta(seconds=0.2)
55
- LONG_PRESS_DURATION = timedelta(seconds=0.7)
56
- DELAY_DURATION = 0.1
57
- SECOND_DELAY_DURATION = 0.3
58
57
 
59
58
  # HA CONSTS
60
59
  HOMEASSISTANT = "homeassistant"
@@ -9,8 +9,8 @@ mqtt:
9
9
  oled:
10
10
 
11
11
  lm75:
12
- id: temp
13
- address: 0x48
12
+ - id: temp
13
+ address: 0x48
14
14
 
15
15
  mcp23017:
16
16
  - id: mcp1
@@ -2,7 +2,7 @@ cover:
2
2
  - id: kitchen
3
3
  open_relay: test1
4
4
  close_relay: test2
5
- open_time: 20
6
- close_time: 22
5
+ open_time: 20s
6
+ close_time: 22s
7
7
  show_in_ha: yes
8
8
  restore_state: yes
@@ -2,6 +2,7 @@
2
2
  Module to provide basic config options.
3
3
  """
4
4
  from boneio.const import BONEIO, HOMEASSISTANT
5
+ from _collections_abc import dict_values
5
6
 
6
7
 
7
8
  class ConfigHelper:
@@ -14,6 +15,7 @@ class ConfigHelper:
14
15
  self._topic_prefix = topic_prefix
15
16
  self._ha_discovery = ha_discovery
16
17
  self._ha_discovery_prefix = ha_discovery_prefix
18
+ self._autodiscovery_messages = {}
17
19
 
18
20
  @property
19
21
  def topic_prefix(self) -> str:
@@ -34,3 +36,12 @@ class ConfigHelper:
34
36
  @property
35
37
  def subscribe_topic(self) -> str:
36
38
  return f"{self.cmd_topic_prefix}+/+/#"
39
+
40
+ def add_autodiscovery_msg(self, topic: str, payload: str):
41
+ """Add autodiscovery message."""
42
+ self._autodiscovery_messages[topic] = {"topic": topic, "payload": payload}
43
+
44
+ @property
45
+ def autodiscovery_msgs(self) -> dict_values:
46
+ """Get autodiscovery messages"""
47
+ return self._autodiscovery_messages.values()
@@ -23,3 +23,7 @@ class ConfigurationException(BoneIOException):
23
23
 
24
24
  class CoverRelayException(BoneIOException):
25
25
  """Cover configuration exception."""
26
+
27
+
28
+ class ModbusUartException(BoneIOException):
29
+ """Cover configuration exception."""
@@ -97,7 +97,7 @@ class GpioBaseClass:
97
97
  self._pin = pin
98
98
  gpio = kwargs.get("rest_pin", {GPIO_MODE: GPIO_STR})
99
99
  gpio_mode = gpio.get(GPIO_MODE, GPIO_STR)
100
- self._bounce_time = gpio.get("bounce_time", TimePeriod(milliseconds=25))
100
+ self._bounce_time = gpio.get("bounce_time", TimePeriod(milliseconds=10))
101
101
  self._loop = asyncio.get_running_loop()
102
102
  self._press_callback = press_callback
103
103
  setup_input(pin=self._pin, pull_mode=gpio_mode)
@@ -127,7 +127,6 @@ def create_temp_sensor(
127
127
  ha_type=SENSOR,
128
128
  availability_msg_func=ha_sensor_temp_availabilty_message,
129
129
  )
130
- manager.append_task(asyncio.create_task(temp_sensor.send_state()))
131
130
  return temp_sensor
132
131
  except I2CError as err:
133
132
  _LOGGER.error("Can't configure Temp sensor. %s", err)
@@ -1,19 +1,21 @@
1
1
  """GPIOInputButton to receive signals."""
2
2
  import logging
3
- from datetime import datetime
3
+ from datetime import datetime, timedelta
4
4
  from functools import partial
5
5
 
6
6
  from boneio.const import (
7
- DEBOUNCE_DURATION,
8
- DELAY_DURATION,
9
7
  DOUBLE,
10
8
  LONG,
11
- LONG_PRESS_DURATION,
12
- SECOND_DELAY_DURATION,
13
9
  SINGLE,
14
10
  )
15
11
  from boneio.helper import edge_detect, GpioBaseClass
16
12
 
13
+ # TIMINGS FOR BUTTONS
14
+ DEBOUNCE_DURATION = timedelta(microseconds=150000)
15
+ LONG_PRESS_DURATION = timedelta(microseconds=700000)
16
+ DELAY_DURATION = 0.08
17
+ SECOND_DELAY_DURATION = 0.14
18
+
17
19
  _LOGGER = logging.getLogger(__name__)
18
20
 
19
21
 
@@ -54,7 +56,6 @@ class GpioInputButton(GpioBaseClass):
54
56
  and now - self._second_press_timestamp < DEBOUNCE_DURATION
55
57
  ):
56
58
  return
57
-
58
59
  if not self._first_press_timestamp:
59
60
  self._first_press_timestamp = now
60
61
  elif not self._second_press_timestamp:
@@ -105,7 +106,7 @@ class GpioInputButton(GpioBaseClass):
105
106
  if self._second_check:
106
107
  if self._second_press_timestamp:
107
108
  _LOGGER.debug(
108
- "Double click event on pin %s, roznica %s",
109
+ "Double click event on pin %s, diff %s",
109
110
  self._pin,
110
111
  self._second_press_timestamp - self._first_press_timestamp,
111
112
  )
@@ -46,6 +46,7 @@ from boneio.helper import (
46
46
 
47
47
  from boneio.helper.config import ConfigHelper
48
48
  from boneio.helper.events import EventBus
49
+ from boneio.helper.exceptions import ModbusUartException
49
50
  from boneio.helper.loader import (
50
51
  configure_cover,
51
52
  configure_input,
@@ -107,7 +108,14 @@ class Manager:
107
108
  self._temp_sensors = []
108
109
  self._modbus = None
109
110
  if modbus and modbus.get(UART) in UARTS:
110
- self._modbus = Modbus(UARTS[modbus.get(UART)])
111
+ try:
112
+ self._modbus = Modbus(UARTS[modbus.get(UART)])
113
+ except ModbusUartException:
114
+ _LOGGER.error(
115
+ "This UART %s can't be used for modbus communication.",
116
+ modbus.get(UART),
117
+ )
118
+ self._modbus = None
111
119
 
112
120
  for sensor_type in (LM75, MCP_TEMP_9808):
113
121
  if sensors.get(sensor_type):
@@ -374,14 +382,14 @@ class Manager:
374
382
  if not self._config_helper.ha_discovery:
375
383
  return
376
384
  topic_prefix = topic_prefix or self._config_helper.topic_prefix
377
- msg = availability_msg_func(topic=topic_prefix, id=id, name=name, **kwargs)
385
+ payload = availability_msg_func(topic=topic_prefix, id=id, name=name, **kwargs)
378
386
  topic = f"{self._config_helper.ha_discovery_prefix}/{ha_type}/{topic_prefix}/{id}/config"
379
387
  _LOGGER.debug("Sending HA discovery for %s, %s.", ha_type, name)
380
- self._autodiscovery_messages.append({"topic": topic, "payload": msg})
381
- self.send_message(topic=topic, payload=msg, retain=True)
388
+ self._config_helper.add_autodiscovery_msg(topic=topic, payload=payload)
389
+ self.send_message(topic=topic, payload=payload, retain=True)
382
390
 
383
391
  def resend_autodiscovery(self):
384
- for msg in self._autodiscovery_messages:
392
+ for msg in self._config_helper.autodiscovery_msgs:
385
393
  self.send_message(**msg, retain=True)
386
394
 
387
395
  async def receive_message(self, topic: str, message: str) -> None:
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import asyncio
4
4
  import logging
5
5
  from boneio.helper import configure_pin
6
+ from boneio.helper.exceptions import ModbusUartException
6
7
  from boneio.const import ID, RX, TX, UART, REGISTERS
7
8
  from pymodbus.client.sync import (
8
9
  BaseModbusClient,
@@ -23,9 +24,13 @@ class Modbus:
23
24
 
24
25
  def __init__(self, uart: dict[str, Any]) -> None:
25
26
  """Initialize the Modbus hub."""
27
+ rx = uart.get(RX)
28
+ tx = uart.get(TX)
29
+ if not tx or not rx:
30
+ raise ModbusUartException
26
31
 
27
- configure_pin(pin=uart[RX], mode=UART)
28
- configure_pin(pin=uart[TX], mode=UART)
32
+ configure_pin(pin=rx, mode=UART)
33
+ configure_pin(pin=tx, mode=UART)
29
34
  self._uart = uart
30
35
 
31
36
  # generic configuration
@@ -93,6 +93,7 @@ modbus:
93
93
  uart:
94
94
  type: string
95
95
  required: True
96
+ allowed: ["uart1", "uart2", "uart3", "uart4", "uart5"]
96
97
  meta:
97
98
  label: Uart ID to use
98
99
 
@@ -122,20 +122,20 @@ class ModbusSensor(BasicMqtt):
122
122
  ) -> None:
123
123
  """Send HA autodiscovery information for each Modbus sensor."""
124
124
  _LOGGER.debug("Sending HA discovery for sensor %s %s.", sdm_name, sensor_id)
125
- self._send_message(
126
- topic=(
127
- f"{self._config_helper.ha_discovery_prefix}/{SENSOR}/{self._config_helper.topic_prefix}{id}"
128
- f"/{id}{sensor_id.replace('_', '').replace(' ', '').lower()}/config"
129
- ),
130
- payload=modbus_sensor_availabilty_message(
131
- topic=self._config_helper.topic_prefix,
132
- id=id,
133
- name=sdm_name,
134
- model=self._model,
135
- sensor_id=sensor_id,
136
- **kwargs,
137
- ),
125
+ topic = (
126
+ f"{self._config_helper.ha_discovery_prefix}/{SENSOR}/{self._config_helper.topic_prefix}{id}"
127
+ f"/{id}{sensor_id.replace('_', '').replace(' ', '').lower()}/config"
138
128
  )
129
+ payload = modbus_sensor_availabilty_message(
130
+ topic=self._config_helper.topic_prefix,
131
+ id=id,
132
+ name=sdm_name,
133
+ model=self._model,
134
+ sensor_id=sensor_id,
135
+ **kwargs,
136
+ )
137
+ self._config_helper.add_autodiscovery_msg(topic=topic, payload=payload)
138
+ self._send_message(topic=topic, payload=payload)
139
139
 
140
140
  def _send_discovery_for_all_registers(self, register: int = 0) -> bool:
141
141
  """Send discovery message to HA for each register."""
@@ -0,0 +1,2 @@
1
+ # flake8: noqa
2
+ __version__ = "0.3.0.dev8"
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneio
3
- Version: 0.3.0.dev6
3
+ Version: 0.3.0.dev8
4
4
  Summary: Python App for BoneIO
5
5
  Home-page: https://github.com/boneIO-eu/app_bbb
6
- Download-URL: https://github.com/boneIO-eu/app_bbb/archive/0.3.0.dev6.zip
6
+ Download-URL: https://github.com/boneIO-eu/app_bbb/archive/0.3.0.dev8.zip
7
7
  License: GNU General Public License v3.0
8
8
  Platform: UNKNOWN
9
9
  Classifier: Programming Language :: Python
@@ -1,2 +0,0 @@
1
- # flake8: noqa
2
- __version__ = "0.3.0.dev6"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes