boneIO 0.7.0.dev6__tar.gz → 0.7.2.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 (94) hide show
  1. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/PKG-INFO +1 -1
  2. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/bonecli.py +1 -1
  3. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/const.py +58 -2
  4. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/example_config/binary_sensor.yaml +2 -0
  5. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/example_config/config.yaml +1 -1
  6. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/example_config/event.yaml +2 -0
  7. boneIO-0.7.2.dev2/boneio/example_config/event_all.yaml +186 -0
  8. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/group/output.py +13 -18
  9. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/__init__.py +2 -0
  10. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/async_updater.py +3 -3
  11. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/click_timer.py +8 -0
  12. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/events.py +21 -1
  13. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/gpio.py +53 -17
  14. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/ha_discovery.py +22 -0
  15. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/loader.py +78 -82
  16. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/mqtt.py +3 -1
  17. boneIO-0.7.2.dev2/boneio/helper/sensor/ina_219_smbus.py +167 -0
  18. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/state_manager.py +13 -3
  19. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/stats.py +29 -10
  20. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/util.py +6 -0
  21. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/yaml_util.py +1 -1
  22. boneIO-0.7.2.dev2/boneio/input/__init__.py +7 -0
  23. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/input/gpio.py +2 -8
  24. boneIO-0.7.0.dev6/boneio/input/gpio_beta.py → boneIO-0.7.2.dev2/boneio/input/gpio_new.py +24 -34
  25. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/manager.py +134 -35
  26. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/modbus.py +41 -30
  27. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/mqtt_client.py +4 -0
  28. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/oled.py +24 -16
  29. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/relay/basic.py +42 -18
  30. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/relay/mcp.py +7 -18
  31. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/relay/pca.py +11 -70
  32. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/relay/pcf.py +3 -6
  33. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/runner.py +5 -1
  34. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/schema/actions_sensor.yaml +0 -2
  35. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/schema/actions_switch.yaml +0 -2
  36. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/schema/schema.yaml +130 -34
  37. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/__init__.py +6 -4
  38. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/gpio.py +2 -5
  39. boneIO-0.7.0.dev6/boneio/sensor/gpio_beta.py → boneIO-0.7.2.dev2/boneio/sensor/gpio_new.py +5 -8
  40. boneIO-0.7.2.dev2/boneio/sensor/ina219.py +107 -0
  41. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/modbus/__init__.py +54 -10
  42. boneIO-0.7.2.dev2/boneio/sensor/modbus/sdm630.json +299 -0
  43. boneIO-0.7.2.dev2/boneio/sensor/modbus/socomec_e23.json +102 -0
  44. boneIO-0.7.2.dev2/boneio/version.py +2 -0
  45. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/pyproject.toml +3 -2
  46. boneIO-0.7.0.dev6/boneio/input/__init__.py +0 -7
  47. boneIO-0.7.0.dev6/boneio/sensor/modbus/sdm630.json +0 -300
  48. boneIO-0.7.0.dev6/boneio/version.py +0 -2
  49. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/LICENSE +0 -0
  50. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/README.md +0 -0
  51. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/__init__.py +0 -0
  52. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/cover.py +0 -0
  53. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/example_config/__init__.py +0 -0
  54. /boneIO-0.7.0.dev6/boneio/example_config/adc_v0_4.yaml → /boneIO-0.7.2.dev2/boneio/example_config/adc.yaml +0 -0
  55. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/example_config/cover.yaml +0 -0
  56. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/example_config/led32x4A.yaml +0 -0
  57. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/example_config/output24x16A.yaml +0 -0
  58. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/example_config/output24x16A_v0.3.yaml +0 -0
  59. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/example_config/output32x5A.yaml +0 -0
  60. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/fonts/danube__.ttf +0 -0
  61. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/group/__init__.py +0 -0
  62. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/config.py +0 -0
  63. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/exceptions.py +0 -0
  64. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/filter.py +0 -0
  65. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/logger.py +0 -0
  66. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/oled.py +0 -0
  67. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/onewire/W1ThermSensor.py +0 -0
  68. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/onewire/__init__.py +0 -0
  69. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/onewire/ds2482.py +0 -0
  70. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/onewire/onewire.py +0 -0
  71. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/pcf8575.py +0 -0
  72. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/queue.py +0 -0
  73. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/helper/timeperiod.py +0 -0
  74. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/relay/__init__.py +0 -0
  75. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/relay/gpio.py +0 -0
  76. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/schema/actions.yaml +0 -0
  77. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/schema/filters.yaml +0 -0
  78. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/schema/filters_adc.yaml +0 -0
  79. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/schema/id.yaml +0 -0
  80. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/schema/temp_unit.yaml +0 -0
  81. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/schema/update_interval.yaml +0 -0
  82. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/adc.py +0 -0
  83. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/modbus/dts1964_3f.json +0 -0
  84. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/modbus/pt100.json +0 -0
  85. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/modbus/r4dcb08.json +0 -0
  86. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/modbus/sdm120.json +0 -0
  87. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/modbus/sofar.json +0 -0
  88. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/temp/__init__.py +0 -0
  89. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/temp/dallas.py +0 -0
  90. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/temp/lm75.py +0 -0
  91. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/boneio/sensor/temp/mcp9808.py +0 -0
  92. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/tests/32_5_config.yaml +0 -0
  93. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/tests/bandit.yaml +0 -0
  94. {boneIO-0.7.0.dev6 → boneIO-0.7.2.dev2}/tests/relay_32_5.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneIO
3
- Version: 0.7.0.dev6
3
+ Version: 0.7.2.dev2
4
4
  Summary: Python App for BoneIO
5
5
  License: GNU General Public License v3.0
6
6
  Author-email: Paweł Szafer <pszafer@gmail.com>
@@ -113,7 +113,7 @@ def main() -> int:
113
113
  mqttpassword=args.mqttpassword,
114
114
  debug=debug,
115
115
  )
116
-
116
+ _LOGGER.info("Exiting with exit code %s", exit_code)
117
117
  return exit_code
118
118
 
119
119
 
@@ -56,7 +56,11 @@ UARTS = {
56
56
  "uart5": {ID: "/dev/ttyS5", TX: "P8.37", RX: "P8.38"},
57
57
  }
58
58
 
59
- relay_actions = {ON: "turn_on", OFF: "turn_off", TOGGLE: "toggle"}
59
+ relay_actions = {
60
+ ON: "async_turn_on",
61
+ OFF: "async_turn_off",
62
+ TOGGLE: "async_toggle",
63
+ }
60
64
 
61
65
  # HA CONSTS
62
66
  HOMEASSISTANT = "homeassistant"
@@ -67,7 +71,8 @@ SHOW_HA = "show_in_ha"
67
71
  # OLED CONST
68
72
  OLED = "oled"
69
73
  FONTS = "fonts"
70
- OLED_PIN = "P9_41"
74
+ OLED_PIN = ("",)
75
+ "P9_41"
71
76
  GIGABYTE = 1073741824
72
77
  MEGABYTE = 1048576
73
78
  WIDTH = 128
@@ -158,3 +163,54 @@ cover_actions = {
158
163
  "TOGGLE_OPEN": "toggle_open",
159
164
  "TOGGLE_CLOSE": "toggle_close",
160
165
  }
166
+
167
+ INA219 = "ina219"
168
+ PINS = {
169
+ "P9_22": {"chip": 0, "line": 2},
170
+ "P9_21": {"chip": 0, "line": 3},
171
+ "P9_18": {"chip": 0, "line": 4},
172
+ "P9_17": {"chip": 0, "line": 5},
173
+ "P8_35": {"chip": 0, "line": 8},
174
+ "P8_33": {"chip": 0, "line": 9},
175
+ "P8_31": {"chip": 0, "line": 10},
176
+ "P8_32": {"chip": 0, "line": 11},
177
+ "P8_19": {"chip": 0, "line": 22},
178
+ "P8_13": {"chip": 0, "line": 23},
179
+ "P8_14": {"chip": 0, "line": 26},
180
+ "P8_17": {"chip": 0, "line": 27},
181
+ "P8_12": {"chip": 1, "line": 12},
182
+ "P8_11": {"chip": 1, "line": 13},
183
+ "P8_16": {"chip": 1, "line": 14},
184
+ "P8_15": {"chip": 1, "line": 15},
185
+ "P9_23": {"chip": 1, "line": 17},
186
+ "P9_14": {"chip": 1, "line": 18},
187
+ "P9_16": {"chip": 1, "line": 19},
188
+ "P8_26": {"chip": 1, "line": 29},
189
+ "P8_18": {"chip": 2, "line": 1},
190
+ "P8_7": {"chip": 2, "line": 2},
191
+ "P8_8": {"chip": 2, "line": 3},
192
+ "P8_10": {"chip": 2, "line": 4},
193
+ "P8_9": {"chip": 2, "line": 5},
194
+ "P8_45": {"chip": 2, "line": 6},
195
+ "P8_46": {"chip": 2, "line": 7},
196
+ "P8_43": {"chip": 2, "line": 8},
197
+ "P8_44": {"chip": 2, "line": 9},
198
+ "P8_41": {"chip": 2, "line": 10},
199
+ "P8_42": {"chip": 2, "line": 11},
200
+ "P8_39": {"chip": 2, "line": 12},
201
+ "P8_40": {"chip": 2, "line": 13},
202
+ "P8_37": {"chip": 2, "line": 14},
203
+ "P8_38": {"chip": 2, "line": 15},
204
+ "P8_36": {"chip": 2, "line": 16},
205
+ "P8_34": {"chip": 2, "line": 17},
206
+ "P8_27": {"chip": 2, "line": 22},
207
+ "P8_29": {"chip": 2, "line": 23},
208
+ "P8_28": {"chip": 2, "line": 24},
209
+ "P8_30": {"chip": 2, "line": 25},
210
+ "P9_31": {"chip": 3, "line": 14},
211
+ "P9_29": {"chip": 3, "line": 15},
212
+ "P9_30": {"chip": 3, "line": 16},
213
+ "P9_28": {"chip": 3, "line": 17},
214
+ "P9_27": {"chip": 3, "line": 19},
215
+ "P9_25": {"chip": 3, "line": 21},
216
+ }
@@ -1,9 +1,11 @@
1
1
  - id: IN_47
2
2
  pin: P8_12
3
3
  kind: sensor
4
+ detection_type: "old"
4
5
  - id: IN_48
5
6
  pin: P8_11
6
7
  kind: sensor
8
+ detection_type: "new"
7
9
  - id: IN_49
8
10
  pin: P8_10
9
11
  kind: sensor
@@ -23,4 +23,4 @@ binary_sensor: !include binary_sensor.yaml
23
23
 
24
24
  output: !include output32x5A.yaml
25
25
 
26
- adc: !include adc.yaml
26
+ # adc: !include adc.yaml Uncomment only if needed.
@@ -1,5 +1,6 @@
1
1
  - id: IN_01
2
2
  pin: P8_37
3
+ detection_type: "old"
3
4
  actions:
4
5
  single:
5
6
  - action: output
@@ -9,6 +10,7 @@
9
10
  pin: switch 1
10
11
  - id: IN_02
11
12
  pin: P8_38
13
+ detection_type: "new"
12
14
  actions:
13
15
  single:
14
16
  - action: output
@@ -0,0 +1,186 @@
1
+ - id: IN_01
2
+ pin: P8_37
3
+ detection_type: "old"
4
+ actions:
5
+ single:
6
+ - action: output
7
+ pin: light 1
8
+ double:
9
+ - action: output
10
+ pin: switch 1
11
+ - id: IN_02
12
+ pin: P8_38
13
+ detection_type: "new"
14
+ actions:
15
+ single:
16
+ - action: output
17
+ pin: light 2
18
+ double:
19
+ - action: output
20
+ pin: switch 2
21
+ - id: IN_03
22
+ pin: P8_39
23
+ actions:
24
+ single:
25
+ - action: output
26
+ pin: light 3
27
+ double:
28
+ - action: output
29
+ pin: switch 3
30
+ - id: IN_04
31
+ pin: P8_40
32
+ actions:
33
+ single:
34
+ - action: output
35
+ pin: light 4
36
+ double:
37
+ - action: output
38
+ pin: switch 4
39
+ - id: IN_05
40
+ pin: P8_41
41
+ actions:
42
+ single:
43
+ - action: output
44
+ pin: light 5
45
+ double:
46
+ - action: output
47
+ pin: switch 5
48
+ - id: IN_06
49
+ pin: P8_42
50
+ actions:
51
+ single:
52
+ - action: output
53
+ pin: light 6
54
+ double:
55
+ - action: output
56
+ pin: switch 6
57
+ - id: IN_07
58
+ pin: P8_43
59
+ actions:
60
+ single:
61
+ - action: output
62
+ pin: light 7
63
+
64
+ - id: IN_08
65
+ pin: P8_44
66
+ actions:
67
+ single:
68
+ - action: output
69
+ pin: light 8
70
+ - id: IN_09
71
+ pin: P8_45
72
+ actions:
73
+ single:
74
+ - action: output
75
+ pin: light 9
76
+ - id: IN_10
77
+ pin: P8_46
78
+ actions:
79
+ single:
80
+ - action: output
81
+ pin: light 10
82
+ - id: IN_11
83
+ pin: P9_42
84
+ actions:
85
+ single:
86
+ - action: output
87
+ pin: light 11
88
+ - id: IN_12
89
+ pin: P9_31
90
+ actions:
91
+ single:
92
+ - action: output
93
+ pin: light 12
94
+ - id: IN_13
95
+ pin: P9_30
96
+ actions:
97
+ single:
98
+ - action: output
99
+ pin: light 13
100
+ - id: IN_14
101
+ pin: P9_29
102
+ actions:
103
+ single:
104
+ - action: output
105
+ pin: light 14
106
+
107
+ - id: IN_15
108
+ pin: P9_28
109
+ actions:
110
+ single:
111
+ - action: output
112
+ pin: light 15
113
+ - id: IN_16
114
+ pin: P9_27
115
+ actions:
116
+ single:
117
+ - action: output
118
+ pin: light 16
119
+ - id: IN_17
120
+ pin: P9_25
121
+ actions:
122
+ single:
123
+ - action: output
124
+ pin: light 4
125
+ - id: IN_18
126
+ pin: P9_23
127
+ - id: IN_19
128
+ pin: P9_22
129
+ - id: IN_20
130
+ pin: P9_21
131
+ - id: IN_21
132
+ pin: P9_18
133
+
134
+ - id: IN_22
135
+ pin: P9_17
136
+ - id: IN_23
137
+ pin: P9_16
138
+ - id: IN_24
139
+ pin: P9_15
140
+ - id: IN_25
141
+ pin: P9_14
142
+ - id: IN_26
143
+ pin: P9_13
144
+ - id: IN_27
145
+ pin: P9_12
146
+ - id: IN_28
147
+ pin: P9_11
148
+
149
+ - id: IN_29
150
+ pin: P8_36
151
+ - id: IN_30
152
+ pin: P8_35
153
+ - id: IN_31
154
+ pin: P8_34
155
+ - id: IN_32
156
+ pin: P8_33
157
+
158
+ - id: IN_33
159
+ pin: P8_32
160
+ - id: IN_34
161
+ pin: P8_31
162
+ - id: IN_35
163
+ pin: P8_30
164
+ - id: IN_36
165
+ pin: P8_29
166
+ - id: IN_37
167
+ pin: P8_28
168
+ - id: IN_38
169
+ pin: P8_27
170
+ - id: IN_39
171
+ pin: P8_26
172
+
173
+ - id: IN_40
174
+ pin: P8_19
175
+ - id: IN_41
176
+ pin: P8_18
177
+ - id: IN_42
178
+ pin: P8_17
179
+ - id: IN_43
180
+ pin: P8_16
181
+ - id: IN_44
182
+ pin: P8_15
183
+ - id: IN_45
184
+ pin: P8_14
185
+ - id: IN_46
186
+ pin: P8_13
@@ -1,14 +1,10 @@
1
- """Cover module."""
1
+ """Group output module."""
2
2
  from __future__ import annotations
3
- import logging
4
3
  import asyncio
5
4
  from typing import List
6
-
7
5
  from boneio.const import COVER, SWITCH, ON, OFF
8
6
  from boneio.relay.basic import BasicRelay
9
7
 
10
- _LOGGER = logging.getLogger(__name__)
11
-
12
8
 
13
9
  class OutputGroup(BasicRelay):
14
10
  """Cover class of boneIO"""
@@ -41,23 +37,22 @@ class OutputGroup(BasicRelay):
41
37
  self._state = state
42
38
  self._loop.call_soon_threadsafe(self.send_state)
43
39
 
44
- def turn_on(self) -> None:
40
+ async def async_turn_on(self) -> None:
45
41
  """Call turn on action."""
46
- for x in self._group_members:
47
- asyncio.create_task(x.async_turn_on())
42
+ await asyncio.gather(
43
+ *[self._loop.run_in_executor(self.executor, x.turn_on) for x in self._group_members]
44
+ )
48
45
 
49
- def turn_off(self) -> None:
46
+ async def async_turn_off(self) -> None:
50
47
  """Call turn off action."""
51
- for x in self._group_members:
52
- asyncio.create_task(x.async_turn_off())
48
+ await asyncio.gather(
49
+ *[self._loop.run_in_executor(self.executor, x.turn_off) for x in self._group_members]
50
+ )
53
51
 
54
- def toggle(self) -> None:
55
- """Toggle group."""
56
- _LOGGER.debug("Toggle relay.")
57
- if self._state == ON:
58
- self.turn_off()
59
- else:
60
- self.turn_on()
52
+ @property
53
+ def is_active(self) -> bool:
54
+ """Is relay active."""
55
+ return self._state == ON
61
56
 
62
57
  def send_state(self) -> None:
63
58
  """Send state to Mqtt on action."""
@@ -21,6 +21,7 @@ from boneio.helper.ha_discovery import (
21
21
  ha_sensor_temp_availabilty_message,
22
22
  ha_switch_availabilty_message,
23
23
  ha_led_availabilty_message,
24
+ ha_sensor_ina_availabilty_message
24
25
  )
25
26
  from boneio.helper.mqtt import BasicMqtt
26
27
  from boneio.helper.async_updater import AsyncUpdater
@@ -54,6 +55,7 @@ __all__ = [
54
55
  "ha_sensor_temp_availabilty_message",
55
56
  "ha_binary_sensor_availabilty_message",
56
57
  "ha_button_availabilty_message",
58
+ "ha_sensor_ina_availabilty_message",
57
59
  "ha_event_availabilty_message",
58
60
  "ha_led_availabilty_message",
59
61
  "GPIOInputException",
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
  import asyncio
3
-
3
+ import time
4
4
  # Typing imports that create a circular dependency
5
5
  from typing import TYPE_CHECKING
6
6
 
@@ -19,11 +19,11 @@ class AsyncUpdater:
19
19
  while True:
20
20
  if hasattr(self, "async_update"):
21
21
  update_interval = (
22
- await self.async_update(time=None)
22
+ await self.async_update(time=time.time())
23
23
  or self._update_interval.total_in_seconds
24
24
  )
25
25
  else:
26
26
  update_interval = (
27
- self.update(time=None) or self._update_interval.total_in_seconds
27
+ self.update(time=time.time()) or self._update_interval.total_in_seconds
28
28
  )
29
29
  await asyncio.sleep(update_interval)
@@ -1,8 +1,12 @@
1
1
  from __future__ import annotations
2
+ import logging
2
3
  import asyncio
3
4
  from boneio.helper.timeperiod import TimePeriod
4
5
  import time
5
6
 
7
+ _LOGGER = logging.getLogger(__name__)
8
+
9
+
6
10
  class ClickTimer:
7
11
  """Represent async call later function with variable to check if timing is ON."""
8
12
 
@@ -16,6 +20,10 @@ class ClickTimer:
16
20
  def is_waiting(self) -> bool:
17
21
  """If variable is set then timer is ON, if None is Off."""
18
22
  return self._remove_listener is not None
23
+
24
+ @property
25
+ def delay(self) -> float:
26
+ return self._delay
19
27
 
20
28
  def reset(self) -> None:
21
29
  """Uninitialize variable remove_listener."""
@@ -4,7 +4,8 @@ import logging
4
4
  import signal
5
5
  import time
6
6
  from datetime import datetime
7
- from typing import Callable, Optional
7
+ from typing import Any, Coroutine, List, Optional, Callable, Optional
8
+
8
9
 
9
10
  from boneio.helper.util import callback
10
11
 
@@ -261,3 +262,22 @@ def async_call_later_miliseconds(
261
262
  return async_track_point_in_timestamp(
262
263
  loop=loop, action=action, timestamp=expected_fire_timestamp
263
264
  )
265
+
266
+
267
+ def create_unawaited_task_threadsafe(
268
+ loop: asyncio.AbstractEventLoop,
269
+ transient_tasks: List["asyncio.Task[Any]"],
270
+ coro: Coroutine[Any, Any, None],
271
+ task_future: Optional["asyncio.Future[asyncio.Task[Any]]"] = None,
272
+ ) -> None:
273
+ """
274
+ Schedule a coroutine on the loop and add the Task to transient_tasks.
275
+ """
276
+
277
+ def callback() -> None:
278
+ task = loop.create_task(coro)
279
+ transient_tasks.append(task)
280
+ if task_future is not None:
281
+ task_future.set_result(task)
282
+
283
+ loop.call_soon_threadsafe(callback)
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
  import asyncio
3
3
  import logging
4
-
4
+ from datetime import datetime
5
5
  try:
6
6
  from Adafruit_BBIO import GPIO
7
7
  except ModuleNotFoundError:
@@ -17,13 +17,14 @@ except ModuleNotFoundError:
17
17
  pass
18
18
 
19
19
  import subprocess
20
- from typing import Callable
20
+ from typing import Callable, Awaitable, List
21
21
 
22
22
  from boneio.const import CONFIG_PIN, FALLING
23
23
  from boneio.const import GPIO as GPIO_STR
24
- from boneio.const import GPIO_MODE, LOW, ClickTypes, Gpio_Edges, Gpio_States
24
+ from boneio.const import GPIO_MODE, LOW, ClickTypes, Gpio_Edges, Gpio_States, InputTypes
25
25
  from boneio.helper.exceptions import GPIOInputException
26
26
  from boneio.helper.timeperiod import TimePeriod
27
+ from concurrent.futures import ThreadPoolExecutor
27
28
 
28
29
  _LOGGER = logging.getLogger(__name__)
29
30
 
@@ -81,22 +82,20 @@ def edge_detect(
81
82
  GPIO.add_event_detect(gpio=pin, edge=edge, callback=callback, bouncetime=bounce)
82
83
  except RuntimeError as err:
83
84
  raise GPIOInputException(err)
84
-
85
- def add_event_detect(
86
- pin: str, edge: Gpio_Edges = FALLING
87
- ) -> None:
85
+
86
+
87
+ def add_event_detect(pin: str, edge: Gpio_Edges = FALLING) -> None:
88
88
  """Add detection for RISING and FALLING events."""
89
89
  try:
90
90
  GPIO.add_event_detect(gpio=pin, edge=edge)
91
91
  except RuntimeError as err:
92
92
  raise GPIOInputException(err)
93
-
94
- def add_event_callback(
95
- pin: str, callback: Callable
96
- ) -> None:
93
+
94
+
95
+ def add_event_callback(pin: str, callback: Callable) -> None:
97
96
  """Add detection for RISING and FALLING events."""
98
97
  try:
99
- GPIO.add_event_callback(gpio=pin,callback=callback)
98
+ GPIO.add_event_callback(gpio=pin, callback=callback)
100
99
  except RuntimeError as err:
101
100
  raise GPIOInputException(err)
102
101
 
@@ -105,24 +104,61 @@ class GpioBaseClass:
105
104
  """Base class for initialize GPIO"""
106
105
 
107
106
  def __init__(
108
- self, pin: str, press_callback: Callable[[ClickTypes, str, bool | None], None], **kwargs
107
+ self,
108
+ pin: str,
109
+ press_callback: Callable[
110
+ [ClickTypes, str, List, InputTypes, bool, float | None], Awaitable[None]
111
+ ],
112
+ name: str,
113
+ actions: dict,
114
+ input_type,
115
+ empty_message_after: bool,
116
+ **kwargs,
109
117
  ) -> None:
110
118
  """Setup GPIO Input Button"""
111
119
  self._pin = pin
112
120
  gpio_mode = kwargs.get(GPIO_MODE, GPIO_STR)
113
- self._bounce_time = kwargs.get("bounce_time", TimePeriod(milliseconds=50))
121
+ bounce_time: TimePeriod = kwargs.get("bounce_time", TimePeriod(milliseconds=50))
122
+ self._bounce_time = bounce_time.total_in_seconds
114
123
  self._loop = asyncio.get_running_loop()
115
124
  self._press_callback = press_callback
125
+ self._name = name
116
126
  setup_input(pin=self._pin, pull_mode=gpio_mode)
127
+ self.executor = ThreadPoolExecutor()
128
+ self._actions = actions
129
+ self._input_type = input_type
130
+ self._empty_message_after = empty_message_after
117
131
 
118
- def set_press_callback(self, press_callback: Callable[[ClickTypes, str, bool | None], None]) -> None:
119
- self._press_callback = press_callback
132
+ def press_callback(self, click_type: ClickTypes, duration: float | None = None) -> None:
133
+ actions = self._actions.get(click_type, [])
134
+ self._loop.create_task(self.async_press_callback(click_type, duration, actions))
135
+
136
+ async def async_press_callback(
137
+ self, click_type: ClickTypes, duration: float | None = None, actions: List = []
138
+ ) -> None:
139
+ _LOGGER.warn("press callback %s", datetime.now())
140
+ await self._press_callback(
141
+ click_type,
142
+ self._pin,
143
+ actions,
144
+ self._input_type,
145
+ self._empty_message_after,
146
+ duration,
147
+ )
148
+
149
+ def set_actions(self, actions: dict) -> None:
150
+ self._actions = actions
120
151
 
121
152
  @property
122
153
  def is_pressed(self) -> bool:
123
154
  """Is button pressed."""
124
155
  return read_input(self._pin)
125
-
156
+
157
+ @property
158
+ def name(self) -> str:
159
+ """Name of the GPIO visible in HA/MQTT."""
160
+ return self._name
161
+
126
162
  @property
127
163
  def pin(self) -> str:
128
164
  """Return configured pin."""
@@ -131,6 +131,28 @@ def ha_binary_sensor_availabilty_message(id: str, name: str, device_class: str,
131
131
  }
132
132
 
133
133
 
134
+ def ha_sensor_ina_availabilty_message(
135
+ id: str, name: str, topic: str = "boneIO", **kwargs
136
+ ):
137
+ """Create availability topic for HA."""
138
+ return {
139
+ "availability": [{"topic": f"{topic}/{STATE}"}],
140
+ "device": {
141
+ "identifiers": [topic],
142
+ "manufacturer": "boneIO",
143
+ "model": "boneIO Relay Board",
144
+ "name": f"boneIO {topic}",
145
+ "sw_version": __version__,
146
+ },
147
+ "name": name,
148
+ "state_topic": f"{topic}/{SENSOR}/{id}",
149
+ "unique_id": f"{topic}{SENSOR}{id}",
150
+ "state_class": "measurement",
151
+ "value_template": "{{ value_json.state }}",
152
+ **kwargs,
153
+ }
154
+
155
+
134
156
  def ha_sensor_temp_availabilty_message(
135
157
  id: str, name: str, topic: str = "boneIO", **kwargs
136
158
  ):