boneIO 0.6.3.dev4__py3-none-any.whl → 0.7.0.dev1__py3-none-any.whl
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.
- {boneIO-0.6.3.dev4.dist-info → boneIO-0.7.0.dev1.dist-info}/METADATA +10 -10
- {boneIO-0.6.3.dev4.dist-info → boneIO-0.7.0.dev1.dist-info}/RECORD +27 -23
- boneio/const.py +1 -0
- boneio/example_config/binary_sensor.yaml +19 -0
- boneio/example_config/config.yaml +2 -1
- boneio/example_config/{input.yaml → event.yaml} +0 -20
- boneio/example_config/output24x16A_v0.3.yaml +143 -0
- boneio/helper/__init__.py +2 -2
- boneio/helper/config.py +3 -2
- boneio/helper/ha_discovery.py +5 -1
- boneio/helper/loader.py +46 -12
- boneio/input/__init__.py +4 -2
- boneio/input/gpio.py +39 -53
- boneio/input/gpio_beta.py +84 -0
- boneio/manager.py +27 -11
- boneio/mqtt_client.py +1 -2
- boneio/runner.py +4 -2
- boneio/schema/schema.yaml +82 -9
- boneio/sensor/__init__.py +4 -2
- boneio/sensor/adc.py +2 -1
- boneio/sensor/gpio.py +4 -4
- boneio/sensor/gpio_beta.py +35 -0
- boneio/version.py +1 -1
- {boneIO-0.6.3.dev4.dist-info → boneIO-0.7.0.dev1.dist-info}/WHEEL +0 -0
- {boneIO-0.6.3.dev4.dist-info → boneIO-0.7.0.dev1.dist-info}/entry_points.txt +0 -0
- {boneIO-0.6.3.dev4.dist-info → boneIO-0.7.0.dev1.dist-info}/licenses/LICENSE +0 -0
- boneio/example_config/{adc.yaml → adc_v0_4.yaml} +6 -6
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: boneIO
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0dev1
|
|
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>
|
|
7
7
|
Requires-Python: >=3.7
|
|
8
8
|
Requires-Dist: Adafruit-BBIO>=1.2.0
|
|
9
|
-
Requires-Dist: Adafruit-Blinka>=8.
|
|
9
|
+
Requires-Dist: Adafruit-Blinka>=8.20.1
|
|
10
10
|
Requires-Dist: Cerberus>=1.3.4
|
|
11
|
-
Requires-Dist: PyYAML>=6.0
|
|
12
|
-
Requires-Dist: adafruit-circuitpython-ds18x20>=1.3.
|
|
13
|
-
Requires-Dist: adafruit-circuitpython-mcp230xx>=2.5.
|
|
14
|
-
Requires-Dist: adafruit-circuitpython-mcp9808>=3.3.
|
|
15
|
-
Requires-Dist: adafruit-circuitpython-onewire>=2.0.
|
|
16
|
-
Requires-Dist: adafruit-circuitpython-pca9685>=3.4.
|
|
17
|
-
Requires-Dist: adafruit-circuitpython-pct2075>=1.1.
|
|
18
|
-
Requires-Dist:
|
|
11
|
+
Requires-Dist: PyYAML>=6.0.1
|
|
12
|
+
Requires-Dist: adafruit-circuitpython-ds18x20>=1.3.17
|
|
13
|
+
Requires-Dist: adafruit-circuitpython-mcp230xx>=2.5.11
|
|
14
|
+
Requires-Dist: adafruit-circuitpython-mcp9808>=3.3.21
|
|
15
|
+
Requires-Dist: adafruit-circuitpython-onewire>=2.0.5
|
|
16
|
+
Requires-Dist: adafruit-circuitpython-pca9685>=3.4.10
|
|
17
|
+
Requires-Dist: adafruit-circuitpython-pct2075>=1.1.19
|
|
18
|
+
Requires-Dist: aiomqtt>=1.1.0
|
|
19
19
|
Requires-Dist: colorlog>=6.7.0
|
|
20
20
|
Requires-Dist: gpio>=1.0.0
|
|
21
21
|
Requires-Dist: luma-core>=2.4.0
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
boneio/__init__.py,sha256=hoLKnu6h1uEsiCHA9Ql2MMDC7VQS0E-s_2cxBS-CTOg,147
|
|
2
2
|
boneio/bonecli.py,sha256=VhY1BMt6OaZz-752UjhEexdn8fDJkJaDWcGQNhCmgN0,3341
|
|
3
|
-
boneio/const.py,sha256=
|
|
3
|
+
boneio/const.py,sha256=4HRCWvh1dslJ37vMUp_NL2weeQjEkzi-z4iAcmik4MU,2947
|
|
4
4
|
boneio/cover.py,sha256=nr76ft5smAPdBB8Jytk-uFd6RWuqtcZiG6EE129OUjw,8454
|
|
5
5
|
boneio/example_config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
boneio/example_config/
|
|
7
|
-
boneio/example_config/
|
|
6
|
+
boneio/example_config/adc_v0_4.yaml,sha256=GKNpl2t7ebsH57UhJlJioXNuBflsL6eO4JMnyYwZrFs,168
|
|
7
|
+
boneio/example_config/binary_sensor.yaml,sha256=0-KfPuACU6Q8krtNLQ_Bu8135xLEeCrs8UhGXR7kCxU,238
|
|
8
|
+
boneio/example_config/config.yaml,sha256=6yU-RLTeHWKFcZbhri6wsZTBmoDTjQbf3R8NDYu5ils,369
|
|
8
9
|
boneio/example_config/cover.yaml,sha256=rs7lv3vIEgAb3q96RKsJL7VMRsEvSNHG848dzZzSKsI,150
|
|
9
|
-
boneio/example_config/
|
|
10
|
+
boneio/example_config/event.yaml,sha256=SIuR_sbxSMuFkigC_zyz7aZbDHXrZnnuh3OBC9mCuvU,2644
|
|
10
11
|
boneio/example_config/led32x4A.yaml,sha256=YkcZ5XH2JF9Oa3pAmrYM5wsE8qQODCHcjYH47AEQpUI,3392
|
|
11
12
|
boneio/example_config/output24x16A.yaml,sha256=BTtHToRgz-U_rMMDbmHkM4wQxHakdzInb3zKMkOkj4w,1691
|
|
13
|
+
boneio/example_config/output24x16A_v0.3.yaml,sha256=XkI4rHn_XdX37xG02-wHieZzSHKiKN5mtnyfRE24NII,1713
|
|
12
14
|
boneio/example_config/output32x5A.yaml,sha256=G2Pb6qL8mXs6MliIM1roAanPag9ozRe3McYYuFsiBc0,2403
|
|
13
15
|
boneio/fonts/danube__.ttf,sha256=KBRPUcGvmroCjrWC8zK4MulUb9lV8R0lXkOY7lNnQWc,19372
|
|
14
|
-
boneio/helper/__init__.py,sha256=
|
|
16
|
+
boneio/helper/__init__.py,sha256=zizPsGPbEtcqUsFWOxhs8s4H6PeJvJq8tP0OvCVJ_C4,2039
|
|
15
17
|
boneio/helper/async_updater.py,sha256=BVh5mXFxgaZqoekjQbQSCTssfyVIdCQ80LCJny-rOo4,985
|
|
16
18
|
boneio/helper/click_timer.py,sha256=dVYdX3VNpAEKHCIqWs3u0PCJLSPIGr0K2kMffc_kGdc,1138
|
|
17
|
-
boneio/helper/config.py,sha256=
|
|
19
|
+
boneio/helper/config.py,sha256=HUl7iF7os1-YNfl1neJf2aDwiS2VE43biGefU5EhW3s,2321
|
|
18
20
|
boneio/helper/events.py,sha256=EHYJy507RF1LikWQ2s4r990JRvR9rO4z7FkaJqt1Mrk,7494
|
|
19
21
|
boneio/helper/exceptions.py,sha256=vyYSUojwB7OttOPUjbxeHFM7C_o5ZQmRUcZ_vYpxYYI,717
|
|
20
22
|
boneio/helper/filter.py,sha256=UcjifjaC5wHDW2He7wmwCX2IjSSeLVhXyhrXHeT8RmA,885
|
|
21
23
|
boneio/helper/gpio.py,sha256=sxvkYtKVt5alGoXFBRzG8ONEo112fsKsX-zK2C-_YKg,3249
|
|
22
|
-
boneio/helper/ha_discovery.py,sha256=
|
|
23
|
-
boneio/helper/loader.py,sha256=
|
|
24
|
+
boneio/helper/ha_discovery.py,sha256=ErAub0LK9y2fUieqUsHpixQATO1NQ_ZABGELVYDAZtE,6359
|
|
25
|
+
boneio/helper/loader.py,sha256=qrTntQ_AhkY-8-kL54H65pqAfyMFEwoXPIll6q5EyXw,14895
|
|
24
26
|
boneio/helper/logger.py,sha256=zyF_Vk3o2eSHuXypJhNzK99eZgkWDWybuB5KcJgurDs,1801
|
|
25
27
|
boneio/helper/mqtt.py,sha256=UVa4KaxvVif6By_sVMdSMiYI_doZjiXF4LS9RFltxJk,765
|
|
26
28
|
boneio/helper/oled.py,sha256=f0XYbaFstUbJ6ISmFe1vQCnmNVMctQWtnStNdROrblc,351
|
|
@@ -34,30 +36,32 @@ boneio/helper/stats.py,sha256=XNQDU-ixIobKQ2batzZno2UOMzNGWHSFQ-EXChNBJzM,5853
|
|
|
34
36
|
boneio/helper/timeperiod.py,sha256=xpg9oe30Z5WiLDQPq3EBKKScejOnN47NhcpeFvDd3bY,5806
|
|
35
37
|
boneio/helper/util.py,sha256=QfSoT3H3WnOQAKO5bFRIBCy62HT5NMa9Ek-FmfTW_rw,508
|
|
36
38
|
boneio/helper/yaml_util.py,sha256=gAX7hCaHUlPgkhGCIQ4zjv0Vj9JmLzQsSyF51ZmSb9g,11304
|
|
37
|
-
boneio/input/__init__.py,sha256=
|
|
38
|
-
boneio/input/gpio.py,sha256=
|
|
39
|
-
boneio/
|
|
39
|
+
boneio/input/__init__.py,sha256=ZM6G2XX621lQUy8Tk6S8zf_jBp_NxsK6OHMMrdsOsDo,178
|
|
40
|
+
boneio/input/gpio.py,sha256=4YPzwtyWuEWdDQWte5YU-X_vaId2wFy_XWv7WkjzFoQ,2611
|
|
41
|
+
boneio/input/gpio_beta.py,sha256=mBMIpVUEyH-CJpb2TtHDiiYaVFYdzjExcDGeOxx9PYQ,3133
|
|
42
|
+
boneio/manager.py,sha256=RRKiKq26hNWf2MXaVWnh07_AFObajsMiAeerJxvN2uU,21785
|
|
40
43
|
boneio/modbus.py,sha256=eA_sGnmdcIneXX75ZcXOI223-UkKN1UYmWFqiJBAhJo,4176
|
|
41
|
-
boneio/mqtt_client.py,sha256=
|
|
44
|
+
boneio/mqtt_client.py,sha256=xADbqvQQnSqGBFw294_DyDkgIomwCveY6e1RaJC0Igk,8302
|
|
42
45
|
boneio/oled.py,sha256=d_ofDQHc7zr3j0qOR0B_L3C8TJhvRH85nnb9Le-88nk,5244
|
|
43
46
|
boneio/relay/__init__.py,sha256=iLEUL8kxnEndCQtgDIJfHqUZOfyWfWmuOrqSYAUxb2w,181
|
|
44
47
|
boneio/relay/basic.py,sha256=QEWG8HodBqEqLpQxcQm29hdPIxO7c6ep0uDgfo3pcco,2623
|
|
45
48
|
boneio/relay/gpio.py,sha256=s64FBf6zlxciF57xJ6nrvy0t5Rie0uiXlwos0HL3RKM,1163
|
|
46
49
|
boneio/relay/mcp.py,sha256=DhgqZbFHB6TucL9hJaJiqdVAbkw4Rv5VPHm_khSBIFo,2669
|
|
47
50
|
boneio/relay/pca.py,sha256=tCwXvMJcsxzFj48ZO2tPYyvElZfyIRTFmEMp7ENKvtk,4873
|
|
48
|
-
boneio/runner.py,sha256=
|
|
51
|
+
boneio/runner.py,sha256=8cOWpFFf02IwC9vaCdexcCTN1kP0_yKMBPT35PEHwHM,2653
|
|
49
52
|
boneio/schema/actions.yaml,sha256=WD0LR9SxVPgwU12x10RvFaTeyDiCjdRiicfkrCGLNvc,1030
|
|
50
53
|
boneio/schema/actions_sensor.yaml,sha256=U_VfdjqdorQZHYD6dZOzhlRKnOGwsnTJ3CDGiqrKxW8,124
|
|
51
54
|
boneio/schema/actions_switch.yaml,sha256=sdqhwz0LrcfaiAN3-RfAR_xApxo5dh9RxXQubuKcsjk,129
|
|
52
55
|
boneio/schema/filters.yaml,sha256=WopX1SmCZsSZXNiGccLoi7uMCsUpdbs0eVfsAjmbay4,286
|
|
53
56
|
boneio/schema/filters_adc.yaml,sha256=3e0ts92MoFKOnfGOOn6WYIHxu0-tnZe9OjAjN9m7hiI,304
|
|
54
57
|
boneio/schema/id.yaml,sha256=vHI_6dxkJwoiGp5ien_pPpyaWA1F06eirTgfWMyWa1E,75
|
|
55
|
-
boneio/schema/schema.yaml,sha256=
|
|
58
|
+
boneio/schema/schema.yaml,sha256=NxG-4i3Sak27sOWk_nf8Bmbwgt5Ldye4ZYnRIvR_79g,15072
|
|
56
59
|
boneio/schema/temp_unit.yaml,sha256=m32VGz9RTW92Lz08l9n6RftkcVNZquOGPPr5mc3eZVc,65
|
|
57
60
|
boneio/schema/update_interval.yaml,sha256=L_YLddAZdybcdO-T57Qhlv1GaWIVDwhvH-GadD1oOIo,133
|
|
58
|
-
boneio/sensor/__init__.py,sha256=
|
|
59
|
-
boneio/sensor/adc.py,sha256=
|
|
60
|
-
boneio/sensor/gpio.py,sha256=
|
|
61
|
+
boneio/sensor/__init__.py,sha256=u-fSBKy1gcXTNclra5KzLYDxpHeo9G0vuNiMexIZSDw,538
|
|
62
|
+
boneio/sensor/adc.py,sha256=tCUdr3KN5uSbgXiwhNXbMjeNkO2CzPYhIOncHR5_LD0,1328
|
|
63
|
+
boneio/sensor/gpio.py,sha256=a9HljBbXr5YdCImZ85dBlTgIZZBsL38UEmAmRcDMp0w,1296
|
|
64
|
+
boneio/sensor/gpio_beta.py,sha256=K1sxxnRDWmhTcRjmWZ-tjDAza4rLDamsx_8_jK3TMxU,1284
|
|
61
65
|
boneio/sensor/modbus/__init__.py,sha256=IUwGdGn_egqOcSZrt4tTu0n8APnc0M7uau7XUWDlhes,8520
|
|
62
66
|
boneio/sensor/modbus/dts1964_3f.json,sha256=WABph_2X4OgMidSM28vw4dLd9ZByRoiUP-RqE0UMpR8,8810
|
|
63
67
|
boneio/sensor/modbus/pt100.json,sha256=bzKNYDc3lMto94Ut8gutVIsHytQiMobwFCkonOiMegs,526
|
|
@@ -69,9 +73,9 @@ boneio/sensor/temp/__init__.py,sha256=OViqBb7DwVn_aFIy6V0iqkSUDjsDNLQ5sOS_4frYdw
|
|
|
69
73
|
boneio/sensor/temp/dallas.py,sha256=xrvd1LNBh1fRcjz_yd_9S29Lv26ItVtLCmhZgVQWJos,2485
|
|
70
74
|
boneio/sensor/temp/lm75.py,sha256=-mpOv78429plRPBp9s09Ljz1x2Bdxuagalqz40vlAKE,243
|
|
71
75
|
boneio/sensor/temp/mcp9808.py,sha256=yAh5yJzZLGTqa39xV4fyqsruj7oy3niOZAUV2W6eyCM,271
|
|
72
|
-
boneio/version.py,sha256=
|
|
73
|
-
boneIO-0.
|
|
74
|
-
boneIO-0.
|
|
75
|
-
boneIO-0.
|
|
76
|
-
boneIO-0.
|
|
77
|
-
boneIO-0.
|
|
76
|
+
boneio/version.py,sha256=ig8n6Qd2PUEB4oYuBg_tNATNBQRkzy1TPKoHWipXRX0,41
|
|
77
|
+
boneIO-0.7.0.dev1.dist-info/entry_points.txt,sha256=Igl1SMDEWwMg144bwRz28UOCb80hdxomC99QJ3u6qC0,46
|
|
78
|
+
boneIO-0.7.0.dev1.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
|
|
79
|
+
boneIO-0.7.0.dev1.dist-info/METADATA,sha256=6jXEUsPHVyv_Ym0uIFA0Wfrk130xp7059FuIjrkv7jY,1696
|
|
80
|
+
boneIO-0.7.0.dev1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
81
|
+
boneIO-0.7.0.dev1.dist-info/RECORD,,
|
boneio/const.py
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
- id: IN_47
|
|
2
|
+
pin: P8_12
|
|
3
|
+
kind: sensor
|
|
4
|
+
- id: IN_48
|
|
5
|
+
pin: P8_11
|
|
6
|
+
kind: sensor
|
|
7
|
+
- id: IN_49
|
|
8
|
+
pin: P8_10
|
|
9
|
+
kind: sensor
|
|
10
|
+
|
|
11
|
+
- id: IN_50
|
|
12
|
+
pin: P8_9
|
|
13
|
+
kind: sensor
|
|
14
|
+
- id: IN_51
|
|
15
|
+
pin: P8_8
|
|
16
|
+
kind: sensor
|
|
17
|
+
- id: IN_52
|
|
18
|
+
pin: P8_7
|
|
19
|
+
kind: sensor
|
|
@@ -182,23 +182,3 @@
|
|
|
182
182
|
pin: P8_14
|
|
183
183
|
- id: IN_46
|
|
184
184
|
pin: P8_13
|
|
185
|
-
|
|
186
|
-
- id: IN_47
|
|
187
|
-
pin: P8_12
|
|
188
|
-
kind: sensor
|
|
189
|
-
- id: IN_48
|
|
190
|
-
pin: P8_11
|
|
191
|
-
kind: sensor
|
|
192
|
-
- id: IN_49
|
|
193
|
-
pin: P8_10
|
|
194
|
-
kind: sensor
|
|
195
|
-
|
|
196
|
-
- id: IN_50
|
|
197
|
-
pin: P8_9
|
|
198
|
-
kind: sensor
|
|
199
|
-
- id: IN_51
|
|
200
|
-
pin: P8_8
|
|
201
|
-
kind: sensor
|
|
202
|
-
- id: IN_52
|
|
203
|
-
pin: P8_7
|
|
204
|
-
kind: sensor
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
- id: OUT_01
|
|
2
|
+
kind: mcp
|
|
3
|
+
mcp_id: mcp1
|
|
4
|
+
pin: 9
|
|
5
|
+
output_type: light
|
|
6
|
+
|
|
7
|
+
- id: OUT_02
|
|
8
|
+
kind: mcp
|
|
9
|
+
mcp_id: mcp1
|
|
10
|
+
pin: 8
|
|
11
|
+
output_type: light
|
|
12
|
+
|
|
13
|
+
- id: OUT_03
|
|
14
|
+
kind: mcp
|
|
15
|
+
mcp_id: mcp2
|
|
16
|
+
pin: 1
|
|
17
|
+
output_type: light
|
|
18
|
+
|
|
19
|
+
- id: OUT_04
|
|
20
|
+
kind: mcp
|
|
21
|
+
mcp_id: mcp2
|
|
22
|
+
pin: 0
|
|
23
|
+
output_type: light
|
|
24
|
+
|
|
25
|
+
- id: OUT_05
|
|
26
|
+
kind: mcp
|
|
27
|
+
mcp_id: mcp1
|
|
28
|
+
pin: 13
|
|
29
|
+
output_type: light
|
|
30
|
+
|
|
31
|
+
- id: OUT_06
|
|
32
|
+
kind: mcp
|
|
33
|
+
mcp_id: mcp1
|
|
34
|
+
pin: 12
|
|
35
|
+
output_type: light
|
|
36
|
+
|
|
37
|
+
- id: OUT_07
|
|
38
|
+
kind: mcp
|
|
39
|
+
mcp_id: mcp1
|
|
40
|
+
pin: 11
|
|
41
|
+
output_type: light
|
|
42
|
+
|
|
43
|
+
- id: OUT_08
|
|
44
|
+
kind: mcp
|
|
45
|
+
mcp_id: mcp1
|
|
46
|
+
pin: 10
|
|
47
|
+
output_type: light
|
|
48
|
+
|
|
49
|
+
- id: OUT_09
|
|
50
|
+
kind: mcp
|
|
51
|
+
mcp_id: mcp2
|
|
52
|
+
pin: 14
|
|
53
|
+
output_type: light
|
|
54
|
+
|
|
55
|
+
- id: OUT_10
|
|
56
|
+
kind: mcp
|
|
57
|
+
mcp_id: mcp2
|
|
58
|
+
pin: 15
|
|
59
|
+
output_type: light
|
|
60
|
+
|
|
61
|
+
- id: OUT_11
|
|
62
|
+
kind: mcp
|
|
63
|
+
mcp_id: mcp2
|
|
64
|
+
pin: 13
|
|
65
|
+
output_type: light
|
|
66
|
+
|
|
67
|
+
- id: OUT_12
|
|
68
|
+
kind: mcp
|
|
69
|
+
mcp_id: mcp2
|
|
70
|
+
pin: 12
|
|
71
|
+
output_type: light
|
|
72
|
+
|
|
73
|
+
- id: OUT_13
|
|
74
|
+
kind: mcp
|
|
75
|
+
mcp_id: mcp1
|
|
76
|
+
pin: 6
|
|
77
|
+
output_type: light
|
|
78
|
+
|
|
79
|
+
- id: OUT_14
|
|
80
|
+
kind: mcp
|
|
81
|
+
mcp_id: mcp1
|
|
82
|
+
pin: 5
|
|
83
|
+
output_type: light
|
|
84
|
+
|
|
85
|
+
- id: OUT_15
|
|
86
|
+
kind: mcp
|
|
87
|
+
mcp_id: mcp1
|
|
88
|
+
pin: 4
|
|
89
|
+
output_type: light
|
|
90
|
+
|
|
91
|
+
- id: OUT_16
|
|
92
|
+
kind: mcp
|
|
93
|
+
mcp_id: mcp1
|
|
94
|
+
pin: 3
|
|
95
|
+
output_type: light
|
|
96
|
+
|
|
97
|
+
- id: OUT_17
|
|
98
|
+
kind: mcp
|
|
99
|
+
mcp_id: mcp1
|
|
100
|
+
pin: 2
|
|
101
|
+
output_type: light
|
|
102
|
+
|
|
103
|
+
- id: OUT_18
|
|
104
|
+
kind: mcp
|
|
105
|
+
mcp_id: mcp1
|
|
106
|
+
pin: 0
|
|
107
|
+
output_type: light
|
|
108
|
+
|
|
109
|
+
- id: OUT_19
|
|
110
|
+
kind: mcp
|
|
111
|
+
mcp_id: mcp1
|
|
112
|
+
pin: 1
|
|
113
|
+
output_type: light
|
|
114
|
+
|
|
115
|
+
- id: OUT_20
|
|
116
|
+
kind: mcp
|
|
117
|
+
mcp_id: mcp1
|
|
118
|
+
pin: 7
|
|
119
|
+
output_type: light
|
|
120
|
+
|
|
121
|
+
- id: OUT_21
|
|
122
|
+
kind: mcp
|
|
123
|
+
mcp_id: mcp2
|
|
124
|
+
pin: 8
|
|
125
|
+
output_type: light
|
|
126
|
+
|
|
127
|
+
- id: OUT_22
|
|
128
|
+
kind: mcp
|
|
129
|
+
mcp_id: mcp2
|
|
130
|
+
pin: 9
|
|
131
|
+
output_type: light
|
|
132
|
+
|
|
133
|
+
- id: OUT_23
|
|
134
|
+
kind: mcp
|
|
135
|
+
mcp_id: mcp2
|
|
136
|
+
pin: 11
|
|
137
|
+
output_type: light
|
|
138
|
+
|
|
139
|
+
- id: OUT_24
|
|
140
|
+
kind: mcp
|
|
141
|
+
mcp_id: mcp2
|
|
142
|
+
pin: 10
|
|
143
|
+
output_type: light
|
boneio/helper/__init__.py
CHANGED
|
@@ -15,7 +15,7 @@ from boneio.helper.ha_discovery import (
|
|
|
15
15
|
ha_adc_sensor_availabilty_message,
|
|
16
16
|
ha_binary_sensor_availabilty_message,
|
|
17
17
|
ha_button_availabilty_message,
|
|
18
|
-
|
|
18
|
+
ha_event_availabilty_message,
|
|
19
19
|
ha_light_availabilty_message,
|
|
20
20
|
ha_sensor_availabilty_message,
|
|
21
21
|
ha_sensor_temp_availabilty_message,
|
|
@@ -54,7 +54,7 @@ __all__ = [
|
|
|
54
54
|
"ha_sensor_temp_availabilty_message",
|
|
55
55
|
"ha_binary_sensor_availabilty_message",
|
|
56
56
|
"ha_button_availabilty_message",
|
|
57
|
-
"
|
|
57
|
+
"ha_event_availabilty_message",
|
|
58
58
|
"ha_led_availabilty_message",
|
|
59
59
|
"GPIOInputException",
|
|
60
60
|
"GPIOOutputException",
|
boneio/helper/config.py
CHANGED
|
@@ -4,7 +4,7 @@ Module to provide basic config options.
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
from _collections_abc import dict_values
|
|
6
6
|
from typing import Union
|
|
7
|
-
from boneio.const import BONEIO, HOMEASSISTANT, LIGHT, SENSOR, COVER, BUTTON, SWITCH, BINARY_SENSOR
|
|
7
|
+
from boneio.const import BONEIO, HOMEASSISTANT, LIGHT, SENSOR, COVER, BUTTON, SWITCH, BINARY_SENSOR, EVENT_ENTITY
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ConfigHelper:
|
|
@@ -24,7 +24,8 @@ class ConfigHelper:
|
|
|
24
24
|
BINARY_SENSOR: {},
|
|
25
25
|
SENSOR: {},
|
|
26
26
|
COVER: {},
|
|
27
|
-
BUTTON: {}
|
|
27
|
+
BUTTON: {},
|
|
28
|
+
EVENT_ENTITY: {}
|
|
28
29
|
}
|
|
29
30
|
self.manager_ready: bool = False
|
|
30
31
|
|
boneio/helper/ha_discovery.py
CHANGED
|
@@ -13,6 +13,9 @@ from boneio.const import (
|
|
|
13
13
|
SENSOR,
|
|
14
14
|
STATE,
|
|
15
15
|
STOP,
|
|
16
|
+
SINGLE,
|
|
17
|
+
DOUBLE,
|
|
18
|
+
LONG
|
|
16
19
|
)
|
|
17
20
|
from boneio.version import __version__
|
|
18
21
|
|
|
@@ -86,9 +89,10 @@ def ha_switch_availabilty_message(id: str, topic: str = "boneIO", **kwargs):
|
|
|
86
89
|
return msg
|
|
87
90
|
|
|
88
91
|
|
|
89
|
-
def
|
|
92
|
+
def ha_event_availabilty_message(**kwargs):
|
|
90
93
|
msg = ha_availabilty_message(device_type=INPUT, **kwargs)
|
|
91
94
|
msg["icon"] = "mdi:gesture-double-tap"
|
|
95
|
+
msg["event_types"] = [SINGLE, DOUBLE, LONG]
|
|
92
96
|
return msg
|
|
93
97
|
|
|
94
98
|
|
boneio/helper/loader.py
CHANGED
|
@@ -37,6 +37,7 @@ from boneio.const import (
|
|
|
37
37
|
SHOW_HA,
|
|
38
38
|
UPDATE_INTERVAL,
|
|
39
39
|
DallasBusTypes,
|
|
40
|
+
EVENT_ENTITY
|
|
40
41
|
)
|
|
41
42
|
from boneio.cover import Cover
|
|
42
43
|
from boneio.helper import (
|
|
@@ -46,7 +47,7 @@ from boneio.helper import (
|
|
|
46
47
|
StateManager,
|
|
47
48
|
ha_adc_sensor_availabilty_message,
|
|
48
49
|
ha_binary_sensor_availabilty_message,
|
|
49
|
-
|
|
50
|
+
ha_event_availabilty_message,
|
|
50
51
|
ha_sensor_temp_availabilty_message,
|
|
51
52
|
)
|
|
52
53
|
from boneio.helper.onewire import (
|
|
@@ -58,8 +59,8 @@ from boneio.helper.onewire import (
|
|
|
58
59
|
)
|
|
59
60
|
from boneio.helper.ha_discovery import ha_cover_availabilty_message
|
|
60
61
|
from boneio.helper.timeperiod import TimePeriod
|
|
61
|
-
from boneio.input
|
|
62
|
-
from boneio.sensor import DallasSensorDS2482
|
|
62
|
+
from boneio.input import GpioEventButton, GpioEventButtonBeta
|
|
63
|
+
from boneio.sensor import DallasSensorDS2482, GpioInputBinarySensor, GpioInputBinarySensorBeta
|
|
63
64
|
from boneio.sensor.temp.dallas import DallasSensorW1
|
|
64
65
|
|
|
65
66
|
# Typing imports that create a circular dependency
|
|
@@ -70,7 +71,6 @@ from busio import I2C
|
|
|
70
71
|
|
|
71
72
|
from boneio.relay import GpioRelay, MCPRelay, PWMPCA
|
|
72
73
|
from boneio.sensor import GpioADCSensor, initialize_adc
|
|
73
|
-
from boneio.sensor.gpio import GpioInputSensor
|
|
74
74
|
|
|
75
75
|
_LOGGER = logging.getLogger(__name__)
|
|
76
76
|
|
|
@@ -94,6 +94,7 @@ def create_adc(manager: Manager, topic_prefix: str, adc_list: list = []):
|
|
|
94
94
|
send_message=manager.send_message,
|
|
95
95
|
topic_prefix=topic_prefix,
|
|
96
96
|
update_interval=gpio.get(UPDATE_INTERVAL, TimePeriod(seconds=60)),
|
|
97
|
+
filters=gpio.get(FILTERS, []),
|
|
97
98
|
)
|
|
98
99
|
if gpio.get(SHOW_HA, True):
|
|
99
100
|
manager.send_ha_autodiscovery(
|
|
@@ -321,16 +322,16 @@ def input_chooser(input_type: str):
|
|
|
321
322
|
"""Get named tuple based on input."""
|
|
322
323
|
if input_type == SENSOR:
|
|
323
324
|
return InputEntry(
|
|
324
|
-
|
|
325
|
+
GpioInputBinarySensor,
|
|
325
326
|
INPUT_SENSOR,
|
|
326
327
|
BINARY_SENSOR,
|
|
327
328
|
ha_binary_sensor_availabilty_message,
|
|
328
329
|
)
|
|
329
330
|
else:
|
|
330
|
-
return InputEntry(
|
|
331
|
+
return InputEntry(GpioEventButton, INPUT, EVENT_ENTITY, ha_event_availabilty_message)
|
|
331
332
|
|
|
332
333
|
|
|
333
|
-
def
|
|
334
|
+
def configure_event_sensor(
|
|
334
335
|
gpio: dict,
|
|
335
336
|
pin: str,
|
|
336
337
|
press_callback: Callable,
|
|
@@ -338,14 +339,15 @@ def configure_input(
|
|
|
338
339
|
) -> str:
|
|
339
340
|
"""Configure input sensor or button."""
|
|
340
341
|
try:
|
|
341
|
-
|
|
342
|
-
|
|
342
|
+
GpioEventButtonClass = GpioEventButton if gpio.get("detection_type", "stable") == "stable" else GpioEventButtonBeta
|
|
343
|
+
GpioEventButtonClass(
|
|
343
344
|
pin=pin,
|
|
344
345
|
press_callback=lambda x, i: press_callback(
|
|
345
346
|
x=x,
|
|
346
347
|
inpin=i,
|
|
347
348
|
actions=gpio.get(ACTIONS, {}).get(x, []),
|
|
348
|
-
input_type=
|
|
349
|
+
input_type=INPUT,
|
|
350
|
+
empty_message_after=gpio.get("clear_message", False)
|
|
349
351
|
),
|
|
350
352
|
**gpio,
|
|
351
353
|
)
|
|
@@ -353,15 +355,47 @@ def configure_input(
|
|
|
353
355
|
send_ha_autodiscovery(
|
|
354
356
|
id=pin,
|
|
355
357
|
name=gpio.get(ID, pin),
|
|
356
|
-
ha_type=
|
|
358
|
+
ha_type=EVENT_ENTITY,
|
|
357
359
|
device_class=gpio.get(DEVICE_CLASS, None),
|
|
358
|
-
availability_msg_func=
|
|
360
|
+
availability_msg_func=ha_event_availabilty_message,
|
|
359
361
|
)
|
|
360
362
|
return pin
|
|
361
363
|
except GPIOInputException as err:
|
|
362
364
|
_LOGGER.error("This PIN %s can't be configured. %s", pin, err)
|
|
363
365
|
pass
|
|
364
366
|
|
|
367
|
+
def configure_binary_sensor(
|
|
368
|
+
gpio: dict,
|
|
369
|
+
pin: str,
|
|
370
|
+
press_callback: Callable,
|
|
371
|
+
send_ha_autodiscovery: Callable,
|
|
372
|
+
) -> str:
|
|
373
|
+
"""Configure input sensor or button."""
|
|
374
|
+
try:
|
|
375
|
+
GpioInputBinarySensorClass = GpioInputBinarySensor if gpio.get("detection_type", "stable") == "stable" else GpioInputBinarySensorBeta
|
|
376
|
+
GpioInputBinarySensor(
|
|
377
|
+
pin=pin,
|
|
378
|
+
press_callback=lambda x, i: press_callback(
|
|
379
|
+
x=x,
|
|
380
|
+
inpin=i,
|
|
381
|
+
actions=gpio.get(ACTIONS, {}).get(x, []),
|
|
382
|
+
input_type=INPUT_SENSOR,
|
|
383
|
+
empty_message_after=gpio.get("clear_message", False)
|
|
384
|
+
),
|
|
385
|
+
**gpio,
|
|
386
|
+
)
|
|
387
|
+
if gpio.get(SHOW_HA, True):
|
|
388
|
+
send_ha_autodiscovery(
|
|
389
|
+
id=pin,
|
|
390
|
+
name=gpio.get(ID, pin),
|
|
391
|
+
ha_type=BINARY_SENSOR,
|
|
392
|
+
device_class=gpio.get(DEVICE_CLASS, None),
|
|
393
|
+
availability_msg_func=ha_binary_sensor_availabilty_message,
|
|
394
|
+
)
|
|
395
|
+
return pin
|
|
396
|
+
except GPIOInputException as err:
|
|
397
|
+
_LOGGER.error("This PIN %s can't be configured. %s", pin, err)
|
|
398
|
+
pass
|
|
365
399
|
|
|
366
400
|
def configure_cover(
|
|
367
401
|
manager: Manager,
|
boneio/input/__init__.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Input classes."""
|
|
2
2
|
|
|
3
|
-
from boneio.input.gpio import
|
|
3
|
+
from boneio.input.gpio import GpioEventButton
|
|
4
|
+
from boneio.input.gpio_beta import GpioEventButtonBeta
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
__all__ = ["GpioEventButton", "GpioEventButtonBeta"]
|
boneio/input/gpio.py
CHANGED
|
@@ -1,39 +1,31 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""GpioEventButton to receive signals."""
|
|
2
2
|
from __future__ import annotations
|
|
3
|
-
import time
|
|
4
3
|
import logging
|
|
4
|
+
import asyncio
|
|
5
5
|
from functools import partial
|
|
6
|
-
from boneio.const import DOUBLE, LONG, SINGLE, ClickTypes
|
|
7
|
-
from boneio.helper import GpioBaseClass, ClickTimer
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
from boneio.const import DOUBLE, LONG, SINGLE, ClickTypes
|
|
7
|
+
from boneio.helper import GpioBaseClass, ClickTimer, TimePeriod
|
|
8
|
+
|
|
9
|
+
|
|
10
10
|
# TIMINGS FOR BUTTONS
|
|
11
11
|
|
|
12
|
+
DOUBLE_CLICK_DURATION_MS = 350
|
|
13
|
+
LONG_PRESS_DURATION_MS = 600
|
|
12
14
|
|
|
13
15
|
_LOGGER = logging.getLogger(__name__)
|
|
14
16
|
|
|
15
|
-
DOUBLE_CLICK_DURATION_MS = 250
|
|
16
|
-
LONG_PRESS_DURATION_MS = 500
|
|
17
17
|
|
|
18
|
-
class
|
|
18
|
+
class GpioEventButton(GpioBaseClass):
|
|
19
19
|
"""Represent Gpio input switch."""
|
|
20
20
|
|
|
21
21
|
def __init__(self, **kwargs) -> None:
|
|
22
22
|
"""Setup GPIO Input Button"""
|
|
23
23
|
super().__init__(**kwargs)
|
|
24
24
|
self._state = self.is_pressed
|
|
25
|
-
|
|
26
|
-
self._debounce_time: float = self._bounce_time.total_in_seconds
|
|
27
|
-
self._period_to_wait_for_2nd_click: float = self._debounce_time
|
|
28
|
-
|
|
29
|
-
self._timer_single = ClickTimer(
|
|
30
|
-
delay=TimePeriod(milliseconds=self._period_to_wait_for_2nd_click),
|
|
31
|
-
action=lambda x: self.press_callback(click_type=SINGLE),
|
|
32
|
-
)
|
|
33
|
-
|
|
25
|
+
_LOGGER.debug("Configured stable listening for input pin %s", self._pin)
|
|
34
26
|
self._timer_double = ClickTimer(
|
|
35
27
|
delay=TimePeriod(milliseconds=DOUBLE_CLICK_DURATION_MS),
|
|
36
|
-
action=lambda x:
|
|
28
|
+
action=lambda x: self.double_click_press_callback(),
|
|
37
29
|
)
|
|
38
30
|
self._timer_long = ClickTimer(
|
|
39
31
|
delay=TimePeriod(milliseconds=LONG_PRESS_DURATION_MS),
|
|
@@ -42,46 +34,40 @@ class GpioInputButton(GpioBaseClass):
|
|
|
42
34
|
self._double_click_ran = False
|
|
43
35
|
self._is_waiting_for_second_click = False
|
|
44
36
|
self._long_press_ran = False
|
|
37
|
+
asyncio.create_task(self._run())
|
|
45
38
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
def press_callback(self, click_type: ClickTypes):
|
|
40
|
+
self._loop.call_soon_threadsafe(
|
|
41
|
+
partial(self._press_callback, click_type, self._pin)
|
|
42
|
+
)
|
|
49
43
|
|
|
44
|
+
def double_click_press_callback(self):
|
|
45
|
+
self._is_waiting_for_second_click = False
|
|
46
|
+
if not self._state and not self._timer_long.is_waiting():
|
|
47
|
+
self.press_callback(click_type=SINGLE)
|
|
50
48
|
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
49
|
+
async def _run(self) -> None:
|
|
50
|
+
while True:
|
|
51
|
+
self.check_state(state=self.is_pressed)
|
|
52
|
+
await asyncio.sleep(self._bounce_time.total_in_seconds)
|
|
53
|
+
|
|
54
|
+
def check_state(self, state: bool) -> None:
|
|
55
|
+
if state == self._state:
|
|
56
|
+
return
|
|
57
|
+
self._state = state
|
|
58
|
+
if state: #is pressed?
|
|
59
|
+
self._timer_long.start_timer()
|
|
60
|
+
if self._timer_double.is_waiting():
|
|
61
|
+
self._timer_double.reset()
|
|
62
|
+
self._double_click_ran = True
|
|
63
|
+
self.press_callback(click_type=DOUBLE)
|
|
64
|
+
else:
|
|
65
|
+
self._timer_double.start_timer()
|
|
66
|
+
self._is_waiting_for_second_click = True
|
|
66
67
|
|
|
67
|
-
else:
|
|
68
|
+
else: #is released?
|
|
68
69
|
if not self._is_waiting_for_second_click and not self._double_click_ran:
|
|
69
70
|
if self._timer_long.is_waiting():
|
|
70
71
|
self.press_callback(click_type=SINGLE)
|
|
71
|
-
elif self._is_waiting_for_second_click:
|
|
72
|
-
self._timer_single.start_timer()
|
|
73
72
|
self._timer_long.reset()
|
|
74
73
|
self._double_click_ran = False
|
|
75
|
-
|
|
76
|
-
def reset_all_timers(self) -> None:
|
|
77
|
-
self._is_waiting_for_second_click = False
|
|
78
|
-
self._timer_single.reset()
|
|
79
|
-
self._timer_double.reset()
|
|
80
|
-
self._timer_long.reset()
|
|
81
|
-
|
|
82
|
-
def press_callback(self, click_type: ClickTypes):
|
|
83
|
-
_LOGGER.debug("Detected press %s", click_type)
|
|
84
|
-
self.reset_all_timers()
|
|
85
|
-
self._loop.call_soon_threadsafe(
|
|
86
|
-
partial(self._press_callback, click_type, self._pin)
|
|
87
|
-
)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""GpioEventButtonBeta to receive signals."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
import time
|
|
4
|
+
import logging
|
|
5
|
+
from functools import partial
|
|
6
|
+
from boneio.const import DOUBLE, LONG, SINGLE, ClickTypes, BOTH
|
|
7
|
+
from boneio.helper import GpioBaseClass, ClickTimer
|
|
8
|
+
from boneio.helper.gpio import add_event_callback, add_event_detect
|
|
9
|
+
from boneio.helper.timeperiod import TimePeriod
|
|
10
|
+
# TIMINGS FOR BUTTONS
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
DOUBLE_CLICK_TIME = 0.35 # Maximum time between two clicks for a double-click
|
|
14
|
+
LONG_CLICK_TIME = 0.6 # Minimum time for a long click
|
|
15
|
+
DEBOUNCE_TIME = 0.05
|
|
16
|
+
_LOGGER = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
DOUBLE_CLICK_DURATION_MS = 300
|
|
20
|
+
LONG_PRESS_DURATION_MS = 600
|
|
21
|
+
|
|
22
|
+
class GpioEventButtonBeta(GpioBaseClass):
|
|
23
|
+
"""Represent Gpio input switch."""
|
|
24
|
+
|
|
25
|
+
def __init__(self, **kwargs) -> None:
|
|
26
|
+
"""Setup GPIO Input Button"""
|
|
27
|
+
super().__init__(**kwargs)
|
|
28
|
+
self._state = self.is_pressed
|
|
29
|
+
self.button_pressed_time = 0.0
|
|
30
|
+
self.click_count = 0
|
|
31
|
+
self.last_click_time = 0.0
|
|
32
|
+
self._double_test = None
|
|
33
|
+
self._long_test = None
|
|
34
|
+
|
|
35
|
+
self._timer_double = ClickTimer(
|
|
36
|
+
delay=TimePeriod(milliseconds=DOUBLE_CLICK_DURATION_MS),
|
|
37
|
+
action=lambda x: self.double_click_press_callback(),
|
|
38
|
+
)
|
|
39
|
+
self._timer_long = ClickTimer(
|
|
40
|
+
delay=TimePeriod(milliseconds=LONG_PRESS_DURATION_MS),
|
|
41
|
+
action=lambda x: self.press_callback(click_type=LONG),
|
|
42
|
+
)
|
|
43
|
+
self._double_click_ran = False
|
|
44
|
+
self._is_waiting_for_second_click = False
|
|
45
|
+
self._long_press_ran = False
|
|
46
|
+
|
|
47
|
+
add_event_detect(pin=self._pin, edge=BOTH)
|
|
48
|
+
add_event_callback(pin=self._pin, callback=self.check_state)
|
|
49
|
+
_LOGGER.debug("Configured BETA listening for input pin %s", self._pin)
|
|
50
|
+
|
|
51
|
+
def double_click_press_callback(self):
|
|
52
|
+
self._is_waiting_for_second_click = False
|
|
53
|
+
if not self._state and not self._timer_long.is_waiting():
|
|
54
|
+
self.press_callback(click_type=SINGLE)
|
|
55
|
+
|
|
56
|
+
def check_state(self, channel) -> None:
|
|
57
|
+
time_now = time.time()
|
|
58
|
+
self._state = self.is_pressed
|
|
59
|
+
if self._state:
|
|
60
|
+
if time_now - self.button_pressed_time >= DEBOUNCE_TIME:
|
|
61
|
+
self.button_pressed_time = time_now
|
|
62
|
+
self.click_count += 1
|
|
63
|
+
self._timer_long.start_timer()
|
|
64
|
+
if self._timer_double.is_waiting():
|
|
65
|
+
self._timer_double.reset()
|
|
66
|
+
self._double_click_ran = True
|
|
67
|
+
self.press_callback(click_type=DOUBLE)
|
|
68
|
+
return
|
|
69
|
+
self._timer_double.start_timer()
|
|
70
|
+
self._is_waiting_for_second_click = True
|
|
71
|
+
|
|
72
|
+
else:
|
|
73
|
+
if not self._is_waiting_for_second_click and not self._double_click_ran:
|
|
74
|
+
if self._timer_long.is_waiting():
|
|
75
|
+
self.press_callback(click_type=SINGLE)
|
|
76
|
+
self._timer_long.reset()
|
|
77
|
+
self._double_click_ran = False
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def press_callback(self, click_type: ClickTypes):
|
|
81
|
+
self.click_count = 0
|
|
82
|
+
self._loop.call_soon_threadsafe(
|
|
83
|
+
partial(self._press_callback, click_type, self._pin)
|
|
84
|
+
)
|
boneio/manager.py
CHANGED
|
@@ -53,7 +53,8 @@ from boneio.helper.events import EventBus
|
|
|
53
53
|
from boneio.helper.exceptions import ModbusUartException
|
|
54
54
|
from boneio.helper.loader import (
|
|
55
55
|
configure_cover,
|
|
56
|
-
|
|
56
|
+
configure_event_sensor,
|
|
57
|
+
configure_binary_sensor,
|
|
57
58
|
configure_relay,
|
|
58
59
|
create_dallas_sensor,
|
|
59
60
|
create_mcp23017,
|
|
@@ -85,7 +86,8 @@ class Manager:
|
|
|
85
86
|
config_helper: ConfigHelper,
|
|
86
87
|
config_file_path: str,
|
|
87
88
|
relay_pins: List = [],
|
|
88
|
-
|
|
89
|
+
event_pins: List = [],
|
|
90
|
+
binary_pins: List = [],
|
|
89
91
|
sensors: dict = {},
|
|
90
92
|
modbus: dict = {},
|
|
91
93
|
pca9685: list = [],
|
|
@@ -109,7 +111,8 @@ class Manager:
|
|
|
109
111
|
|
|
110
112
|
self.send_message = send_message
|
|
111
113
|
self.stop_client = stop_client
|
|
112
|
-
self.
|
|
114
|
+
self._event_pins = event_pins
|
|
115
|
+
self._binary_pins = binary_pins
|
|
113
116
|
self._i2cbusio = I2C(SCL, SDA)
|
|
114
117
|
self._mcp = {}
|
|
115
118
|
self._pca = {}
|
|
@@ -234,13 +237,26 @@ class Manager:
|
|
|
234
237
|
used_pins = set()
|
|
235
238
|
if reload_config:
|
|
236
239
|
load_config_from_file(self._config_file_path)
|
|
237
|
-
for gpio in self.
|
|
240
|
+
for gpio in self._event_pins:
|
|
238
241
|
pin = gpio.pop(PIN)
|
|
239
242
|
if pin in used_pins:
|
|
240
243
|
_LOGGER.warn("This PIN %s is already configured. Omitting it.", pin)
|
|
241
244
|
continue
|
|
242
245
|
used_pins.add(
|
|
243
|
-
|
|
246
|
+
configure_event_sensor(
|
|
247
|
+
gpio=gpio,
|
|
248
|
+
pin=pin,
|
|
249
|
+
press_callback=self.press_callback,
|
|
250
|
+
send_ha_autodiscovery=self.send_ha_autodiscovery,
|
|
251
|
+
)
|
|
252
|
+
)
|
|
253
|
+
for gpio in self._binary_pins:
|
|
254
|
+
pin = gpio.pop(PIN)
|
|
255
|
+
if pin in used_pins:
|
|
256
|
+
_LOGGER.warn("This PIN %s is already configured. Omitting it.", pin)
|
|
257
|
+
continue
|
|
258
|
+
used_pins.add(
|
|
259
|
+
configure_binary_sensor(
|
|
244
260
|
gpio=gpio,
|
|
245
261
|
pin=pin,
|
|
246
262
|
press_callback=self.press_callback,
|
|
@@ -442,7 +458,7 @@ class Manager:
|
|
|
442
458
|
return self._pca
|
|
443
459
|
|
|
444
460
|
def press_callback(
|
|
445
|
-
self, x: ClickTypes, inpin: str, actions: List, input_type: InputTypes = INPUT
|
|
461
|
+
self, x: ClickTypes, inpin: str, actions: List, input_type: InputTypes = INPUT, empty_message_after: bool = False
|
|
446
462
|
) -> None:
|
|
447
463
|
"""Press callback to use in input gpio.
|
|
448
464
|
If relay input map is provided also toggle action on relay or cover or mqtt."""
|
|
@@ -456,7 +472,6 @@ class Manager:
|
|
|
456
472
|
continue
|
|
457
473
|
relay = self._output.get(device.replace(" ", ""))
|
|
458
474
|
action = relay_actions.get(action_definition["action_output"])
|
|
459
|
-
print("reya", relay, action)
|
|
460
475
|
if relay and action:
|
|
461
476
|
getattr(relay, action)()
|
|
462
477
|
else:
|
|
@@ -480,9 +495,10 @@ class Manager:
|
|
|
480
495
|
getattr(cover, action_definition["action_cover"])()
|
|
481
496
|
|
|
482
497
|
# This is similar how Z2M is clearing click sensor.
|
|
483
|
-
|
|
484
|
-
self._loop.
|
|
485
|
-
|
|
498
|
+
if empty_message_after:
|
|
499
|
+
self._loop.call_soon_threadsafe(
|
|
500
|
+
self._loop.call_later, 0.2, self.send_message, topic, ""
|
|
501
|
+
)
|
|
486
502
|
|
|
487
503
|
def send_ha_autodiscovery(
|
|
488
504
|
self,
|
|
@@ -499,7 +515,7 @@ class Manager:
|
|
|
499
515
|
topic_prefix = topic_prefix or self._config_helper.topic_prefix
|
|
500
516
|
payload = availability_msg_func(topic=topic_prefix, id=id, name=name, **kwargs)
|
|
501
517
|
topic = f"{self._config_helper.ha_discovery_prefix}/{ha_type}/{topic_prefix}/{id}/config"
|
|
502
|
-
_LOGGER.debug("Sending HA discovery for %s, %s.", ha_type, name)
|
|
518
|
+
_LOGGER.debug("Sending HA discovery for %s entity, %s.", ha_type, name)
|
|
503
519
|
self._config_helper.add_autodiscovery_msg(topic=topic, ha_type=ha_type, payload=payload)
|
|
504
520
|
self.send_message(topic=topic, payload=payload, retain=True)
|
|
505
521
|
|
boneio/mqtt_client.py
CHANGED
|
@@ -11,8 +11,7 @@ from contextlib import AsyncExitStack
|
|
|
11
11
|
from typing import Any, Callable, Optional, Set, Union, Awaitable
|
|
12
12
|
|
|
13
13
|
import paho.mqtt.client as mqtt
|
|
14
|
-
from
|
|
15
|
-
from asyncio_mqtt import MqttError, Will
|
|
14
|
+
from aiomqtt import Client as AsyncioClient, MqttError, Will
|
|
16
15
|
from paho.mqtt.properties import Properties
|
|
17
16
|
from paho.mqtt.subscribeoptions import SubscribeOptions
|
|
18
17
|
|
boneio/runner.py
CHANGED
|
@@ -7,13 +7,14 @@ from typing import Any
|
|
|
7
7
|
|
|
8
8
|
from boneio.const import (
|
|
9
9
|
ADC,
|
|
10
|
+
BINARY_SENSOR,
|
|
10
11
|
COVER,
|
|
11
12
|
DALLAS,
|
|
12
13
|
DS2482,
|
|
13
14
|
ENABLED,
|
|
14
15
|
HA_DISCOVERY,
|
|
15
16
|
HOST,
|
|
16
|
-
|
|
17
|
+
EVENT_ENTITY,
|
|
17
18
|
LM75,
|
|
18
19
|
MCP23017,
|
|
19
20
|
PCA9685,
|
|
@@ -78,7 +79,8 @@ async def async_run(
|
|
|
78
79
|
send_message=client.send_message,
|
|
79
80
|
stop_client=client.stop_client,
|
|
80
81
|
relay_pins=config.get(OUTPUT, []),
|
|
81
|
-
|
|
82
|
+
event_pins=config.get(EVENT_ENTITY, []),
|
|
83
|
+
binary_pins=config.get(BINARY_SENSOR, []),
|
|
82
84
|
config_file_path=config_file,
|
|
83
85
|
state_manager=StateManager(
|
|
84
86
|
state_file=f"{os.path.split(config_file)[0]}state.json"
|
boneio/schema/schema.yaml
CHANGED
|
@@ -322,7 +322,7 @@ output:
|
|
|
322
322
|
label: If HA discovery is used device if relay is light or switch. If None is declared then any state is not published to MQTT (used for cover).
|
|
323
323
|
|
|
324
324
|
|
|
325
|
-
|
|
325
|
+
binary_sensor:
|
|
326
326
|
type: list
|
|
327
327
|
meta:
|
|
328
328
|
label: GPIO inputs section
|
|
@@ -346,6 +346,18 @@ input:
|
|
|
346
346
|
allowed: ["gpio", "gpio_pu", "gpio_pd", "gpio_input"]
|
|
347
347
|
meta:
|
|
348
348
|
label: What mode to use in config PIN.
|
|
349
|
+
detection_type:
|
|
350
|
+
type: string
|
|
351
|
+
required: True
|
|
352
|
+
default: "stable"
|
|
353
|
+
allowed: ["stable", "beta"]
|
|
354
|
+
meta:
|
|
355
|
+
label: There are 2 detector algorithms. Stable consumes more CPU. Beta is more optimized, but needed extra time for testing.
|
|
356
|
+
clear_message:
|
|
357
|
+
type: boolean
|
|
358
|
+
default: False
|
|
359
|
+
meta:
|
|
360
|
+
label: Decide if after press/release callback send empty message to mqtt. Same as Zigbee2Mqtt is doing in button actions.
|
|
349
361
|
bounce_time:
|
|
350
362
|
type:
|
|
351
363
|
- string
|
|
@@ -354,7 +366,7 @@ input:
|
|
|
354
366
|
- str
|
|
355
367
|
- positive_time_period
|
|
356
368
|
required: True
|
|
357
|
-
default: "
|
|
369
|
+
default: "120ms"
|
|
358
370
|
meta:
|
|
359
371
|
label: Bounce time for GPIO in miliseconds. Only for advanced usage.
|
|
360
372
|
show_in_ha:
|
|
@@ -363,13 +375,74 @@ input:
|
|
|
363
375
|
default: True
|
|
364
376
|
meta:
|
|
365
377
|
label: If you want you can disable discovering this input in HA.
|
|
366
|
-
|
|
378
|
+
device_class:
|
|
367
379
|
type: string
|
|
368
|
-
|
|
369
|
-
|
|
380
|
+
required: False
|
|
381
|
+
allowed: ["battery", "battery_charging", "carbon_monoxide", "cold", "connectivity", "door", "garage_door", "gas", "heat", "light", "lock", "moisture", "motion", "moving", "occupancy", "opening", "plug", "power", "presence", "problem", "running", "safety", "smoke", "sound", "tamper", "vibration", "window"]
|
|
382
|
+
meta:
|
|
383
|
+
label: Device class to use in HA
|
|
384
|
+
actions:
|
|
385
|
+
required: False
|
|
386
|
+
type: dict
|
|
387
|
+
coerce: check_actions
|
|
388
|
+
schema:
|
|
389
|
+
pressed: !include actions_sensor.yaml
|
|
390
|
+
released: !include actions_sensor.yaml
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
event:
|
|
394
|
+
type: list
|
|
395
|
+
meta:
|
|
396
|
+
label: GPIO inputs section
|
|
397
|
+
schema:
|
|
398
|
+
type: dict
|
|
399
|
+
schema:
|
|
400
|
+
id:
|
|
401
|
+
type: string
|
|
402
|
+
required: False
|
|
403
|
+
meta:
|
|
404
|
+
label: Id to use in HA if needed. Default to pin number.
|
|
405
|
+
pin:
|
|
406
|
+
type: string
|
|
407
|
+
required: True
|
|
408
|
+
meta:
|
|
409
|
+
label: PIN to use.
|
|
410
|
+
gpio_mode:
|
|
411
|
+
type: string
|
|
412
|
+
required: True
|
|
413
|
+
default: "gpio"
|
|
414
|
+
allowed: ["gpio", "gpio_pu", "gpio_pd", "gpio_input"]
|
|
415
|
+
meta:
|
|
416
|
+
label: What mode to use in config PIN.
|
|
417
|
+
detection_type:
|
|
418
|
+
type: string
|
|
419
|
+
required: True
|
|
420
|
+
default: "stable"
|
|
421
|
+
allowed: ["stable", "beta"]
|
|
422
|
+
meta:
|
|
423
|
+
label: There are 2 detector algorithms. Stable consumes more CPU. Beta is more optimized, but needed extra time for testing.
|
|
424
|
+
clear_message:
|
|
425
|
+
type: boolean
|
|
426
|
+
default: False
|
|
427
|
+
meta:
|
|
428
|
+
label: Decide if after press/release callback send empty message to mqtt. Same as Zigbee2Mqtt is doing in button actions.
|
|
429
|
+
bounce_time:
|
|
430
|
+
type:
|
|
431
|
+
- string
|
|
432
|
+
- timeperiod
|
|
433
|
+
coerce:
|
|
434
|
+
- str
|
|
435
|
+
- positive_time_period
|
|
370
436
|
required: True
|
|
437
|
+
default: "120ms"
|
|
371
438
|
meta:
|
|
372
|
-
label:
|
|
439
|
+
label: Bounce time for GPIO in miliseconds. Only for advanced usage.
|
|
440
|
+
show_in_ha:
|
|
441
|
+
type: boolean
|
|
442
|
+
required: True
|
|
443
|
+
default: True
|
|
444
|
+
meta:
|
|
445
|
+
label: If you want you can disable discovering this input in HA.
|
|
373
446
|
inverted:
|
|
374
447
|
type: boolean
|
|
375
448
|
default: False
|
|
@@ -379,7 +452,8 @@ input:
|
|
|
379
452
|
device_class:
|
|
380
453
|
type: string
|
|
381
454
|
required: False
|
|
382
|
-
|
|
455
|
+
default: "button"
|
|
456
|
+
allowed: ["button", "doorbell", "motion"]
|
|
383
457
|
meta:
|
|
384
458
|
label: Device class to use in HA
|
|
385
459
|
actions:
|
|
@@ -390,8 +464,6 @@ input:
|
|
|
390
464
|
single: !include actions_switch.yaml
|
|
391
465
|
double: !include actions_switch.yaml
|
|
392
466
|
long: !include actions_switch.yaml
|
|
393
|
-
pressed: !include actions_sensor.yaml
|
|
394
|
-
released: !include actions_sensor.yaml
|
|
395
467
|
adc:
|
|
396
468
|
type: list
|
|
397
469
|
meta:
|
|
@@ -417,6 +489,7 @@ adc:
|
|
|
417
489
|
default: True
|
|
418
490
|
meta:
|
|
419
491
|
label: If you want you can disable discovering this input in HA.
|
|
492
|
+
filters: !include filters_adc.yaml
|
|
420
493
|
cover:
|
|
421
494
|
type: list
|
|
422
495
|
required: False
|
boneio/sensor/__init__.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Sensor module."""
|
|
2
2
|
from boneio.sensor.adc import GpioADCSensor, initialize_adc
|
|
3
|
-
from boneio.sensor.gpio import
|
|
3
|
+
from boneio.sensor.gpio import GpioInputBinarySensor
|
|
4
|
+
from boneio.sensor.gpio_beta import GpioInputBinarySensorBeta
|
|
4
5
|
from boneio.sensor.temp.dallas import DallasSensorDS2482
|
|
5
6
|
from boneio.sensor.temp.lm75 import LM75Sensor
|
|
6
7
|
from boneio.sensor.temp.mcp9808 import MCP9808Sensor
|
|
@@ -9,7 +10,8 @@ __all__ = [
|
|
|
9
10
|
"DallasSensorDS2482",
|
|
10
11
|
"LM75Sensor",
|
|
11
12
|
"MCP9808Sensor",
|
|
12
|
-
"
|
|
13
|
+
"GpioInputBinarySensor",
|
|
14
|
+
"GpioInputBinarySensorBeta",
|
|
13
15
|
"initialize_adc",
|
|
14
16
|
"GpioADCSensor",
|
|
15
17
|
]
|
boneio/sensor/adc.py
CHANGED
|
@@ -26,11 +26,12 @@ def initialize_adc():
|
|
|
26
26
|
class GpioADCSensor(BasicMqtt, AsyncUpdater, Filter):
|
|
27
27
|
"""Represent Gpio ADC sensor."""
|
|
28
28
|
|
|
29
|
-
def __init__(self, pin: str, **kwargs) -> None:
|
|
29
|
+
def __init__(self, pin: str, filters: list, **kwargs) -> None:
|
|
30
30
|
"""Setup GPIO ADC Sensor"""
|
|
31
31
|
super().__init__(topic_type=SENSOR, **kwargs)
|
|
32
32
|
self._pin = pin
|
|
33
33
|
self._state = None
|
|
34
|
+
self._filters = filters
|
|
34
35
|
AsyncUpdater.__init__(self, **kwargs)
|
|
35
36
|
_LOGGER.debug("Configured sensor pin %s", self._pin)
|
|
36
37
|
|
boneio/sensor/gpio.py
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""GpioInputBinarySensor to receive signals."""
|
|
2
2
|
import logging
|
|
3
3
|
from functools import partial
|
|
4
4
|
import asyncio
|
|
5
|
-
from boneio.const import
|
|
6
|
-
from boneio.helper import GpioBaseClass
|
|
5
|
+
from boneio.const import PRESSED, RELEASED
|
|
6
|
+
from boneio.helper import GpioBaseClass
|
|
7
7
|
|
|
8
8
|
_LOGGER = logging.getLogger(__name__)
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class
|
|
11
|
+
class GpioInputBinarySensor(GpioBaseClass):
|
|
12
12
|
"""Represent Gpio sensor on input boards."""
|
|
13
13
|
|
|
14
14
|
def __init__(self, **kwargs) -> None:
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""GpioInputBinarySensor to receive signals."""
|
|
2
|
+
import logging
|
|
3
|
+
from functools import partial
|
|
4
|
+
from boneio.const import PRESSED, RELEASED
|
|
5
|
+
from boneio.helper import GpioBaseClass
|
|
6
|
+
from boneio.helper.gpio import add_event_callback, add_event_detect
|
|
7
|
+
_LOGGER = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class GpioInputBinarySensorBeta(GpioBaseClass):
|
|
11
|
+
"""Represent Gpio sensor on input boards."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, **kwargs) -> None:
|
|
14
|
+
"""Setup GPIO Input Button"""
|
|
15
|
+
super().__init__(**kwargs)
|
|
16
|
+
self._state = self.is_pressed
|
|
17
|
+
self._click_type = (
|
|
18
|
+
(RELEASED, PRESSED)
|
|
19
|
+
if kwargs.get("inverted", False)
|
|
20
|
+
else (PRESSED, RELEASED)
|
|
21
|
+
)
|
|
22
|
+
_LOGGER.debug("Configured sensor pin %s", self._pin)
|
|
23
|
+
add_event_detect(pin=self._pin, edge=BOTH)
|
|
24
|
+
add_event_callback(pin=self._pin, callback=self.check_state)
|
|
25
|
+
|
|
26
|
+
def check_state(self, channel) -> None:
|
|
27
|
+
state = self.is_pressed
|
|
28
|
+
if state == self._state:
|
|
29
|
+
return
|
|
30
|
+
self._state = state
|
|
31
|
+
click_type = self._click_type[0] if state else self._click_type[1]
|
|
32
|
+
_LOGGER.debug("%s event on pin %s", click_type, self._pin)
|
|
33
|
+
self._loop.call_soon_threadsafe(
|
|
34
|
+
partial(self._press_callback, click_type, self._pin)
|
|
35
|
+
)
|
boneio/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# flake8: noqa
|
|
2
|
-
__version__ = "0.
|
|
2
|
+
__version__ = "0.7.0dev1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
- id: adc1
|
|
2
|
-
pin:
|
|
2
|
+
pin: P9_33
|
|
3
3
|
- id: adc2
|
|
4
|
-
pin:
|
|
4
|
+
pin: P9_36
|
|
5
5
|
- id: adc3
|
|
6
|
-
pin:
|
|
6
|
+
pin: P9_35
|
|
7
7
|
- id: adc4
|
|
8
8
|
pin: P9_38
|
|
9
9
|
- id: adc5
|
|
10
|
-
pin:
|
|
10
|
+
pin: P9_37
|
|
11
11
|
- id: adc6
|
|
12
|
-
pin:
|
|
12
|
+
pin: P9_40
|
|
13
13
|
- id: adc7
|
|
14
|
-
pin:
|
|
14
|
+
pin: P9_39
|