boneIO 0.3.0__tar.gz → 0.3.0.dev1__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.
- {boneio-0.3.0/boneio.egg-info → boneio-0.3.0.dev1}/PKG-INFO +2 -2
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/bonecli.py +1 -1
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/const.py +6 -7
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/cover.py +6 -7
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/example_config/config.yaml +2 -2
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/example_config/cover.yaml +2 -2
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/example_config/output32x5A.yaml +72 -110
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/__init__.py +15 -2
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/events.py +4 -14
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/exceptions.py +0 -12
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/gpio.py +2 -1
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/loader.py +30 -61
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/yaml_util.py +0 -1
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/input/gpio.py +7 -8
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/manager.py +43 -109
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/modbus.py +3 -8
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/mqtt_client.py +7 -22
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/relay/mcp.py +3 -3
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/runner.py +5 -15
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/schema/schema.yaml +13 -119
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/sensor/__init__.py +1 -4
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/sensor/adc.py +2 -5
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/sensor/modbus/__init__.py +35 -44
- boneio-0.3.0.dev1/boneio/sensor/temp/__init__.py +52 -0
- boneio-0.3.0.dev1/boneio/version.py +2 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1/boneio.egg-info}/PKG-INFO +2 -2
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio.egg-info/SOURCES.txt +1 -9
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio.egg-info/requires.txt +0 -1
- {boneio-0.3.0 → boneio-0.3.0.dev1}/requirements.txt +0 -1
- {boneio-0.3.0 → boneio-0.3.0.dev1}/setup.py +0 -1
- boneio-0.3.0/boneio/helper/config.py +0 -47
- boneio-0.3.0/boneio/helper/ds2482/__init__.py +0 -10
- boneio-0.3.0/boneio/helper/ds2482/ds2482.py +0 -163
- boneio-0.3.0/boneio/helper/ds2482/onewire.py +0 -44
- boneio-0.3.0/boneio/helper/util.py +0 -15
- boneio-0.3.0/boneio/sensor/temp/__init__.py +0 -76
- boneio-0.3.0/boneio/sensor/temp/dallas.py +0 -43
- boneio-0.3.0/boneio/sensor/temp/lm75.py +0 -11
- boneio-0.3.0/boneio/sensor/temp/mcp9808.py +0 -12
- boneio-0.3.0/boneio/version.py +0 -2
- {boneio-0.3.0 → boneio-0.3.0.dev1}/LICENSE +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/MANIFEST.in +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/README.md +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/__init__.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/example_config/__init__.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/example_config/adc.yaml +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/example_config/input.yaml +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/example_config/output24x16A.yaml +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/fonts/danube__.ttf +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/ha_discovery.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/logger.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/mqtt.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/oled.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/queue.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/state_manager.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/stats.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/helper/timeperiod.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/input/__init__.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/oled.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/relay/__init__.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/relay/basic.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/relay/gpio.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/schema/actions.yaml +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/schema/actions_sensor.yaml +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/schema/actions_switch.yaml +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/sensor/gpio.py +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/sensor/modbus/sdm120.json +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/sensor/modbus/sdm630.json +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio/sensor/modbus/sofar.json +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio.egg-info/dependency_links.txt +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio.egg-info/entry_points.txt +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/boneio.egg-info/top_level.txt +0 -0
- {boneio-0.3.0 → boneio-0.3.0.dev1}/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.dev1
|
|
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.dev1.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
|
|
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
|
|
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,11 +1,10 @@
|
|
|
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
|
|
8
|
-
from boneio.helper.timeperiod import TimePeriod
|
|
9
8
|
from boneio.relay import MCPRelay
|
|
10
9
|
|
|
11
10
|
_LOGGER = logging.getLogger(__name__)
|
|
@@ -22,10 +21,10 @@ COVER_COMMANDS = {
|
|
|
22
21
|
class RelayHelper:
|
|
23
22
|
"""Relay helper for cover either open/close."""
|
|
24
23
|
|
|
25
|
-
def __init__(self, relay: MCPRelay, time:
|
|
24
|
+
def __init__(self, relay: MCPRelay, time: int) -> None:
|
|
26
25
|
"""Initialize helper."""
|
|
27
26
|
self._relay = relay
|
|
28
|
-
self._steps = 100 / time
|
|
27
|
+
self._steps = 100 / time
|
|
29
28
|
|
|
30
29
|
@property
|
|
31
30
|
def relay(self) -> MCPRelay:
|
|
@@ -44,11 +43,11 @@ class Cover(BasicMqtt):
|
|
|
44
43
|
def __init__(
|
|
45
44
|
self,
|
|
46
45
|
id: str,
|
|
47
|
-
open_relay:
|
|
46
|
+
open_relay: Any,
|
|
48
47
|
close_relay: MCPRelay,
|
|
49
48
|
state_save: Callable,
|
|
50
|
-
open_time:
|
|
51
|
-
close_time:
|
|
49
|
+
open_time: int,
|
|
50
|
+
close_time: int,
|
|
52
51
|
event_bus: EventBus,
|
|
53
52
|
restored_state: int = 100,
|
|
54
53
|
**kwargs,
|
|
@@ -1,198 +1,160 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
152
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
6
|
+
from typing import Callable
|
|
7
7
|
from datetime import datetime
|
|
8
|
-
from boneio.helper
|
|
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:
|
|
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,8 @@ 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=
|
|
100
|
+
self._bounce_time = gpio.get("bounce_time", TimePeriod(milliseconds=25))
|
|
101
|
+
configure_pin(pin=pin, mode=gpio_mode)
|
|
101
102
|
self._loop = asyncio.get_running_loop()
|
|
102
103
|
self._press_callback = press_callback
|
|
103
104
|
setup_input(pin=self._pin, pull_mode=gpio_mode)
|