boneIO 0.8.3__tar.gz → 0.9.0.dev4__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 (120) hide show
  1. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/PKG-INFO +1 -1
  2. boneIO-0.9.0.dev4/boneio/boards/0.7/output_32_10.yaml +17 -0
  3. boneIO-0.9.0.dev4/boneio/boards/0.8/input.yaml +110 -0
  4. boneIO-0.9.0.dev4/boneio/boards/0.8/output_32_10.yaml +137 -0
  5. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/bonecli.py +36 -41
  6. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/const.py +2 -1
  7. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/cover.py +3 -2
  8. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/group/output.py +13 -18
  9. boneIO-0.9.0.dev4/boneio/helper/async_updater.py +39 -0
  10. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/click_timer.py +2 -4
  11. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/config.py +21 -3
  12. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/events.py +143 -35
  13. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/gpio.py +60 -16
  14. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/loader.py +49 -35
  15. boneIO-0.9.0.dev4/boneio/helper/logger.py +158 -0
  16. boneIO-0.9.0.dev4/boneio/helper/message_bus.py +83 -0
  17. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/state_manager.py +2 -3
  18. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/stats.py +9 -10
  19. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/yaml_util.py +277 -107
  20. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/input/gpio.py +4 -3
  21. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/input/gpio_new.py +37 -33
  22. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/manager.py +184 -133
  23. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/client.py +56 -21
  24. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/modbuscli.py +52 -16
  25. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/sensor.py +34 -14
  26. boneIO-0.9.0.dev4/boneio/modbus/sht30.json +37 -0
  27. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/single_sensor.py +17 -5
  28. boneIO-0.9.0.dev4/boneio/models/__init__.py +45 -0
  29. boneIO-0.9.0.dev4/boneio/models/files.py +16 -0
  30. boneIO-0.9.0.dev4/boneio/models/logs.py +12 -0
  31. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/mqtt_client.py +34 -19
  32. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/oled.py +14 -10
  33. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/relay/basic.py +44 -23
  34. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/relay/mcp.py +2 -3
  35. boneIO-0.9.0.dev4/boneio/runner.py +173 -0
  36. boneIO-0.9.0.dev4/boneio/schema/actions.yaml +51 -0
  37. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/schema/actions_sensor.yaml +0 -1
  38. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/schema/actions_switch.yaml +0 -1
  39. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/schema/schema.yaml +89 -14
  40. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/sensor/adc.py +3 -3
  41. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/sensor/gpio.py +2 -1
  42. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/sensor/ina219.py +30 -15
  43. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/sensor/temp/__init__.py +42 -7
  44. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/sensor/temp/dallas.py +3 -3
  45. boneIO-0.9.0.dev4/boneio/version.py +2 -0
  46. boneIO-0.9.0.dev4/boneio/webui/app.py +880 -0
  47. boneIO-0.9.0.dev4/boneio/webui/web_server.py +118 -0
  48. boneIO-0.9.0.dev4/boneio/webui/websocket_manager.py +142 -0
  49. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/pyproject.toml +6 -2
  50. boneIO-0.8.3/boneio/helper/async_updater.py +0 -29
  51. boneIO-0.8.3/boneio/helper/logger.py +0 -52
  52. boneIO-0.8.3/boneio/runner.py +0 -109
  53. boneIO-0.8.3/boneio/schema/actions.yaml +0 -45
  54. boneIO-0.8.3/boneio/version.py +0 -2
  55. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/LICENSE +0 -0
  56. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/README.md +0 -0
  57. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/__init__.py +0 -0
  58. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/__init__.py +0 -0
  59. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/adc.yaml +0 -0
  60. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/binary_sensor.yaml +0 -0
  61. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/binary_sensor_v_0_7.yaml +0 -0
  62. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/config.yaml +0 -0
  63. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/cover.yaml +0 -0
  64. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/event.yaml +0 -0
  65. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/event_all.yaml +0 -0
  66. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/event_v_0_7.yaml +0 -0
  67. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/led32x4A.yaml +0 -0
  68. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/output24x16A.yaml +0 -0
  69. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/output24x16A_v0.3.yaml +0 -0
  70. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/output32x10A.yaml +0 -0
  71. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/example_config/output32x5A.yaml +0 -0
  72. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/fonts/danube__.ttf +0 -0
  73. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/group/__init__.py +0 -0
  74. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/__init__.py +0 -0
  75. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/exceptions.py +0 -0
  76. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/filter.py +0 -0
  77. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/gpiod.py +0 -0
  78. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/ha_discovery.py +0 -0
  79. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/mqtt.py +0 -0
  80. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/oled.py +0 -0
  81. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/onewire/W1ThermSensor.py +0 -0
  82. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/onewire/__init__.py +0 -0
  83. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/onewire/ds2482.py +0 -0
  84. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/onewire/onewire.py +0 -0
  85. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/pcf8575.py +0 -0
  86. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/queue.py +0 -0
  87. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/sensor/ina_219_smbus.py +0 -0
  88. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/timeperiod.py +0 -0
  89. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/helper/util.py +0 -0
  90. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/input/__init__.py +0 -0
  91. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/__init__.py +0 -0
  92. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/cwt.json +0 -0
  93. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/dts1964_3f.json +0 -0
  94. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/liquid-sensor.json +0 -0
  95. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/orno-or-we-517.json +0 -0
  96. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/pt100.json +0 -0
  97. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/r4dcb08.json +0 -0
  98. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/sdm120.json +0 -0
  99. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/sdm630.json +0 -0
  100. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/sht20.json +0 -0
  101. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/socomec_e03.json +0 -0
  102. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/socomec_e23.json +0 -0
  103. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/sofar.json +0 -0
  104. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/modbus/utils.py +0 -0
  105. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/relay/__init__.py +0 -0
  106. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/relay/gpio.py +0 -0
  107. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/relay/pca.py +0 -0
  108. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/relay/pcf.py +0 -0
  109. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/schema/filters.yaml +0 -0
  110. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/schema/filters_adc.yaml +0 -0
  111. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/schema/id.yaml +0 -0
  112. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/schema/temp_unit.yaml +0 -0
  113. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/schema/update_interval.yaml +0 -0
  114. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/sensor/__init__.py +0 -0
  115. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/sensor/gpio_new.py +0 -0
  116. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/sensor/temp/lm75.py +0 -0
  117. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/boneio/sensor/temp/mcp9808.py +0 -0
  118. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/tests/32_5_config.yaml +0 -0
  119. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/tests/bandit.yaml +0 -0
  120. {boneIO-0.8.3 → boneIO-0.9.0.dev4}/tests/relay_32_5.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneIO
3
- Version: 0.8.3
3
+ Version: 0.9.0.dev4
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,17 @@
1
+ mcp23017:
2
+ - id: mcp1
3
+ address: 0x20
4
+ - id: mcp2
5
+ address: 0x21
6
+
7
+ output_mapping:
8
+ out_01:
9
+ kind: mcp
10
+ mcp_id: mcp2
11
+ pin: 7
12
+ output_type: light
13
+ out_02:
14
+ kind: mcp
15
+ mcp_id: mcp2
16
+ pin: 6
17
+ output_type: light
@@ -0,0 +1,110 @@
1
+ input_mapping:
2
+ in_01:
3
+ pin: P8_37
4
+ gpio_mode: gpio_pu
5
+ in_02:
6
+ pin: P8_38
7
+ gpio_mode: gpio_pu
8
+ in_03:
9
+ pin: P8_39
10
+ in_04:
11
+ pin: P8_40
12
+ in_05:
13
+ pin: P8_41
14
+ in_06:
15
+ pin: P8_42
16
+ in_07:
17
+ pin: P8_43
18
+ in_08:
19
+ pin: P8_44
20
+ in_09:
21
+ pin: P8_45
22
+ in_10:
23
+ pin: P8_46
24
+ gpio_mode: gpio_pu
25
+ in_11:
26
+ pin: P9_42
27
+ in_12:
28
+ pin: P9_31
29
+ in_13:
30
+ pin: P9_30
31
+ in_14:
32
+ pin: P9_29
33
+ in_15:
34
+ pin: P9_28
35
+ in_16:
36
+ pin: P9_27
37
+ in_17:
38
+ pin: P9_25
39
+ in_18:
40
+ pin: P9_23
41
+ in_19:
42
+ pin: P9_22
43
+ gpio_mode: gpio_pu
44
+ in_20:
45
+ pin: P9_21
46
+ gpio_mode: gpio_pu
47
+ in_21:
48
+ pin: P9_18
49
+ in_22:
50
+ pin: P9_17
51
+ in_23:
52
+ pin: P9_16
53
+ in_24:
54
+ pin: P9_15
55
+ in_25:
56
+ pin: P9_14
57
+ in_26:
58
+ pin: P8_7
59
+ in_27:
60
+ pin: P8_8
61
+ in_28:
62
+ pin: P8_9
63
+ in_29:
64
+ pin: P8_36
65
+ gpio_mode: gpio_pu
66
+ in_30:
67
+ pin: P8_35
68
+ gpio_mode: gpio_pu
69
+ in_31:
70
+ pin: P8_34
71
+ gpio_mode: gpio_pu
72
+ in_32:
73
+ pin: P8_33
74
+ gpio_mode: gpio_pu
75
+ in_33:
76
+ pin: P8_32
77
+ gpio_mode: gpio_pu
78
+ in_34:
79
+ pin: P8_31
80
+ gpio_mode: gpio_pu
81
+ in_35:
82
+ pin: P8_30
83
+ in_36:
84
+ pin: P8_29
85
+ in_37:
86
+ pin: P8_28
87
+ in_38:
88
+ pin: P8_27
89
+ in_39:
90
+ pin: P8_26
91
+ in_40:
92
+ pin: P8_19
93
+ in_41:
94
+ pin: P8_18
95
+ in_42:
96
+ pin: P8_17
97
+ in_43:
98
+ pin: P8_16
99
+ in_44:
100
+ pin: P8_15
101
+ in_45:
102
+ pin: P8_14
103
+ in_46:
104
+ pin: P8_13
105
+ in_47:
106
+ pin: P8_12
107
+ in_48:
108
+ pin: P8_11
109
+ in_49:
110
+ pin: P8_10
@@ -0,0 +1,137 @@
1
+ mcp23017:
2
+ - id: mcp1
3
+ address: 0x23
4
+ - id: mcp2
5
+ address: 0x24
6
+
7
+ output_mapping:
8
+ out_01:
9
+ kind: mcp
10
+ mcp_id: mcp2
11
+ pin: 7
12
+ out_02:
13
+ kind: mcp
14
+ mcp_id: mcp2
15
+ pin: 6
16
+ out_03:
17
+ kind: mcp
18
+ mcp_id: mcp2
19
+ pin: 5
20
+ out_04:
21
+ kind: mcp
22
+ mcp_id: mcp2
23
+ pin: 4
24
+ out_05:
25
+ kind: mcp
26
+ mcp_id: mcp2
27
+ pin: 3
28
+ out_06:
29
+ kind: mcp
30
+ mcp_id: mcp2
31
+ pin: 2
32
+ out_07:
33
+ kind: mcp
34
+ mcp_id: mcp2
35
+ pin: 1
36
+ out_08:
37
+ kind: mcp
38
+ mcp_id: mcp2
39
+ pin: 0
40
+ out_09:
41
+ kind: mcp
42
+ mcp_id: mcp1
43
+ pin: 7
44
+ out_10:
45
+ kind: mcp
46
+ mcp_id: mcp1
47
+ pin: 6
48
+ out_11:
49
+ kind: mcp
50
+ mcp_id: mcp1
51
+ pin: 5
52
+ out_12:
53
+ kind: mcp
54
+ mcp_id: mcp1
55
+ pin: 4
56
+ out_13:
57
+ kind: mcp
58
+ mcp_id: mcp1
59
+ pin: 3
60
+ out_14:
61
+ kind: mcp
62
+ mcp_id: mcp1
63
+ pin: 2
64
+ out_15:
65
+ kind: mcp
66
+ mcp_id: mcp1
67
+ pin: 1
68
+ out_16:
69
+ kind: mcp
70
+ mcp_id: mcp1
71
+ pin: 0
72
+ out_17:
73
+ kind: mcp
74
+ mcp_id: mcp2
75
+ pin: 8
76
+ out_18:
77
+ kind: mcp
78
+ mcp_id: mcp2
79
+ pin: 9
80
+ out_19:
81
+ kind: mcp
82
+ mcp_id: mcp2
83
+ pin: 10
84
+ out_20:
85
+ kind: mcp
86
+ mcp_id: mcp2
87
+ pin: 11
88
+ out_21:
89
+ kind: mcp
90
+ mcp_id: mcp2
91
+ pin: 12
92
+ out_22:
93
+ kind: mcp
94
+ mcp_id: mcp2
95
+ pin: 13
96
+ out_23:
97
+ kind: mcp
98
+ mcp_id: mcp2
99
+ pin: 14
100
+ out_24:
101
+ kind: mcp
102
+ mcp_id: mcp2
103
+ pin: 15
104
+ out_25:
105
+ kind: mcp
106
+ mcp_id: mcp1
107
+ pin: 8
108
+ out_26:
109
+ kind: mcp
110
+ mcp_id: mcp1
111
+ pin: 9
112
+ out_27:
113
+ kind: mcp
114
+ mcp_id: mcp1
115
+ pin: 10
116
+ out_28:
117
+ kind: mcp
118
+ mcp_id: mcp1
119
+ pin: 11
120
+ out_29:
121
+ kind: mcp
122
+ mcp_id: mcp1
123
+ pin: 12
124
+ out_30:
125
+ kind: mcp
126
+ mcp_id: mcp1
127
+ pin: 13
128
+ out_31:
129
+ kind: mcp
130
+ mcp_id: mcp1
131
+ pin: 14
132
+ out_32:
133
+ kind: mcp
134
+ mcp_id: mcp1
135
+ pin: 15
136
+
137
+
@@ -2,57 +2,40 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import logging
5
6
  import os
6
7
 
7
8
  os.environ["W1THERMSENSOR_NO_KERNEL_MODULE"] = "1"
8
9
 
9
10
  import argparse
10
11
  import asyncio
11
- import logging
12
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
13
 
14
+ from yaml import MarkedYAMLError
23
15
 
24
16
  from boneio.const import ACTION
25
17
  from boneio.helper import load_config_from_file
18
+ from boneio.helper.events import GracefulExit
26
19
  from boneio.helper.exceptions import (
27
20
  ConfigurationException,
28
21
  RestartRequestException,
29
22
  )
30
- from boneio.helper.events import GracefulExit
31
- from boneio.helper.logger import configure_logger
23
+ from boneio.helper.logger import configure_logger, setup_logging
24
+ from boneio.modbus.client import VALUE_TYPES
25
+ from boneio.modbus.modbuscli import (
26
+ async_run_modbus_get,
27
+ async_run_modbus_search,
28
+ async_run_modbus_set,
29
+ )
32
30
  from boneio.runner import async_run
33
31
  from boneio.version import __version__
34
32
 
35
33
  TASK_CANCELATION_TIMEOUT = 1
36
34
 
37
35
  _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
- )
36
+
37
+
38
+
56
39
 
57
40
 
58
41
  def get_arguments() -> argparse.Namespace:
@@ -110,7 +93,7 @@ def get_arguments() -> argparse.Namespace:
110
93
  modbus_parser.add_argument(
111
94
  "--baudrate",
112
95
  type=int,
113
- choices=[2400, 4800, 9600, 14400, 19200],
96
+ choices=[1200, 2400, 4800, 9600, 14400, 19200],
114
97
  required=True,
115
98
  help="Current baudrate",
116
99
  )
@@ -157,7 +140,7 @@ def get_arguments() -> argparse.Namespace:
157
140
  set_modbus_parser.add_argument(
158
141
  "--device",
159
142
  type=str,
160
- choices=["cwt", "r4dcb08", "liquid-sensor", "sht20", "custom"],
143
+ choices=["cwt", "r4dcb08", "liquid-sensor", "sht20", "sht30", "custom"],
161
144
  help="Choose device to set modbus address/baudrate. For custom you must provide --custom-value and --custom-register-address",
162
145
  required=True,
163
146
  )
@@ -176,11 +159,16 @@ def get_arguments() -> argparse.Namespace:
176
159
  )
177
160
 
178
161
  get_modbus_parser = modbus_sub_parser.add_parser("get")
179
- get_modbus_parser.add_argument(
162
+ register_group = get_modbus_parser.add_mutually_exclusive_group(required=True)
163
+ register_group.add_argument(
180
164
  "--register-address",
181
165
  type=int,
182
- help="Register address",
183
- required=True,
166
+ help="Single register address to read",
167
+ )
168
+ register_group.add_argument(
169
+ "--register-range",
170
+ type=str,
171
+ help="Register address range in format 'start-stop' (e.g., '1-230')",
184
172
  )
185
173
  get_modbus_parser.add_argument(
186
174
  "--register-type",
@@ -196,7 +184,6 @@ def get_arguments() -> argparse.Namespace:
196
184
  help="Value types",
197
185
  required=True,
198
186
  )
199
- parser.add_argument("--version", action="version", version=__version__)
200
187
  search_modbus_parser = modbus_sub_parser.add_parser(
201
188
  name="search",
202
189
  help="Search for device. Iterate over every address 1-253 with provided register address",
@@ -214,6 +201,7 @@ def get_arguments() -> argparse.Namespace:
214
201
  help="Register type",
215
202
  required=True,
216
203
  )
204
+ parser.add_argument("--version", action="version", version=__version__)
217
205
  arguments = parser.parse_args()
218
206
 
219
207
  return arguments
@@ -223,6 +211,7 @@ def run(
223
211
  config: str, debug: int, mqttusername: str = "", mqttpassword: str = ""
224
212
  ) -> int:
225
213
  """Run BoneIO."""
214
+ setup_logging(debug_level=debug)
226
215
  _LOGGER.info("BoneIO %s starting.", __version__)
227
216
  try:
228
217
  _config = load_config_from_file(config_file=config)
@@ -230,18 +219,22 @@ def run(
230
219
  _LOGGER.error("Config not loaded. Exiting.")
231
220
  return 1
232
221
  configure_logger(log_config=_config.get("logger"), debug=debug)
233
- asyncio.run(
222
+ ret = asyncio.run(
234
223
  async_run(
235
224
  config=_config,
236
225
  config_file=config,
237
226
  mqttusername=mqttusername,
238
227
  mqttpassword=mqttpassword,
228
+ debug=debug,
239
229
  ),
240
230
  )
231
+ _LOGGER.info("BoneIO %s exiting.", __version__)
232
+ return ret
233
+ except KeyboardInterrupt:
241
234
  return 0
242
- except (RestartRequestException, GracefulExit) as err:
235
+ except GracefulExit as err:
243
236
  if err is not None:
244
- _LOGGER.info(err)
237
+ _LOGGER.info("Message: %s", err)
245
238
  return 0
246
239
  except (ConfigurationException, MarkedYAMLError) as err:
247
240
  _LOGGER.error("Failed to load config. %s Exiting.", err)
@@ -252,6 +245,7 @@ def run_modbus_command(
252
245
  args: argparse.Namespace,
253
246
  ) -> int:
254
247
  """Run BoneIO."""
248
+ setup_logging(debug_level=args.debug)
255
249
  _LOGGER.info("BoneIO %s starting.", __version__)
256
250
  try:
257
251
  configure_logger(log_config={}, debug=args.debug)
@@ -284,6 +278,7 @@ def run_modbus_command(
284
278
  bytesize=args.bytesize,
285
279
  stopbits=args.stopbits,
286
280
  value_type=args.value_type,
281
+ register_range=args.register_range,
287
282
  ),
288
283
  )
289
284
  else:
@@ -293,9 +288,9 @@ def run_modbus_command(
293
288
  baudrate=args.baudrate,
294
289
  register_address=args.register_address,
295
290
  register_type=args.register_type,
296
- parity=args.parity,
297
- bytesize=args.bytesize,
298
291
  stopbits=args.stopbits,
292
+ bytesize=args.bytesize,
293
+ parity=args.parity,
299
294
  ),
300
295
  )
301
296
  return ret
@@ -10,7 +10,7 @@ except ModuleNotFoundError:
10
10
  pass
11
11
  from typing_extensions import Literal
12
12
 
13
- BONEIO = "boneIO"
13
+ BONEIO = "boneio"
14
14
  NONE = "none"
15
15
 
16
16
  # MISCELLANEOUS CONSTS
@@ -43,6 +43,7 @@ MASK = "mask"
43
43
  MAC = "mac"
44
44
  NONE = "none"
45
45
  MODBUS = "modbus"
46
+ MODBUS_SENSOR = "modbus_sensor"
46
47
  UART = "uart"
47
48
  RX = "rx"
48
49
  TX = "tx"
@@ -1,6 +1,7 @@
1
1
  """Cover module."""
2
2
 
3
3
  from __future__ import annotations
4
+
4
5
  import asyncio
5
6
  import logging
6
7
  from typing import Callable
@@ -109,7 +110,7 @@ class Cover(BasicMqtt):
109
110
  async with self._lock:
110
111
  if inverted_relay.is_active:
111
112
  inverted_relay.turn_off()
112
- self._timer_handle = self._event_bus.add_listener(
113
+ self._timer_handle = self._event_bus.add_every_second_listener(
113
114
  f"{COVER}{self.id}", self.listen_cover
114
115
  )
115
116
  relay.turn_on()
@@ -143,7 +144,7 @@ class Cover(BasicMqtt):
143
144
  self._open.relay.turn_off()
144
145
  self._close.relay.turn_off()
145
146
  if self._timer_handle is not None:
146
- self._event_bus.remove_listener(f"{COVER}{self.id}")
147
+ self._event_bus.remove_every_second_listener(f"{COVER}{self.id}")
147
148
  self._timer_handle = None
148
149
  self._set_position = None
149
150
  if not on_exit:
@@ -1,9 +1,12 @@
1
1
  """Group output module."""
2
2
 
3
3
  from __future__ import annotations
4
+
4
5
  import asyncio
5
6
  from typing import List
6
- from boneio.const import COVER, SWITCH, ON, OFF
7
+
8
+ from boneio.const import COVER, OFF, ON, SWITCH
9
+ from boneio.models import OutputState
7
10
  from boneio.relay.basic import BasicRelay
8
11
 
9
12
 
@@ -34,7 +37,7 @@ class OutputGroup(BasicRelay):
34
37
  for member in self._group_members:
35
38
  self._event_bus.add_output_listener(
36
39
  output_id=member.id,
37
- group_id=self.id,
40
+ listener_id=self.id,
38
41
  target=self.event_listener,
39
42
  )
40
43
 
@@ -44,7 +47,7 @@ class OutputGroup(BasicRelay):
44
47
  self._state = ON
45
48
  return
46
49
 
47
- async def event_listener(self, relay_id=None) -> None:
50
+ async def event_listener(self, event: OutputState = None) -> None:
48
51
  """Listen for events called by children relays."""
49
52
  if self._all_on_behaviour:
50
53
  state = (
@@ -54,34 +57,26 @@ class OutputGroup(BasicRelay):
54
57
  state = (
55
58
  ON if any(x.state == ON for x in self._group_members) else OFF
56
59
  )
57
- if state != self._state or not relay_id:
60
+ if state != self._state or not event:
58
61
  self._state = state
59
- self._loop.call_soon_threadsafe(self.send_state)
62
+ self._loop.create_task(self.async_send_state())
60
63
 
61
64
  async def async_turn_on(self) -> None:
62
65
  """Call turn on action."""
63
- await asyncio.gather(
64
- *[
65
- self._loop.run_in_executor(self.executor, x.turn_on)
66
- for x in self._group_members
67
- ]
68
- )
66
+ for x in self._group_members:
67
+ self._loop.create_task(x.async_turn_on())
69
68
 
70
69
  async def async_turn_off(self) -> None:
71
70
  """Call turn off action."""
72
- await asyncio.gather(
73
- *[
74
- self._loop.run_in_executor(self.executor, x.turn_off)
75
- for x in self._group_members
76
- ]
77
- )
71
+ for x in self._group_members:
72
+ self._loop.create_task(x.async_turn_off())
78
73
 
79
74
  @property
80
75
  def is_active(self) -> bool:
81
76
  """Is relay active."""
82
77
  return self._state == ON
83
78
 
84
- def send_state(self) -> None:
79
+ async def async_send_state(self) -> None:
85
80
  """Send state to Mqtt on action."""
86
81
  self._send_message(
87
82
  topic=self._send_topic, payload=self.payload(), retain=True
@@ -0,0 +1,39 @@
1
+ from __future__ import annotations
2
+
3
+ import asyncio
4
+ import time
5
+
6
+ # Typing imports that create a circular dependency
7
+ from typing import TYPE_CHECKING
8
+
9
+ if TYPE_CHECKING:
10
+ from ..manager import Manager
11
+ from boneio.helper.timeperiod import TimePeriod
12
+
13
+
14
+ class AsyncUpdater:
15
+ def __init__(self, manager: Manager, update_interval: TimePeriod, **kwargs):
16
+ self.manager = manager
17
+ self._update_interval = update_interval or TimePeriod(seconds=60)
18
+ self.manager.append_task(coro=self._refresh, name=self.id)
19
+ self._timestamp = time.time()
20
+
21
+
22
+ async def _refresh(self) -> None:
23
+ try:
24
+ while True:
25
+ if hasattr(self, "async_update"):
26
+ update_interval = (
27
+ await self.async_update(timestamp=time.time())
28
+ or self._update_interval.total_in_seconds
29
+ )
30
+ else:
31
+ update_interval = (
32
+ self.update(timestamp=time.time()) or self._update_interval.total_in_seconds
33
+ )
34
+ await asyncio.sleep(update_interval)
35
+ except asyncio.CancelledError:
36
+ raise
37
+ @property
38
+ def last_timestamp(self) -> float:
39
+ return self._timestamp
@@ -31,12 +31,10 @@ class ClickTimer:
31
31
  self._remove_listener.cancel()
32
32
  self._remove_listener = None
33
33
 
34
- async def _start_async_timer(self) -> None:
35
- start = time.time()
36
- await asyncio.sleep(self._delay)
34
+ def _start_action(self, start: float) -> None:
37
35
  self._remove_listener = None
38
36
  self._action(round(time.time() - start, 2))
39
37
 
40
38
  def start_timer(self) -> None:
41
39
  """Start timer."""
42
- self._remove_listener = self._loop.create_task(self._start_async_timer())
40
+ self._remove_listener = self._loop.call_later(self._delay, self._start_action, time.time())
@@ -2,19 +2,33 @@
2
2
  Module to provide basic config options.
3
3
  """
4
4
  from __future__ import annotations
5
+
5
6
  from _collections_abc import dict_values
6
7
  from typing import Union
7
- from boneio.const import BONEIO, HOMEASSISTANT, LIGHT, SENSOR, COVER, BUTTON, SWITCH, BINARY_SENSOR, EVENT_ENTITY
8
+
9
+ from boneio.const import (
10
+ BINARY_SENSOR,
11
+ BONEIO,
12
+ BUTTON,
13
+ COVER,
14
+ EVENT_ENTITY,
15
+ HOMEASSISTANT,
16
+ LIGHT,
17
+ SENSOR,
18
+ SWITCH,
19
+ )
8
20
 
9
21
 
10
22
  class ConfigHelper:
11
23
  def __init__(
12
24
  self,
13
- topic_prefix: str = BONEIO,
25
+ topic_prefix: str,
26
+ name: str = BONEIO,
14
27
  ha_discovery: bool = True,
15
28
  ha_discovery_prefix: str = HOMEASSISTANT,
16
29
  ):
17
- self._topic_prefix = topic_prefix
30
+ self._name = name
31
+ self._topic_prefix = topic_prefix if topic_prefix else name
18
32
  self._ha_discovery = ha_discovery
19
33
  self._ha_discovery_prefix = ha_discovery_prefix
20
34
  self._fetch_old_discovery = None
@@ -33,6 +47,10 @@ class ConfigHelper:
33
47
  def topic_prefix(self) -> str:
34
48
  return self._topic_prefix
35
49
 
50
+ @property
51
+ def name(self) -> str:
52
+ return self._name
53
+
36
54
  @property
37
55
  def ha_discovery(self) -> bool:
38
56
  return self._ha_discovery