boneIO 0.8.0.dev9__tar.gz → 0.8.0.dev10__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 (103) hide show
  1. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/PKG-INFO +1 -1
  2. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/gpio.py +29 -8
  3. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/stats.py +8 -6
  4. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/client.py +7 -0
  5. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/orno-or-we-517.json +8 -0
  6. boneIO-0.8.0.dev9/boneio/modbus/socomec_e23.json → boneIO-0.8.0.dev10/boneio/modbus/socomec_e03.json +1 -1
  7. boneIO-0.8.0.dev10/boneio/modbus/socomec_e23.json +164 -0
  8. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/schema/schema.yaml +6 -0
  9. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/sensor/gpio_new.py +18 -4
  10. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/sensor/ina219.py +7 -11
  11. boneIO-0.8.0.dev10/boneio/version.py +2 -0
  12. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/pyproject.toml +1 -1
  13. boneIO-0.8.0.dev9/boneio/version.py +0 -2
  14. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/LICENSE +0 -0
  15. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/README.md +0 -0
  16. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/__init__.py +0 -0
  17. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/bonecli.py +0 -0
  18. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/const.py +0 -0
  19. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/cover.py +0 -0
  20. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/__init__.py +0 -0
  21. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/adc.yaml +0 -0
  22. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/binary_sensor.yaml +0 -0
  23. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/binary_sensor_v_0_7.yaml +0 -0
  24. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/config.yaml +0 -0
  25. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/cover.yaml +0 -0
  26. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/event.yaml +0 -0
  27. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/event_all.yaml +0 -0
  28. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/event_v_0_7.yaml +0 -0
  29. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/led32x4A.yaml +0 -0
  30. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/output24x16A.yaml +0 -0
  31. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/output24x16A_v0.3.yaml +0 -0
  32. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/output32x10A.yaml +0 -0
  33. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/example_config/output32x5A.yaml +0 -0
  34. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/fonts/danube__.ttf +0 -0
  35. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/group/__init__.py +0 -0
  36. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/group/output.py +0 -0
  37. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/__init__.py +0 -0
  38. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/async_updater.py +0 -0
  39. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/click_timer.py +0 -0
  40. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/config.py +0 -0
  41. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/events.py +0 -0
  42. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/exceptions.py +0 -0
  43. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/filter.py +0 -0
  44. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/ha_discovery.py +0 -0
  45. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/loader.py +0 -0
  46. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/logger.py +0 -0
  47. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/mqtt.py +0 -0
  48. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/oled.py +0 -0
  49. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/onewire/W1ThermSensor.py +0 -0
  50. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/onewire/__init__.py +0 -0
  51. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/onewire/ds2482.py +0 -0
  52. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/onewire/onewire.py +0 -0
  53. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/pcf8575.py +0 -0
  54. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/queue.py +0 -0
  55. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/sensor/ina_219_smbus.py +0 -0
  56. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/state_manager.py +0 -0
  57. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/timeperiod.py +0 -0
  58. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/util.py +0 -0
  59. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/helper/yaml_util.py +0 -0
  60. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/input/__init__.py +0 -0
  61. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/input/gpio.py +0 -0
  62. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/input/gpio_new.py +0 -0
  63. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/manager.py +0 -0
  64. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/__init__.py +0 -0
  65. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/cwt.json +0 -0
  66. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/dts1964_3f.json +0 -0
  67. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/liquid-sensor.json +0 -0
  68. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/modbuscli.py +0 -0
  69. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/pt100.json +0 -0
  70. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/r4dcb08.json +0 -0
  71. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/sdm120.json +0 -0
  72. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/sdm630.json +0 -0
  73. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/sensor.py +0 -0
  74. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/sht20.json +0 -0
  75. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/sofar.json +0 -0
  76. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/modbus/utils.py +0 -0
  77. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/mqtt_client.py +0 -0
  78. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/oled.py +0 -0
  79. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/relay/__init__.py +0 -0
  80. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/relay/basic.py +0 -0
  81. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/relay/gpio.py +0 -0
  82. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/relay/mcp.py +0 -0
  83. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/relay/pca.py +0 -0
  84. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/relay/pcf.py +0 -0
  85. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/runner.py +1 -1
  86. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/schema/actions.yaml +0 -0
  87. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/schema/actions_sensor.yaml +0 -0
  88. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/schema/actions_switch.yaml +0 -0
  89. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/schema/filters.yaml +0 -0
  90. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/schema/filters_adc.yaml +0 -0
  91. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/schema/id.yaml +0 -0
  92. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/schema/temp_unit.yaml +0 -0
  93. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/schema/update_interval.yaml +0 -0
  94. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/sensor/__init__.py +0 -0
  95. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/sensor/adc.py +0 -0
  96. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/sensor/gpio.py +0 -0
  97. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/sensor/temp/__init__.py +0 -0
  98. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/sensor/temp/dallas.py +0 -0
  99. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/sensor/temp/lm75.py +0 -0
  100. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/boneio/sensor/temp/mcp9808.py +0 -0
  101. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/tests/32_5_config.yaml +0 -0
  102. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/tests/bandit.yaml +0 -0
  103. {boneIO-0.8.0.dev9 → boneIO-0.8.0.dev10}/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.0.dev9
3
+ Version: 0.8.0.dev10
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>
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
  import asyncio
3
3
  import logging
4
4
  from datetime import datetime
5
+
5
6
  try:
6
7
  from Adafruit_BBIO import GPIO
7
8
  except ModuleNotFoundError:
@@ -21,7 +22,14 @@ from typing import Callable, Awaitable, List
21
22
 
22
23
  from boneio.const import CONFIG_PIN, FALLING
23
24
  from boneio.const import GPIO as GPIO_STR
24
- from boneio.const import GPIO_MODE, LOW, ClickTypes, Gpio_Edges, Gpio_States, InputTypes
25
+ from boneio.const import (
26
+ GPIO_MODE,
27
+ LOW,
28
+ ClickTypes,
29
+ Gpio_Edges,
30
+ Gpio_States,
31
+ InputTypes,
32
+ )
25
33
  from boneio.helper.exceptions import GPIOInputException
26
34
  from boneio.helper.timeperiod import TimePeriod
27
35
  from concurrent.futures import ThreadPoolExecutor
@@ -79,7 +87,9 @@ def edge_detect(
79
87
  ) -> None:
80
88
  """Add detection for RISING and FALLING events."""
81
89
  try:
82
- GPIO.add_event_detect(gpio=pin, edge=edge, callback=callback, bouncetime=bounce)
90
+ GPIO.add_event_detect(
91
+ gpio=pin, edge=edge, callback=callback, bouncetime=bounce
92
+ )
83
93
  except RuntimeError as err:
84
94
  raise GPIOInputException(err)
85
95
 
@@ -107,7 +117,8 @@ class GpioBaseClass:
107
117
  self,
108
118
  pin: str,
109
119
  press_callback: Callable[
110
- [ClickTypes, str, List, InputTypes, bool, float | None], Awaitable[None]
120
+ [ClickTypes, str, List, InputTypes, bool, float | None],
121
+ Awaitable[None],
111
122
  ],
112
123
  name: str,
113
124
  actions: dict,
@@ -118,7 +129,9 @@ class GpioBaseClass:
118
129
  """Setup GPIO Input Button"""
119
130
  self._pin = pin
120
131
  gpio_mode = kwargs.get(GPIO_MODE, GPIO_STR)
121
- bounce_time: TimePeriod = kwargs.get("bounce_time", TimePeriod(milliseconds=50))
132
+ bounce_time: TimePeriod = kwargs.get(
133
+ "bounce_time", TimePeriod(milliseconds=50)
134
+ )
122
135
  self._bounce_time = bounce_time.total_in_seconds
123
136
  self._loop = asyncio.get_running_loop()
124
137
  self._press_callback = press_callback
@@ -129,14 +142,22 @@ class GpioBaseClass:
129
142
  self._input_type = input_type
130
143
  self._empty_message_after = empty_message_after
131
144
 
132
- def press_callback(self, click_type: ClickTypes, duration: float | None = None) -> None:
145
+ def press_callback(
146
+ self, click_type: ClickTypes, duration: float | None = None
147
+ ) -> None:
133
148
  actions = self._actions.get(click_type, [])
134
- self._loop.create_task(self.async_press_callback(click_type, duration, actions))
149
+ self._loop.create_task(
150
+ self.async_press_callback(click_type, duration, actions)
151
+ )
135
152
 
136
153
  async def async_press_callback(
137
- self, click_type: ClickTypes, duration: float | None = None, actions: List = []
154
+ self,
155
+ click_type: ClickTypes,
156
+ duration: float | None = None,
157
+ actions: List = [],
138
158
  ) -> None:
139
- _LOGGER.warn("press callback %s", datetime.now())
159
+
160
+ _LOGGER.warning("press callback %s", datetime.now())
140
161
  await self._press_callback(
141
162
  click_type,
142
163
  self._pin,
@@ -233,13 +233,15 @@ class HostData:
233
233
  },
234
234
  }
235
235
  if ina219 is not None:
236
+
237
+ def get_ina_values():
238
+ return {
239
+ sensor.device_class: f"{sensor.state} {sensor.unit_of_measurement}"
240
+ for sensor in ina219.sensors.values()
241
+ }
242
+
236
243
  host_stats[INA219] = {
237
- "f": lambda: {
238
- *{
239
- sensor.device_class: sensor.state
240
- for sensor in ina219.sensors.values()
241
- }
242
- },
244
+ "f": get_ina_values,
243
245
  "update_interval": TimePeriod(seconds=60),
244
246
  }
245
247
  self._data = {}
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import asyncio
4
4
  import logging
5
5
  import struct
6
+ import time
6
7
  from typing import Any
7
8
 
8
9
  from pymodbus.client.sync import BaseModbusClient, ModbusSerialClient
@@ -131,6 +132,7 @@ class Modbus:
131
132
  ) -> ModbusResponse:
132
133
  """Call async pymodbus."""
133
134
  async with self._lock:
135
+ start_time = time.perf_counter()
134
136
  if not self._pymodbus_connect():
135
137
  _LOGGER.error("Can't connect to Modbus.")
136
138
  return None
@@ -153,6 +155,11 @@ class Modbus:
153
155
  if not hasattr(result, REGISTERS):
154
156
  _LOGGER.error(str(result))
155
157
  return None
158
+ end_time = time.perf_counter()
159
+ _LOGGER.debug(
160
+ "Time of execution of read_registers: %s ms.",
161
+ round((end_time - start_time) * 1000, 3),
162
+ )
156
163
  return result
157
164
 
158
165
  def decode_value(self, payload, value_type):
@@ -29,6 +29,14 @@
29
29
  "state_class": "measurement",
30
30
  "device_class": "voltage",
31
31
  "value_type": "FP32"
32
+ },
33
+ {
34
+ "name": "Grid Frequency",
35
+ "address": 18,
36
+ "unit_of_measurement": "V",
37
+ "state_class": "measurement",
38
+ "device_class": "voltage",
39
+ "value_type": "FP32"
32
40
  }
33
41
  ]
34
42
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "model": "Socomec E23/E24",
2
+ "model": "Socomec E03",
3
3
  "registers_base": [
4
4
  {
5
5
  "base": 50520,
@@ -0,0 +1,164 @@
1
+ {
2
+ "model": "Socomec E23/E24",
3
+ "registers_base": [
4
+ {
5
+ "base": 50520,
6
+ "length": 26,
7
+ "register_type": "holding",
8
+ "registers": [
9
+ {
10
+ "name": "Voltage_Phase1",
11
+ "address": 50520,
12
+ "unit_of_measurement": "V",
13
+ "state_class": "measurement",
14
+ "device_class": "voltage",
15
+ "value_type": "U_DWORD",
16
+ "filters": [{ "multiply": 0.01 }]
17
+ },
18
+ {
19
+ "name": "Voltage_Phase2",
20
+ "address": 50522,
21
+ "unit_of_measurement": "V",
22
+ "state_class": "measurement",
23
+ "device_class": "voltage",
24
+ "value_type": "U_DWORD",
25
+ "filters": [{ "multiply": 0.01 }]
26
+ },
27
+ {
28
+ "name": "Voltage_Phase3",
29
+ "address": 50524,
30
+ "unit_of_measurement": "V",
31
+ "state_class": "measurement",
32
+ "device_class": "voltage",
33
+ "value_type": "U_DWORD",
34
+ "filters": [{ "multiply": 0.01 }]
35
+ },
36
+ {
37
+ "name": "Frequency",
38
+ "address": 50526,
39
+ "unit_of_measurement": "Hz",
40
+ "state_class": "measurement",
41
+ "device_class": "voltage",
42
+ "value_type": "U_DWORD",
43
+ "filters": [{ "multiply": 0.001 }]
44
+ },
45
+ {
46
+ "name": "Current_Phase1",
47
+ "address": 50528,
48
+ "unit_of_measurement": "A",
49
+ "state_class": "measurement",
50
+ "device_class": "current",
51
+ "value_type": "U_DWORD",
52
+ "filters": [{ "multiply": 0.001 }]
53
+ },
54
+ {
55
+ "name": "Current_Phase2",
56
+ "address": 50530,
57
+ "unit_of_measurement": "A",
58
+ "state_class": "measurement",
59
+ "device_class": "current",
60
+ "value_type": "U_DWORD",
61
+ "filters": [{ "multiply": 0.001 }]
62
+ },
63
+ {
64
+ "name": "Current_Phase3",
65
+ "address": 50532,
66
+ "unit_of_measurement": "A",
67
+ "state_class": "measurement",
68
+ "device_class": "current",
69
+ "value_type": "U_DWORD",
70
+ "filters": [{ "multiply": 0.001 }]
71
+ },
72
+ {
73
+ "name": "Current_In",
74
+ "address": 50534,
75
+ "unit_of_measurement": "A",
76
+ "state_class": "measurement",
77
+ "device_class": "current",
78
+ "value_type": "U_DWORD",
79
+ "filters": [{ "multiply": 0.001 }]
80
+ },
81
+ {
82
+ "name": "Sum_Active_Power",
83
+ "address": 50536,
84
+ "unit_of_measurement": "W",
85
+ "state_class": "measurement",
86
+ "value_type": "S_DWORD",
87
+ "filters": [{ "multiply": 10 }]
88
+ },
89
+ {
90
+ "name": "Sum_Reactive_Power",
91
+ "address": 50538,
92
+ "unit_of_measurement": "var",
93
+ "state_class": "measurement",
94
+ "value_type": "S_DWORD",
95
+ "filters": [{ "multiply": 10 }]
96
+ },
97
+ {
98
+ "name": "Sum_Apparent_Power",
99
+ "address": 50540,
100
+ "unit_of_measurement": "VA",
101
+ "state_class": "measurement",
102
+ "value_type": "U_DWORD",
103
+ "filters": [{ "multiply": 10 }]
104
+ },
105
+ {
106
+ "name": "Sum_Power_Factor",
107
+ "address": 50542,
108
+ "unit_of_measurement": "",
109
+ "state_class": "measurement",
110
+ "value_type": "S_DWORD",
111
+ "filters": [{ "multiply": 0.001 }]
112
+ },
113
+ {
114
+ "name": "Active_Power_Phase1",
115
+ "address": 50544,
116
+ "unit_of_measurement": "W",
117
+ "state_class": "measurement",
118
+ "value_type": "S_DWORD",
119
+ "filters": [{ "multiply": 10 }]
120
+ },
121
+ {
122
+ "name": "Active_Power_Phase2",
123
+ "address": 50546,
124
+ "unit_of_measurement": "W",
125
+ "state_class": "measurement",
126
+ "value_type": "S_DWORD",
127
+ "filters": [{ "multiply": 10 }]
128
+ },
129
+ {
130
+ "name": "Active_Power_Phase3",
131
+ "address": 50548,
132
+ "unit_of_measurement": "W",
133
+ "state_class": "measurement",
134
+ "value_type": "S_DWORD",
135
+ "filters": [{ "multiply": 10 }]
136
+ }
137
+ ]
138
+ },
139
+ {
140
+ "base": 50946,
141
+ "length": 8,
142
+ "register_type": "holding",
143
+ "registers": [
144
+ {
145
+ "name": "Total_Positive_Active_Energy",
146
+ "address": 50946,
147
+ "unit_of_measurement": "kWh",
148
+ "value_type": "U_DWORD",
149
+ "state_class": "total",
150
+ "device_class": "energy",
151
+ "filters": [{ "multiply": 0.01 }]
152
+ },
153
+ {
154
+ "name": "Total_Negative_Active_Energy",
155
+ "address": 50952,
156
+ "unit_of_measurement": "kWh",
157
+ "state_class": "total",
158
+ "device_class": "energy",
159
+ "filters": [{ "multiply": 0.01 }]
160
+ }
161
+ ]
162
+ }
163
+ ]
164
+ }
@@ -514,6 +514,12 @@ binary_sensor:
514
514
  required: True
515
515
  meta:
516
516
  label: Check if sensor type is inverted. Only aplicable for sensor kind.
517
+ initial_send:
518
+ type: boolean
519
+ default: False
520
+ required: True
521
+ meta:
522
+ label: If set to true, then on startup of application initial status of the binary sensor will be send to MQTT.
517
523
  device_class:
518
524
  type: string
519
525
  required: False
@@ -1,12 +1,14 @@
1
1
  """GpioInputBinarySensorNew to receive signals."""
2
+
2
3
  import logging
3
4
  from boneio.const import PRESSED, RELEASED, BOTH
4
5
  from boneio.helper import GpioBaseClass
6
+ import time
5
7
  from boneio.helper.gpio import add_event_callback, add_event_detect
6
8
 
7
9
  _LOGGER = logging.getLogger(__name__)
8
10
 
9
-
11
+ soc
10
12
  class GpioInputBinarySensorNew(GpioBaseClass):
11
13
  """Represent Gpio sensor on input boards."""
12
14
 
@@ -14,20 +16,32 @@ class GpioInputBinarySensorNew(GpioBaseClass):
14
16
  """Setup GPIO Input Button"""
15
17
  super().__init__(**kwargs)
16
18
  self._state = self.is_pressed
19
+ self.button_pressed_time = 0.0
17
20
  self._click_type = (
18
21
  (RELEASED, PRESSED)
19
22
  if kwargs.get("inverted", False)
20
23
  else (PRESSED, RELEASED)
21
24
  )
25
+ self._initial_send = kwargs.get("initial_send", False)
22
26
  _LOGGER.debug("Configured sensor pin %s", self._pin)
23
27
  add_event_detect(pin=self._pin, edge=BOTH)
24
28
  add_event_callback(pin=self._pin, callback=self.check_state)
29
+ self._loop.call_soon_threadsafe(self.check_state, self._initial_send)
25
30
 
26
- def check_state(self, _) -> None:
31
+ def check_state(self, initial_send: bool = False) -> None:
32
+ """Check if state has changed."""
33
+ time_now = time.time()
27
34
  state = self.is_pressed
28
- if state == self._state:
35
+ if (time_now - self.button_pressed_time <= self._bounce_time) or (
36
+ not initial_send and state == self._state
37
+ ):
29
38
  return
30
39
  self._state = state
31
40
  click_type = self._click_type[0] if state else self._click_type[1]
32
- _LOGGER.debug("%s event on pin %s - %s", click_type, self._pin, self.name)
41
+ _LOGGER.debug(
42
+ "Binary sensor: %s event on pin %s - %s",
43
+ click_type,
44
+ self._pin,
45
+ self.name,
46
+ )
33
47
  self.press_callback(click_type=click_type, duration=None)
@@ -67,7 +67,7 @@ class INA219Sensor(BasicMqtt, Filter):
67
67
  )
68
68
 
69
69
 
70
- class INA219(AsyncUpdater, Filter):
70
+ class INA219(AsyncUpdater):
71
71
  """Represent INA219 sensors."""
72
72
 
73
73
  def __init__(
@@ -77,16 +77,14 @@ class INA219(AsyncUpdater, Filter):
77
77
  self._loop = asyncio.get_event_loop()
78
78
  self._ina_219 = INA219_I2C(address=address)
79
79
  self._sensors = {}
80
- self._states = {}
81
80
  self._id = id
82
81
  for sensor in sensors:
83
82
  _name = sensor["id"]
84
83
  _id = f"{id}{_name.replace(' ', '')}"
85
- self._states[sensor["device_class"]] = None
86
84
  self._sensors[sensor["device_class"]] = INA219Sensor(
87
85
  device_class=sensor["device_class"],
88
86
  filters=sensor.get("filters", []),
89
- state=self._states[sensor["device_class"]],
87
+ state=None,
90
88
  name=_name,
91
89
  id=_id,
92
90
  **kwargs,
@@ -104,11 +102,9 @@ class INA219(AsyncUpdater, Filter):
104
102
 
105
103
  async def async_update(self, time: datetime) -> None:
106
104
  """Fetch temperature periodically and send to MQTT."""
107
- for k in self._states.keys():
108
- value = getattr(self._ina_219, k)
109
- self._states[k] = value
110
- _LOGGER.debug("Read %s with value: %s", k, value)
111
105
  for k, sensor in self._sensors.items():
112
- if sensor.raw_state != self._states[k]:
113
- sensor.raw_state = self._states[k]
114
- self._loop.call_soon_threadsafe(sensor.update, time)
106
+ value = getattr(self._ina_219, k)
107
+ _LOGGER.debug("Fetched INA219 value: %s %s", k, value)
108
+ if sensor.raw_state != value:
109
+ sensor.raw_state = value
110
+ sensor.update(time=time)
@@ -0,0 +1,2 @@
1
+ # flake8: noqa
2
+ __version__ = "0.8.0dev10"
@@ -30,7 +30,7 @@ dependencies = [
30
30
  "Adafruit-BBIO>=1.2.0",
31
31
  ]
32
32
  requires-python = ">=3.7"
33
- version = "0.8.0.dev9"
33
+ version = "0.8.0.dev10"
34
34
 
35
35
  [project.license]
36
36
  text = "GNU General Public License v3.0"
@@ -1,2 +0,0 @@
1
- # flake8: noqa
2
- __version__ = "0.8.0dev9"
File without changes
File without changes
File without changes
@@ -1,4 +1,5 @@
1
1
  """Runner code for boneIO. Based on HA runner."""
2
+
2
3
  from __future__ import annotations
3
4
 
4
5
  import asyncio
@@ -80,7 +81,6 @@ async def async_run(
80
81
  for item in config_modules
81
82
  }
82
83
 
83
-
84
84
  manager = Manager(
85
85
  send_message=client.send_message,
86
86
  stop_client=client.stop_client,