boneIO 0.7.2.dev4__tar.gz → 0.8.0__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 (108) hide show
  1. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/PKG-INFO +1 -1
  2. boneIO-0.8.0/boneio/bonecli.py +339 -0
  3. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/const.py +2 -2
  4. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/cover.py +25 -6
  5. boneIO-0.8.0/boneio/example_config/binary_sensor_v_0_7.yaml +11 -0
  6. boneIO-0.8.0/boneio/example_config/event_v_0_7.yaml +292 -0
  7. boneIO-0.8.0/boneio/example_config/output32x10A.yaml +192 -0
  8. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/group/output.py +40 -11
  9. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/events.py +13 -9
  10. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/filter.py +8 -4
  11. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/gpio.py +28 -8
  12. boneIO-0.8.0/boneio/helper/gpiod.py +56 -0
  13. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/loader.py +28 -11
  14. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/mqtt.py +8 -2
  15. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/state_manager.py +8 -4
  16. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/stats.py +112 -24
  17. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/util.py +16 -2
  18. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/yaml_util.py +33 -10
  19. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/input/gpio.py +13 -3
  20. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/manager.py +17 -5
  21. boneIO-0.8.0/boneio/modbus/__init__.py +5 -0
  22. boneIO-0.7.2.dev4/boneio/modbus.py → boneIO-0.8.0/boneio/modbus/client.py +105 -40
  23. boneIO-0.8.0/boneio/modbus/cwt.json +37 -0
  24. boneIO-0.8.0/boneio/modbus/liquid-sensor.json +37 -0
  25. boneIO-0.8.0/boneio/modbus/modbuscli.py +272 -0
  26. boneIO-0.8.0/boneio/modbus/orno-or-we-517.json +590 -0
  27. boneIO-0.8.0/boneio/modbus/r4dcb08.json +97 -0
  28. boneIO-0.8.0/boneio/modbus/sensor.py +235 -0
  29. boneIO-0.8.0/boneio/modbus/sht20.json +37 -0
  30. boneIO-0.8.0/boneio/modbus/single_sensor.py +153 -0
  31. boneIO-0.7.2.dev4/boneio/sensor/modbus/socomec_e23.json → boneIO-0.8.0/boneio/modbus/socomec_e03.json +8 -7
  32. boneIO-0.8.0/boneio/modbus/socomec_e23.json +164 -0
  33. boneIO-0.8.0/boneio/modbus/utils.py +73 -0
  34. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/mqtt_client.py +51 -22
  35. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/oled.py +31 -11
  36. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/relay/basic.py +11 -10
  37. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/relay/mcp.py +6 -4
  38. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/relay/pcf.py +3 -8
  39. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/schema/schema.yaml +50 -1
  40. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/sensor/gpio_new.py +17 -4
  41. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/sensor/ina219.py +27 -24
  42. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/sensor/temp/__init__.py +3 -2
  43. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/sensor/temp/dallas.py +6 -1
  44. boneIO-0.8.0/boneio/version.py +2 -0
  45. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/pyproject.toml +11 -1
  46. boneIO-0.7.2.dev4/boneio/bonecli.py +0 -121
  47. boneIO-0.7.2.dev4/boneio/sensor/modbus/__init__.py +0 -287
  48. boneIO-0.7.2.dev4/boneio/sensor/modbus/r4dcb08.json +0 -76
  49. boneIO-0.7.2.dev4/boneio/version.py +0 -2
  50. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/LICENSE +0 -0
  51. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/README.md +0 -0
  52. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/__init__.py +0 -0
  53. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/__init__.py +0 -0
  54. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/adc.yaml +0 -0
  55. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/binary_sensor.yaml +0 -0
  56. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/config.yaml +0 -0
  57. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/cover.yaml +0 -0
  58. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/event.yaml +0 -0
  59. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/event_all.yaml +0 -0
  60. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/led32x4A.yaml +0 -0
  61. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/output24x16A.yaml +0 -0
  62. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/output24x16A_v0.3.yaml +0 -0
  63. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/example_config/output32x5A.yaml +0 -0
  64. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/fonts/danube__.ttf +0 -0
  65. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/group/__init__.py +0 -0
  66. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/__init__.py +0 -0
  67. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/async_updater.py +0 -0
  68. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/click_timer.py +0 -0
  69. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/config.py +0 -0
  70. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/exceptions.py +0 -0
  71. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/ha_discovery.py +0 -0
  72. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/logger.py +0 -0
  73. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/oled.py +0 -0
  74. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/onewire/W1ThermSensor.py +0 -0
  75. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/onewire/__init__.py +0 -0
  76. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/onewire/ds2482.py +0 -0
  77. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/onewire/onewire.py +0 -0
  78. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/pcf8575.py +0 -0
  79. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/queue.py +0 -0
  80. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/sensor/ina_219_smbus.py +0 -0
  81. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/helper/timeperiod.py +0 -0
  82. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/input/__init__.py +0 -0
  83. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/input/gpio_new.py +0 -0
  84. {boneIO-0.7.2.dev4/boneio/sensor → boneIO-0.8.0/boneio}/modbus/dts1964_3f.json +0 -0
  85. {boneIO-0.7.2.dev4/boneio/sensor → boneIO-0.8.0/boneio}/modbus/pt100.json +0 -0
  86. {boneIO-0.7.2.dev4/boneio/sensor → boneIO-0.8.0/boneio}/modbus/sdm120.json +0 -0
  87. {boneIO-0.7.2.dev4/boneio/sensor → boneIO-0.8.0/boneio}/modbus/sdm630.json +0 -0
  88. {boneIO-0.7.2.dev4/boneio/sensor → boneIO-0.8.0/boneio}/modbus/sofar.json +0 -0
  89. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/relay/__init__.py +0 -0
  90. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/relay/gpio.py +0 -0
  91. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/relay/pca.py +0 -0
  92. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/runner.py +1 -1
  93. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/schema/actions.yaml +0 -0
  94. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/schema/actions_sensor.yaml +0 -0
  95. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/schema/actions_switch.yaml +0 -0
  96. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/schema/filters.yaml +0 -0
  97. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/schema/filters_adc.yaml +0 -0
  98. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/schema/id.yaml +0 -0
  99. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/schema/temp_unit.yaml +0 -0
  100. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/schema/update_interval.yaml +0 -0
  101. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/sensor/__init__.py +0 -0
  102. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/sensor/adc.py +0 -0
  103. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/sensor/gpio.py +0 -0
  104. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/sensor/temp/lm75.py +0 -0
  105. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/boneio/sensor/temp/mcp9808.py +0 -0
  106. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/tests/32_5_config.yaml +0 -0
  107. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/tests/bandit.yaml +0 -0
  108. {boneIO-0.7.2.dev4 → boneIO-0.8.0}/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.2.dev4
3
+ Version: 0.8.0
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>
@@ -0,0 +1,339 @@
1
+ """Bonecli script."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+
7
+ os.environ["W1THERMSENSOR_NO_KERNEL_MODULE"] = "1"
8
+
9
+ import argparse
10
+ import asyncio
11
+ import logging
12
+ import sys
13
+ from colorlog import ColoredFormatter
14
+ from yaml import MarkedYAMLError
15
+
16
+ from boneio.modbus.modbuscli import (
17
+ async_run_modbus_set,
18
+ async_run_modbus_get,
19
+ async_run_modbus_search,
20
+ )
21
+ from boneio.modbus.client import VALUE_TYPES
22
+
23
+
24
+ from boneio.const import ACTION
25
+ from boneio.helper import load_config_from_file
26
+ from boneio.helper.exceptions import (
27
+ ConfigurationException,
28
+ RestartRequestException,
29
+ )
30
+ from boneio.helper.events import GracefulExit
31
+ from boneio.helper.logger import configure_logger
32
+ from boneio.runner import async_run
33
+ from boneio.version import __version__
34
+
35
+ TASK_CANCELATION_TIMEOUT = 1
36
+
37
+ _LOGGER = logging.getLogger(__name__)
38
+ logging.basicConfig(level=logging.INFO)
39
+ fmt = "%(asctime)s %(levelname)s (%(threadName)s) [%(name)s] %(message)s"
40
+ datefmt = "%Y-%m-%d %H:%M:%S"
41
+ colorfmt = f"%(log_color)s{fmt}%(reset)s"
42
+ logging.getLogger().handlers[0].setFormatter(
43
+ ColoredFormatter(
44
+ colorfmt,
45
+ datefmt=datefmt,
46
+ reset=True,
47
+ log_colors={
48
+ "DEBUG": "cyan",
49
+ "INFO": "green",
50
+ "WARNING": "yellow",
51
+ "ERROR": "red",
52
+ "CRITICAL": "red",
53
+ },
54
+ )
55
+ )
56
+
57
+
58
+ def get_arguments() -> argparse.Namespace:
59
+ """Get parsed passed in arguments."""
60
+
61
+ parser = argparse.ArgumentParser(
62
+ description="boneIO app for BeagleBone Black.",
63
+ )
64
+ subparsers = parser.add_subparsers(dest=ACTION, required=True)
65
+ run_parser = subparsers.add_parser("run")
66
+ run_parser.add_argument(
67
+ "--debug",
68
+ "-d",
69
+ action="count",
70
+ help="Start boneIO in debug mode",
71
+ default=0,
72
+ )
73
+ run_parser.add_argument(
74
+ "-c",
75
+ "--config",
76
+ metavar="path_to_config_dir",
77
+ default="./config.yaml",
78
+ help="File which contains boneIO configuration",
79
+ )
80
+ run_parser.add_argument(
81
+ "--mqttusername",
82
+ help="Mqtt username to use if you don't want provide in file.",
83
+ )
84
+ run_parser.add_argument(
85
+ "--mqttpassword",
86
+ help="Mqtt password to use if you don't want provide in file.",
87
+ )
88
+ modbus_parser = subparsers.add_parser("modbus")
89
+ modbus_parser.add_argument(
90
+ "--debug",
91
+ "-d",
92
+ action="count",
93
+ help="Start boneIO in debug mode",
94
+ default=0,
95
+ )
96
+ modbus_parser.add_argument(
97
+ "--uart",
98
+ type=str,
99
+ choices=["uart1", "uart4"],
100
+ help="Choose UART",
101
+ required=True,
102
+ )
103
+ modbus_parser.add_argument(
104
+ "--address",
105
+ type=lambda x: int(x, 0),
106
+ required=False,
107
+ default=1,
108
+ help="Current device address (hex or integer)",
109
+ )
110
+ modbus_parser.add_argument(
111
+ "--baudrate",
112
+ type=int,
113
+ choices=[2400, 4800, 9600, 14400, 19200],
114
+ required=True,
115
+ help="Current baudrate",
116
+ )
117
+
118
+ modbus_parser.add_argument(
119
+ "--bytesize",
120
+ type=int,
121
+ required=False,
122
+ default=8,
123
+ help="Bytesize",
124
+ )
125
+
126
+ modbus_parser.add_argument(
127
+ "--stopbits",
128
+ type=int,
129
+ required=False,
130
+ default=1,
131
+ help="stopbits",
132
+ )
133
+
134
+ modbus_parser.add_argument(
135
+ "--parity",
136
+ type=str,
137
+ choices=["P", "E", "N"],
138
+ default="N",
139
+ required=False,
140
+ help="Parity",
141
+ )
142
+
143
+ modbus_sub_parser = modbus_parser.add_subparsers(
144
+ dest="modbus_action", required=True
145
+ )
146
+ set_modbus_parser = modbus_sub_parser.add_parser("set")
147
+ set_modbus_parser.add_argument(
148
+ "--custom-value",
149
+ type=int,
150
+ help="Set Custom value",
151
+ )
152
+ set_modbus_parser.add_argument(
153
+ "--custom-register-address",
154
+ type=int,
155
+ help="Register address for custom value",
156
+ )
157
+ set_modbus_parser.add_argument(
158
+ "--device",
159
+ type=str,
160
+ choices=["cwt", "r4dcb08", "liquid-sensor", "sht20", "custom"],
161
+ help="Choose device to set modbus address/baudrate. For custom you must provide --custom-value and --custom-register-address",
162
+ required=True,
163
+ )
164
+ set_modbus_parser_group = set_modbus_parser.add_mutually_exclusive_group()
165
+ set_modbus_parser_group.add_argument(
166
+ "--new-address",
167
+ type=lambda x: int(x, 0),
168
+ help="Set new address (hex or integer / 1 - 253/)",
169
+ )
170
+
171
+ set_modbus_parser_group.add_argument(
172
+ "--new-baudrate",
173
+ type=int,
174
+ choices=[1200, 2400, 4800, 9600, 19200],
175
+ help="Choose new baudrate to set. CWT doesn't work on 1200.",
176
+ )
177
+
178
+ get_modbus_parser = modbus_sub_parser.add_parser("get")
179
+ get_modbus_parser.add_argument(
180
+ "--register-address",
181
+ type=int,
182
+ help="Register address",
183
+ required=True,
184
+ )
185
+ get_modbus_parser.add_argument(
186
+ "--register-type",
187
+ type=str,
188
+ choices=["input", "holding"],
189
+ help="Register type",
190
+ required=True,
191
+ )
192
+ get_modbus_parser.add_argument(
193
+ "--value-type",
194
+ type=str,
195
+ choices=VALUE_TYPES.keys(),
196
+ help="Value types",
197
+ required=True,
198
+ )
199
+ parser.add_argument("--version", action="version", version=__version__)
200
+ search_modbus_parser = modbus_sub_parser.add_parser(
201
+ name="search",
202
+ help="Search for device. Iterate over every address 1-253 with provided register address",
203
+ )
204
+ search_modbus_parser.add_argument(
205
+ "--register-address",
206
+ type=int,
207
+ help="Register address",
208
+ required=True,
209
+ )
210
+ search_modbus_parser.add_argument(
211
+ "--register-type",
212
+ type=str,
213
+ choices=["input", "holding"],
214
+ help="Register type",
215
+ required=True,
216
+ )
217
+ arguments = parser.parse_args()
218
+
219
+ return arguments
220
+
221
+
222
+ def run(
223
+ config: str, debug: int, mqttusername: str = "", mqttpassword: str = ""
224
+ ) -> int:
225
+ """Run BoneIO."""
226
+ _LOGGER.info("BoneIO %s starting.", __version__)
227
+ try:
228
+ _config = load_config_from_file(config_file=config)
229
+ if not _config:
230
+ _LOGGER.error("Config not loaded. Exiting.")
231
+ return 1
232
+ configure_logger(log_config=_config.get("logger"), debug=debug)
233
+ asyncio.run(
234
+ async_run(
235
+ config=_config,
236
+ config_file=config,
237
+ mqttusername=mqttusername,
238
+ mqttpassword=mqttpassword,
239
+ ),
240
+ )
241
+ return 0
242
+ except (RestartRequestException, GracefulExit) as err:
243
+ if err is not None:
244
+ _LOGGER.info(err)
245
+ return 0
246
+ except (ConfigurationException, MarkedYAMLError) as err:
247
+ _LOGGER.error("Failed to load config. %s Exiting.", err)
248
+ return 1
249
+
250
+
251
+ def run_modbus_command(
252
+ args: argparse.Namespace,
253
+ ) -> int:
254
+ """Run BoneIO."""
255
+ _LOGGER.info("BoneIO %s starting.", __version__)
256
+ try:
257
+ configure_logger(log_config={}, debug=args.debug)
258
+ ret = 0
259
+ if args.modbus_action == "set":
260
+ ret = asyncio.run(
261
+ async_run_modbus_set(
262
+ device=args.device,
263
+ uart=args.uart,
264
+ address=args.address,
265
+ baudrate=args.baudrate,
266
+ parity=args.parity,
267
+ bytesize=args.bytesize,
268
+ stopbits=args.stopbits,
269
+ new_baudrate=args.new_baudrate,
270
+ new_address=args.new_address,
271
+ custom_address=args.custom_register_address,
272
+ custom_value=args.custom_value,
273
+ ),
274
+ )
275
+ elif args.modbus_action == "get":
276
+ ret = asyncio.run(
277
+ async_run_modbus_get(
278
+ uart=args.uart,
279
+ device_address=args.address,
280
+ baudrate=args.baudrate,
281
+ register_address=args.register_address,
282
+ register_type=args.register_type,
283
+ parity=args.parity,
284
+ bytesize=args.bytesize,
285
+ stopbits=args.stopbits,
286
+ value_type=args.value_type,
287
+ ),
288
+ )
289
+ else:
290
+ ret = asyncio.run(
291
+ async_run_modbus_search(
292
+ uart=args.uart,
293
+ baudrate=args.baudrate,
294
+ register_address=args.register_address,
295
+ register_type=args.register_type,
296
+ parity=args.parity,
297
+ bytesize=args.bytesize,
298
+ stopbits=args.stopbits,
299
+ ),
300
+ )
301
+ return ret
302
+ except (RestartRequestException, GracefulExit) as err:
303
+ if err is not None:
304
+ _LOGGER.info(err)
305
+ return 0
306
+ except (ConfigurationException, MarkedYAMLError) as err:
307
+ _LOGGER.error("Failed to load config. %s Exiting.", err)
308
+ return 1
309
+
310
+
311
+ def main() -> int:
312
+ """Start boneIO."""
313
+
314
+ args = get_arguments()
315
+ debug = args.debug
316
+
317
+ exit_code = 0
318
+ if args.action == "run":
319
+ exit_code = run(
320
+ config=args.config,
321
+ mqttusername=args.mqttusername,
322
+ mqttpassword=args.mqttpassword,
323
+ debug=debug,
324
+ )
325
+ elif args.action == "modbus":
326
+ _LOGGER.info("BoneIO Modbus helper %s .", __version__)
327
+ exit_code = run_modbus_command(
328
+ args=args,
329
+ )
330
+
331
+ if exit_code == 0:
332
+ _LOGGER.info("Exiting with exit code %s", exit_code)
333
+ else:
334
+ _LOGGER.error("Exiting with exit code %s", exit_code)
335
+ return exit_code
336
+
337
+
338
+ if __name__ == "__main__":
339
+ sys.exit(main())
@@ -71,8 +71,7 @@ SHOW_HA = "show_in_ha"
71
71
  # OLED CONST
72
72
  OLED = "oled"
73
73
  FONTS = "fonts"
74
- OLED_PIN = ("",)
75
- "P9_41"
74
+ OLED_PIN = "P9_41"
76
75
  GIGABYTE = 1073741824
77
76
  MEGABYTE = 1048576
78
77
  WIDTH = 128
@@ -214,3 +213,4 @@ PINS = {
214
213
  "P9_27": {"chip": 3, "line": 19},
215
214
  "P9_25": {"chip": 3, "line": 21},
216
215
  }
216
+ NAME = "name"
@@ -1,10 +1,20 @@
1
1
  """Cover module."""
2
+
2
3
  from __future__ import annotations
3
4
  import asyncio
4
5
  import logging
5
6
  from typing import Callable
6
7
 
7
- from boneio.const import CLOSE, CLOSED, CLOSING, COVER, IDLE, OPEN, OPENING, STOP
8
+ from boneio.const import (
9
+ CLOSE,
10
+ CLOSED,
11
+ CLOSING,
12
+ COVER,
13
+ IDLE,
14
+ OPEN,
15
+ OPENING,
16
+ STOP,
17
+ )
8
18
  from boneio.helper.events import EventBus
9
19
  from boneio.helper.mqtt import BasicMqtt
10
20
  from boneio.helper.timeperiod import TimePeriod
@@ -121,7 +131,9 @@ class Cover(BasicMqtt):
121
131
 
122
132
  def send_state(self) -> None:
123
133
  """Send state of cover to mqtt."""
124
- self._send_message(topic=f"{self._send_topic}/state", payload=self.cover_state)
134
+ self._send_message(
135
+ topic=f"{self._send_topic}/state", payload=self.cover_state
136
+ )
125
137
  pos = round(self._position, 0)
126
138
  self._send_message(topic=f"{self._send_topic}/pos", payload=str(pos))
127
139
  self._state_save(position=pos)
@@ -161,7 +173,9 @@ class Cover(BasicMqtt):
161
173
  if self._set_position:
162
174
  # Set position is only working for every 10%, so round to nearest 10.
163
175
  # Except for start moving time
164
- if (self._requested_closing and rounded_pos < 95) or rounded_pos > 5:
176
+ if (
177
+ self._requested_closing and rounded_pos < 95
178
+ ) or rounded_pos > 5:
165
179
  rounded_pos = round(self._position, -1)
166
180
  else:
167
181
  if rounded_pos > 100:
@@ -170,7 +184,8 @@ class Cover(BasicMqtt):
170
184
  rounded_pos = 0
171
185
  self._send_message(topic=f"{self._send_topic}/pos", payload=rounded_pos)
172
186
  if rounded_pos == self._set_position or (
173
- self._set_position is None and (rounded_pos >= 100 or rounded_pos <= 0)
187
+ self._set_position is None
188
+ and (rounded_pos >= 100 or rounded_pos <= 0)
174
189
  ):
175
190
  self._position = rounded_pos
176
191
  self._closed = self.current_cover_position <= 0
@@ -222,9 +237,13 @@ class Cover(BasicMqtt):
222
237
  self._requested_closing = set_position < self._position
223
238
  current_operation = CLOSING if self._requested_closing else OPENING
224
239
  _LOGGER.debug(
225
- "Requested set position %s. Operation %s", set_position, current_operation
240
+ "Requested set position %s. Operation %s",
241
+ set_position,
242
+ current_operation,
243
+ )
244
+ self._send_message(
245
+ topic=f"{self._send_topic}/state", payload=current_operation
226
246
  )
227
- self._send_message(topic=f"{self._send_topic}/state", payload=current_operation)
228
247
  await self.run_cover(
229
248
  current_operation=current_operation,
230
249
  )
@@ -0,0 +1,11 @@
1
+ #- id: IN_02
2
+ # pin: P8_38
3
+ # gpio_mode: gpio_pu
4
+ # detection_type: new
5
+ - id: IN_26
6
+ detection_type: new
7
+ pin: P8_7
8
+ actions:
9
+ pressed:
10
+ - action: output
11
+ pin: OUT_26