boneIO 0.3.0__tar.gz → 0.3.0.dev2__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 (73) hide show
  1. {boneio-0.3.0/boneio.egg-info → boneio-0.3.0.dev2}/PKG-INFO +2 -2
  2. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/bonecli.py +1 -1
  3. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/const.py +6 -7
  4. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/cover.py +2 -2
  5. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/example_config/config.yaml +2 -2
  6. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/example_config/cover.yaml +2 -2
  7. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/example_config/output32x5A.yaml +72 -110
  8. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/__init__.py +15 -2
  9. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/events.py +4 -14
  10. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/exceptions.py +0 -12
  11. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/gpio.py +1 -1
  12. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/loader.py +27 -55
  13. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/yaml_util.py +0 -1
  14. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/input/gpio.py +7 -8
  15. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/manager.py +43 -109
  16. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/modbus.py +3 -8
  17. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/mqtt_client.py +7 -22
  18. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/relay/mcp.py +3 -3
  19. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/runner.py +5 -15
  20. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/schema/schema.yaml +1 -82
  21. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/sensor/__init__.py +1 -4
  22. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/sensor/modbus/__init__.py +32 -40
  23. boneio-0.3.0.dev2/boneio/sensor/temp/__init__.py +52 -0
  24. boneio-0.3.0.dev2/boneio/version.py +2 -0
  25. {boneio-0.3.0 → boneio-0.3.0.dev2/boneio.egg-info}/PKG-INFO +2 -2
  26. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio.egg-info/SOURCES.txt +1 -9
  27. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio.egg-info/requires.txt +0 -1
  28. {boneio-0.3.0 → boneio-0.3.0.dev2}/requirements.txt +0 -1
  29. {boneio-0.3.0 → boneio-0.3.0.dev2}/setup.py +0 -1
  30. boneio-0.3.0/boneio/helper/config.py +0 -47
  31. boneio-0.3.0/boneio/helper/ds2482/__init__.py +0 -10
  32. boneio-0.3.0/boneio/helper/ds2482/ds2482.py +0 -163
  33. boneio-0.3.0/boneio/helper/ds2482/onewire.py +0 -44
  34. boneio-0.3.0/boneio/helper/util.py +0 -15
  35. boneio-0.3.0/boneio/sensor/temp/__init__.py +0 -76
  36. boneio-0.3.0/boneio/sensor/temp/dallas.py +0 -43
  37. boneio-0.3.0/boneio/sensor/temp/lm75.py +0 -11
  38. boneio-0.3.0/boneio/sensor/temp/mcp9808.py +0 -12
  39. boneio-0.3.0/boneio/version.py +0 -2
  40. {boneio-0.3.0 → boneio-0.3.0.dev2}/LICENSE +0 -0
  41. {boneio-0.3.0 → boneio-0.3.0.dev2}/MANIFEST.in +0 -0
  42. {boneio-0.3.0 → boneio-0.3.0.dev2}/README.md +0 -0
  43. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/__init__.py +0 -0
  44. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/example_config/__init__.py +0 -0
  45. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/example_config/adc.yaml +0 -0
  46. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/example_config/input.yaml +0 -0
  47. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/example_config/output24x16A.yaml +0 -0
  48. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/fonts/danube__.ttf +0 -0
  49. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/ha_discovery.py +0 -0
  50. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/logger.py +0 -0
  51. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/mqtt.py +0 -0
  52. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/oled.py +0 -0
  53. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/queue.py +0 -0
  54. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/state_manager.py +0 -0
  55. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/stats.py +0 -0
  56. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/helper/timeperiod.py +0 -0
  57. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/input/__init__.py +0 -0
  58. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/oled.py +0 -0
  59. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/relay/__init__.py +0 -0
  60. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/relay/basic.py +0 -0
  61. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/relay/gpio.py +0 -0
  62. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/schema/actions.yaml +0 -0
  63. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/schema/actions_sensor.yaml +0 -0
  64. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/schema/actions_switch.yaml +0 -0
  65. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/sensor/adc.py +0 -0
  66. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/sensor/gpio.py +0 -0
  67. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/sensor/modbus/sdm120.json +0 -0
  68. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/sensor/modbus/sdm630.json +0 -0
  69. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio/sensor/modbus/sofar.json +0 -0
  70. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio.egg-info/dependency_links.txt +0 -0
  71. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio.egg-info/entry_points.txt +0 -0
  72. {boneio-0.3.0 → boneio-0.3.0.dev2}/boneio.egg-info/top_level.txt +0 -0
  73. {boneio-0.3.0 → boneio-0.3.0.dev2}/setup.cfg +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneio
3
- Version: 0.3.0
3
+ Version: 0.3.0.dev2
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.zip
6
+ Download-URL: https://github.com/boneIO-eu/app_bbb/archive/0.3.0.dev2.zip
7
7
  License: GNU General Public License v3.0
8
8
  Platform: UNKNOWN
9
9
  Classifier: Programming Language :: Python
@@ -68,7 +68,7 @@ def get_arguments() -> argparse.Namespace:
68
68
 
69
69
  def run(config: str, debug: int, mqttusername: str = "", mqttpassword: str = ""):
70
70
  """Run BoneIO."""
71
- _LOGGER.info("BoneIO %s starting.", __version__)
71
+ _LOGGER.info("BoneIO starting.")
72
72
  try:
73
73
  _config = load_config_from_file(config_file=config)
74
74
  if not _config:
@@ -2,13 +2,12 @@
2
2
  from datetime import timedelta
3
3
 
4
4
  try:
5
- from Adafruit_BBIO.GPIO import HIGH, LOW, BOTH, FALLING, RISING
5
+ from Adafruit_BBIO.GPIO import HIGH, LOW, BOTH, FALLING
6
6
  except ModuleNotFoundError:
7
7
  HIGH = "high"
8
8
  LOW = "low"
9
9
  BOTH = "both"
10
10
  FALLING = "falling"
11
- RISING = "rising"
12
11
  pass
13
12
  from typing_extensions import Literal
14
13
 
@@ -48,12 +47,14 @@ RESTORE_STATE = "restore_state"
48
47
  MODEL = "model"
49
48
  UARTS = {
50
49
  "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},
53
50
  "uart4": {ID: "/dev/ttyS4", TX: "P9.13", RX: "P9.11"},
54
- "uart5": {ID: "/dev/ttyS5", TX: "P8.37", RX: "P8.38"},
55
51
  }
56
52
 
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
57
58
 
58
59
  # HA CONSTS
59
60
  HOMEASSISTANT = "homeassistant"
@@ -112,8 +113,6 @@ BINARY_SENSOR = "binary_sensor"
112
113
  LM75 = "lm75"
113
114
  MCP_TEMP_9808 = "mcp9808"
114
115
  INPUT_SENSOR = "inputsensor"
115
- DS2482 = "ds2482"
116
- DALLAS = "dallas"
117
116
 
118
117
  BASE = "base"
119
118
  LENGTH = "length"
@@ -1,7 +1,7 @@
1
1
  """Cover module."""
2
2
  import asyncio
3
3
  import logging
4
- from typing import Callable
4
+ from typing import Any, Callable
5
5
  from boneio.const import CLOSE, COVER, IDLE, OPEN, OPENING, CLOSING, CLOSED, STOP
6
6
  from boneio.helper.events import EventBus
7
7
  from boneio.helper.mqtt import BasicMqtt
@@ -44,7 +44,7 @@ class Cover(BasicMqtt):
44
44
  def __init__(
45
45
  self,
46
46
  id: str,
47
- open_relay: MCPRelay,
47
+ open_relay: Any,
48
48
  close_relay: MCPRelay,
49
49
  state_save: Callable,
50
50
  open_time: TimePeriod,
@@ -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: 20s
6
- close_time: 22s
5
+ open_time: 20
6
+ close_time: 22
7
7
  show_in_ha: yes
8
8
  restore_state: yes
@@ -1,198 +1,160 @@
1
- # mcp1 - upper left 8 relays
2
- - id: OUT_01
1
+ - id: light 1
3
2
  kind: mcp
4
3
  mcp_id: mcp1
5
4
  pin: 0
6
5
  output_type: light
7
-
8
- - id: OUT_02
6
+ - id: light 2
9
7
  kind: mcp
10
8
  mcp_id: mcp1
11
9
  pin: 1
12
10
  output_type: light
13
-
14
- - id: OUT_03
11
+ - id: light 3
15
12
  kind: mcp
16
13
  mcp_id: mcp1
17
14
  pin: 2
18
15
  output_type: light
19
-
20
- - id: OUT_04
16
+ - id: light 4
21
17
  kind: mcp
22
18
  mcp_id: mcp1
23
19
  pin: 3
24
20
  output_type: light
25
-
26
- - id: OUT_05
21
+ - id: light 5
27
22
  kind: mcp
28
23
  mcp_id: mcp1
29
24
  pin: 4
30
25
  output_type: light
31
-
32
- - id: OUT_06
26
+ - id: light 6
33
27
  kind: mcp
34
28
  mcp_id: mcp1
35
29
  pin: 5
36
30
  output_type: light
37
-
38
- - id: OUT_07
31
+ - id: light 7
39
32
  kind: mcp
40
33
  mcp_id: mcp1
41
34
  pin: 6
42
35
  output_type: light
43
-
44
- - id: OUT_08
36
+ - id: light 8
45
37
  kind: mcp
46
38
  mcp_id: mcp1
47
39
  pin: 7
48
40
  output_type: light
49
-
50
-
51
- # mcp2 - upper right 8 relays
52
- - id: OUT_09
53
- kind: mcp
54
- mcp_id: mcp2
55
- pin: 0
56
- output_type: light
57
-
58
- - id: OUT_10
59
- kind: mcp
60
- mcp_id: mcp2
61
- pin: 1
62
- output_type: light
63
-
64
- - id: OUT_11
65
- kind: mcp
66
- mcp_id: mcp2
67
- pin: 2
68
- output_type: light
69
-
70
- - id: OUT_12
71
- kind: mcp
72
- mcp_id: mcp2
73
- pin: 3
74
- output_type: light
75
-
76
- - id: OUT_13
77
- kind: mcp
78
- mcp_id: mcp2
79
- pin: 4
80
- output_type: light
81
-
82
- - id: OUT_14
83
- kind: mcp
84
- mcp_id: mcp2
85
- pin: 5
86
- output_type: light
87
-
88
- - id: OUT_15
89
- kind: mcp
90
- mcp_id: mcp2
91
- pin: 6
92
- output_type: light
93
-
94
- - id: OUT_16
95
- kind: mcp
96
- mcp_id: mcp2
97
- pin: 7
98
- output_type: light
99
-
100
-
101
- # mcp1 - lower left 8 relays
102
- - id: OUT_17
41
+ - id: light 9
103
42
  kind: mcp
104
43
  mcp_id: mcp1
105
44
  pin: 8
106
45
  output_type: light
107
-
108
- - id: OUT_18
46
+ - id: light 10
109
47
  kind: mcp
110
48
  mcp_id: mcp1
111
49
  pin: 9
112
50
  output_type: light
113
-
114
- - id: OUT_19
51
+ - id: light 11
115
52
  kind: mcp
116
53
  mcp_id: mcp1
117
54
  pin: 10
118
55
  output_type: light
119
-
120
- - id: OUT_20
56
+ - id: light 12
121
57
  kind: mcp
122
58
  mcp_id: mcp1
123
59
  pin: 11
124
60
  output_type: light
125
-
126
- - id: OUT_21
61
+ - id: light 13
127
62
  kind: mcp
128
63
  mcp_id: mcp1
129
64
  pin: 12
130
65
  output_type: light
131
-
132
- - id: OUT_22
66
+ - id: light 14
133
67
  kind: mcp
134
68
  mcp_id: mcp1
135
69
  pin: 13
136
70
  output_type: light
137
-
138
- - id: OUT_23
71
+ - id: light 15
139
72
  kind: mcp
140
73
  mcp_id: mcp1
141
74
  pin: 14
142
75
  output_type: light
143
-
144
- - id: OUT_24
76
+ - id: light 16
145
77
  kind: mcp
146
78
  mcp_id: mcp1
147
79
  pin: 15
148
80
  output_type: light
149
-
150
-
151
- # mcp2 - lower right 8 relays
152
- - id: OUT_25
81
+ - id: switch 1
82
+ kind: mcp
83
+ mcp_id: mcp2
84
+ pin: 0
85
+ output_type: switch
86
+ - id: switch 2
87
+ kind: mcp
88
+ mcp_id: mcp2
89
+ pin: 1
90
+ output_type: switch
91
+ - id: switch 3
92
+ kind: mcp
93
+ mcp_id: mcp2
94
+ pin: 2
95
+ output_type: switch
96
+ - id: switch 4
97
+ kind: mcp
98
+ mcp_id: mcp2
99
+ pin: 3
100
+ output_type: switch
101
+ - id: switch 5
102
+ kind: mcp
103
+ mcp_id: mcp2
104
+ pin: 4
105
+ output_type: switch
106
+ - id: switch 6
107
+ kind: mcp
108
+ mcp_id: mcp2
109
+ pin: 5
110
+ output_type: switch
111
+ - id: switch 7
112
+ kind: mcp
113
+ mcp_id: mcp2
114
+ pin: 6
115
+ output_type: switch
116
+ - id: switch 8
117
+ kind: mcp
118
+ mcp_id: mcp2
119
+ pin: 7
120
+ output_type: switch
121
+ - id: switch 9
153
122
  kind: mcp
154
123
  mcp_id: mcp2
155
124
  pin: 8
156
- output_type: light
157
-
158
- - id: OUT_26
125
+ output_type: switch
126
+ - id: switch 10
159
127
  kind: mcp
160
128
  mcp_id: mcp2
161
129
  pin: 9
162
- output_type: light
163
-
164
- - id: OUT_27
130
+ output_type: switch
131
+ - id: switch 11
165
132
  kind: mcp
166
133
  mcp_id: mcp2
167
134
  pin: 10
168
- output_type: light
169
-
170
- - id: OUT_28
135
+ output_type: switch
136
+ - id: switch 12
171
137
  kind: mcp
172
138
  mcp_id: mcp2
173
139
  pin: 11
174
- output_type: light
175
-
176
- - id: OUT_29
140
+ output_type: switch
141
+ - id: switch 13
177
142
  kind: mcp
178
143
  mcp_id: mcp2
179
144
  pin: 12
180
- output_type: light
181
-
182
- - id: OUT_30
145
+ output_type: switch
146
+ - id: switch 14
183
147
  kind: mcp
184
148
  mcp_id: mcp2
185
149
  pin: 13
186
- output_type: light
187
-
188
- - id: OUT_31
150
+ output_type: switch
151
+ - id: switch 15
189
152
  kind: mcp
190
153
  mcp_id: mcp2
191
154
  pin: 14
192
- output_type: light
193
-
194
- - id: OUT_32
155
+ output_type: switch
156
+ - id: switch 16
195
157
  kind: mcp
196
158
  mcp_id: mcp2
197
159
  pin: 15
198
- output_type: light
160
+ output_type: switch
@@ -1,4 +1,5 @@
1
1
  """Helper dir for BoneIO."""
2
+ from typing import Callable, TypeVar, Any
2
3
 
3
4
  from boneio.helper.gpio import (
4
5
  edge_detect,
@@ -34,6 +35,20 @@ from boneio.helper.exceptions import GPIOInputException, I2CError
34
35
  from boneio.helper.queue import UniqueQueue
35
36
  from boneio.helper.timeperiod import TimePeriod
36
37
 
38
+ CALLABLE_T = TypeVar("CALLABLE_T", bound=Callable[..., Any])
39
+ CALLBACK_TYPE = Callable[[], None]
40
+
41
+
42
+ def callback(func: CALLABLE_T) -> CALLABLE_T:
43
+ """Annotation to mark method as safe to call from within the event loop."""
44
+ setattr(func, "_boneio_callback", True)
45
+ return func
46
+
47
+
48
+ def is_callback(func: Callable[..., Any]) -> bool:
49
+ """Check if function is safe to be called in the event loop."""
50
+ return getattr(func, "_boneio_callback", False) is True
51
+
37
52
 
38
53
  __all__ = [
39
54
  "CustomValidator",
@@ -65,6 +80,4 @@ __all__ = [
65
80
  "load_config_from_string",
66
81
  "load_config_from_file",
67
82
  "TimePeriod",
68
- "callback",
69
- "is_callback",
70
83
  ]
@@ -3,9 +3,9 @@ import datetime as dt
3
3
  import signal
4
4
  import logging
5
5
  import time
6
- from typing import Callable, Optional
6
+ from typing import Callable
7
7
  from datetime import datetime
8
- from boneio.helper.util import callback
8
+ from boneio.helper import callback
9
9
 
10
10
  _LOGGER = logging.getLogger(__name__)
11
11
  UTC = dt.timezone.utc
@@ -79,7 +79,6 @@ class EventBus:
79
79
  self._loop = loop or asyncio.get_event_loop()
80
80
  self._listeners = {}
81
81
  self._sigterm_listeners = []
82
- self._haonline_listeners = []
83
82
  self._timer_handle = _async_create_timer(self._loop, self._run_second_event)
84
83
  for signame in {"SIGINT", "SIGTERM"}:
85
84
  self._loop.add_signal_handler(
@@ -114,15 +113,6 @@ class EventBus:
114
113
  """Add sigterm listener."""
115
114
  self._sigterm_listeners.append(target)
116
115
 
117
- def add_haonline_listener(self, target):
118
- """Add HA Online listener."""
119
- self._haonline_listeners.append(target)
120
-
121
- def signal_ha_online(self):
122
- """Call events if HA goes online."""
123
- for target in self._haonline_listeners:
124
- target()
125
-
126
116
  def remove_listener(self, name):
127
117
  """Remove regular listener."""
128
118
  if name in self._listeners:
@@ -149,9 +139,9 @@ def async_track_point_in_time(
149
139
  # Ensure point_in_time is UTC
150
140
  utc_point_in_time = as_utc(point_in_time)
151
141
 
152
- # Since this is called once, we accept a so we can avoid
142
+ # Since this is called once, we accept a HassJob so we can avoid
153
143
  # having to figure out how to call the action every time its called.
154
- cancel_callback: Optional[asyncio.TimerHandle] = None
144
+ cancel_callback: asyncio.TimerHandle | None = None
155
145
 
156
146
  @callback
157
147
  def run_action(job) -> None:
@@ -13,17 +13,5 @@ class I2CError(BoneIOException):
13
13
  """I2C Exception."""
14
14
 
15
15
 
16
- class OneWireError(BoneIOException):
17
- """One Wire Exception."""
18
-
19
-
20
16
  class ConfigurationException(BoneIOException):
21
17
  """Configuration yaml exception."""
22
-
23
-
24
- class CoverRelayException(BoneIOException):
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=10))
100
+ self._bounce_time = gpio.get("bounce_time", TimePeriod(milliseconds=25))
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)
@@ -43,13 +43,9 @@ from boneio.helper import (
43
43
  ha_input_availabilty_message,
44
44
  ha_sensor_temp_availabilty_message,
45
45
  )
46
- from adafruit_onewire.bus import OneWireAddress
47
- from boneio.helper.ds2482 import DS2482, OneWireBus, ds_address, DS2482_ADDRESS
48
46
  from boneio.helper.ha_discovery import ha_cover_availabilty_message
49
47
  from boneio.helper.timeperiod import TimePeriod
50
48
  from boneio.input.gpio import GpioInputButton
51
- from boneio.helper.config import ConfigHelper
52
- from boneio.sensor import DallasSensor
53
49
 
54
50
  # Typing imports that create a circular dependency
55
51
  if TYPE_CHECKING:
@@ -63,7 +59,9 @@ from busio import I2C
63
59
  _LOGGER = logging.getLogger(__name__)
64
60
 
65
61
 
66
- def create_adc(manager: Manager, topic_prefix: str, adc_list: list = []):
62
+ def create_adc(
63
+ manager: Manager, topic_prefix: str, ha_discovery_prefix: str, adc_list: list = []
64
+ ):
67
65
  """Create ADC sensor."""
68
66
 
69
67
  initialize_adc()
@@ -80,13 +78,14 @@ def create_adc(manager: Manager, topic_prefix: str, adc_list: list = []):
80
78
  name=name,
81
79
  send_message=manager.send_message,
82
80
  topic_prefix=topic_prefix,
83
- update_interval=gpio.get(UPDATE_INTERVAL, TimePeriod(seconds=60)),
81
+ update_interval=gpio.get(UPDATE_INTERVAL, 60),
84
82
  )
85
83
  if gpio.get(SHOW_HA, True):
86
84
  manager.send_ha_autodiscovery(
87
85
  id=id,
88
86
  name=name,
89
87
  ha_type=SENSOR,
88
+ ha_discovery_prefix=ha_discovery_prefix,
90
89
  availability_msg_func=ha_adc_sensor_availabilty_message,
91
90
  )
92
91
  manager.append_task(asyncio.create_task(adc.send_state()))
@@ -98,9 +97,11 @@ def create_adc(manager: Manager, topic_prefix: str, adc_list: list = []):
98
97
  def create_temp_sensor(
99
98
  manager: Manager,
100
99
  topic_prefix: str,
100
+ ha_discovery_prefix: str,
101
101
  sensor_type: str,
102
102
  i2cbusio: I2C,
103
103
  temp_def: dict = {},
104
+ temp_sensors: list = [],
104
105
  ):
105
106
  """Create LM sensor in manager."""
106
107
  if sensor_type == LM75:
@@ -119,15 +120,16 @@ def create_temp_sensor(
119
120
  address=temp_def[ADDRESS],
120
121
  send_message=manager.send_message,
121
122
  topic_prefix=topic_prefix,
122
- update_interval=temp_def.get(UPDATE_INTERVAL, TimePeriod(seconds=60)),
123
123
  )
124
124
  manager.send_ha_autodiscovery(
125
125
  id=id,
126
126
  name=name,
127
127
  ha_type=SENSOR,
128
+ ha_discovery_prefix=ha_discovery_prefix,
128
129
  availability_msg_func=ha_sensor_temp_availabilty_message,
129
130
  )
130
- return temp_sensor
131
+ manager.append_task(asyncio.create_task(temp_sensor.send_state()))
132
+ temp_sensors.append(temp_sensor)
131
133
  except I2CError as err:
132
134
  _LOGGER.error("Can't configure Temp sensor. %s", err)
133
135
  pass
@@ -156,7 +158,14 @@ def create_mcp23017(
156
158
  return grouped_outputs
157
159
 
158
160
 
159
- def create_modbus_sensors(manager: Manager, sensors, **kwargs) -> None:
161
+ def create_modbus_sensors(
162
+ manager: Manager,
163
+ topic_prefix: str,
164
+ ha_discovery: bool,
165
+ ha_discovery_prefix: str,
166
+ modbus: Modbus,
167
+ sensors,
168
+ ) -> None:
160
169
  """Create Modbus sensor for each device."""
161
170
  from boneio.sensor.modbus import ModbusSensor
162
171
 
@@ -165,13 +174,16 @@ def create_modbus_sensors(manager: Manager, sensors, **kwargs) -> None:
165
174
  id = name.replace(" ", "")
166
175
  try:
167
176
  sdm = ModbusSensor(
177
+ modbus=modbus,
168
178
  address=sensor[ADDRESS],
169
179
  id=id,
170
180
  name=name,
171
181
  model=sensor[MODEL],
172
182
  send_message=manager.send_message,
173
- update_interval=sensor.get(UPDATE_INTERVAL, TimePeriod(seconds=60)),
174
- **kwargs,
183
+ topic_prefix=topic_prefix,
184
+ ha_discovery=ha_discovery,
185
+ ha_discovery_prefix=ha_discovery_prefix,
186
+ update_interval=sensor.get(UPDATE_INTERVAL, 30),
175
187
  )
176
188
  manager.append_task(asyncio.create_task(sdm.send_state()))
177
189
  except FileNotFoundError as err:
@@ -277,6 +289,7 @@ def configure_input(
277
289
  pin: str,
278
290
  press_callback: Callable,
279
291
  send_ha_autodiscovery: Callable,
292
+ ha_discovery_prefix: str,
280
293
  ) -> str:
281
294
  """Configure input sensor or button."""
282
295
  try:
@@ -296,6 +309,7 @@ def configure_input(
296
309
  id=pin,
297
310
  name=gpio.get(ID, pin),
298
311
  ha_type=getattr(input, "ha_type"),
312
+ ha_discovery_prefix=ha_discovery_prefix,
299
313
  availability_msg_func=getattr(input, "availability_msg_f"),
300
314
  )
301
315
  return pin
@@ -308,6 +322,7 @@ def configure_cover(
308
322
  manager: Manager,
309
323
  cover_id: str,
310
324
  state_manager: StateManager,
325
+ ha_discovery_prefix: str,
311
326
  send_ha_autodiscovery: Callable,
312
327
  config: dict,
313
328
  **kwargs,
@@ -337,50 +352,7 @@ def configure_cover(
337
352
  name=cover.name,
338
353
  ha_type=COVER,
339
354
  device_class=config.get(DEVICE_CLASS),
355
+ ha_discovery_prefix=ha_discovery_prefix,
340
356
  availability_msg_func=ha_cover_availabilty_message,
341
357
  )
342
358
  return cover
343
-
344
-
345
- def configure_ds2482(i2cbusio: I2C, address: str = DS2482_ADDRESS) -> OneWireBus:
346
- ds2482 = DS2482(i2c=i2cbusio, address=address)
347
- ow_bus = OneWireBus(ds2482=ds2482)
348
- return ow_bus
349
-
350
-
351
- def find_onewire_devices(ow_bus: OneWireBus):
352
- devices = ow_bus.scan()
353
- out = {}
354
- for device in devices:
355
- _addr: int = ds_address(device.rom)
356
- _LOGGER.debug("Found device with address %s", hex(_addr))
357
- out[_addr] = device
358
- return out
359
-
360
-
361
- def create_ds2482_dallas_sensor(
362
- manager: Manager,
363
- ds2482_bus: OneWireBus,
364
- address: OneWireAddress,
365
- config: dict,
366
- **kwargs,
367
- ):
368
- name = config.get(ID) or hex(address)
369
- id = name.replace(" ", "")
370
- sensor = DallasSensor(
371
- bus=ds2482_bus,
372
- address=address,
373
- id=id,
374
- name=name,
375
- update_interval=config.get(UPDATE_INTERVAL, TimePeriod(seconds=60)),
376
- send_message=manager.send_message,
377
- **kwargs,
378
- )
379
- if config.get(SHOW_HA, True):
380
- manager.send_ha_autodiscovery(
381
- id=sensor.id,
382
- name=sensor.name,
383
- ha_type=SENSOR,
384
- availability_msg_func=ha_sensor_temp_availabilty_message,
385
- )
386
- return sensor
@@ -263,7 +263,6 @@ class CustomValidator(Validator):
263
263
  "milliseconds": "milliseconds",
264
264
  "s": "seconds",
265
265
  "sec": "seconds",
266
- "secs": "seconds",
267
266
  "seconds": "seconds",
268
267
  "min": "minutes",
269
268
  "minutes": "minutes",