Skip to content

Commit 21c7641

Browse files
3.3 (#49)
1 parent 32abadf commit 21c7641

13 files changed

+102
-13
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414

1515

1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.7.2
17+
rev: v0.8.0
1818
hooks:
1919
- id: ruff
2020
name: ruff unused imports

.ruff.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ ignore = [
5959

6060
# https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
6161
"RUF005", # Consider {expression} instead of concatenation
62+
63+
# https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
64+
"PT007", # Wrong values type in @pytest.mark.parametrize expected {values} of {row}
6265
]
6366

6467

docs/getting_started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ serial or http (e.g. for tibber) and edit the mqtt settings.
156156
4. Run with analyze
157157
======================================
158158

159-
Now run ``sml2mqtt`` with the path to the configuration file and the ``--analyze`` option.
159+
Now run ``sml2mqtt`` with the path to the configuration file and the ``-a`` or ``--analyze`` option.
160160
(see :ref:`command line interface <COMMAND_LINE_INTERFACE>`).
161161
This will process one sml frame from the meter and report the output.
162162
It's a convenient way to check what values will be reported.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ will be reported can be processed in various ways with operations.
1616
cli
1717
getting_started
1818
operations
19+
smart_home_systems
1920

2021

2122
Indices and tables

docs/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Packages required to build the documentation
2-
sphinx == 7.4.7
3-
sphinx-autodoc-typehints == 2.2.3
4-
sphinx_rtd_theme == 2.0.0
5-
sphinx-exec-code == 0.12
2+
sphinx == 8.1.3
3+
sphinx-autodoc-typehints == 2.5.0
4+
sphinx_rtd_theme == 3.0.2
5+
sphinx-exec-code == 0.14
66
autodoc_pydantic == 2.2.0

docs/smart_home_systems.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
**************************************
2+
Smart Home Systems
3+
**************************************
4+
5+
Here are some examples to get started with various smart home systems.
6+
They all still require some changes so make sure to modify them to fit your setup.
7+
8+
openHAB
9+
======================================
10+
11+
Integration for `openHAB <https://www.openhab.org/>`_ requires that the
12+
`MQTT Binding <https://www.openhab.org/addons/bindings/mqtt.generic/>`_ is used.
13+
The example connects through the Bridge ``mqtt:broker:localhost``
14+
15+
| The topics you enter under ``stateTopic`` must match the topics you have configured in the sml2mqtt configuration.
16+
| Run sml2mqtt with the ``-a`` or ``--analyze`` flag to see the topics that are being published.
17+
18+
.. code-block:: text
19+
:caption: .things file
20+
21+
Thing mqtt:topic:stromzaehler "Stromzähler" (mqtt:broker:localhost) [
22+
availabilityTopic="stromzaehler/status", payloadAvailable="ONLINE", payloadNotAvailable="OFFLINE"
23+
]
24+
{
25+
Channels:
26+
27+
Type number : leistung [stateTopic="stromzaehler/leistung", unit="W"]
28+
Type number : energie [stateTopic="stromzaehler/energie", unit="kWh"]
29+
...
30+
31+
32+
Type string : status [stateTopic="stromzaehler/status"]
33+
}
34+
35+
.. code-block:: text
36+
:caption: .items file
37+
38+
String Zuhause_Status "Status [%s]" {channel="mqtt:topic:stromzaehler:status"}
39+
Number:Power Zuhause_Leistung "Leistung [%d W]" {channel="mqtt:topic:stromzaehler:leistung", unit="W", expire="5m"}
40+
Number:Energy Zuhause_Energie "Energie [%.2f kWh]" {channel="mqtt:topic:stromzaehler:leistung", unit="kWh"}
41+
42+
43+
HomeAssistant
44+
======================================
45+
46+
Integration for `Home Assistant <https://www.home-assistant.io/>`_ requires that the
47+
`mqtt integration <https://www.home-assistant.io/integrations/mqtt#configuration>`_ is used.
48+
49+
| The topics you enter under ``state_topic`` and ``topic`` must match the topics you have
50+
configured in the sml2mqtt configuration.
51+
| Run sml2mqtt with the ``-a`` or ``--analyze`` flag to see the topics that are being published.
52+
53+
.. code-block:: yaml
54+
55+
mqtt:
56+
sensor:
57+
- name: "sml2mqtt_energy_total"
58+
unique_id: f955b69a-828b-4cad-bafd-7563a909153e
59+
state_topic: "sml2mqtt/meter1/energy_total"
60+
icon: mdi:transmission-tower
61+
unit_of_measurement: kWh
62+
state_class: total
63+
device_class: energy
64+
availability:
65+
topic: "sml2mqtt/status"
66+
payload_available: "ONLINE"
67+
payload_not_available: "OFFLINE"
68+
69+
- name: "sml2mqtt_momentary_power"
70+
unique_id: 6ddc1f63-bd73-4d9b-86a1-3e7dfeccee1e
71+
state_topic: "sml2mqtt/meter1/momentary_power"
72+
unit_of_measurement: W
73+
state_class: measurement
74+
device_class: power
75+
availability:
76+
topic: "sml2mqtt/status"
77+
payload_available: "ONLINE"
78+
payload_not_available: "OFFLINE"
79+
80+
...

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ To read from the serial port an IR to USB reader for energy meter is required.
2121

2222
# Changelog
2323

24+
#### 3.3 (2024-11-26)
25+
- Updated dependencies and docs
26+
- Allow rounding to the tenth
27+
2428
#### 3.2 (2024-11-05)
2529
- Automatically select CRC e.g. for Holley DTZ541
2630

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pytest == 8.3.3
55
pre-commit == 4.0.1
66
pytest-asyncio == 0.24.0
7-
aioresponses == 0.7.6
7+
aioresponses == 0.7.7
88

99
# Linter
10-
ruff == 0.7.2
10+
ruff == 0.8.0

requirements_setup.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ pyserial-asyncio == 0.6
33
easyconfig == 0.3.2
44
pydantic == 2.8.2
55
smllib == 1.5
6-
aiohttp == 3.10.10
6+
aiohttp == 3.11.7

src/sml2mqtt/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.2'
1+
__version__ = '3.3'

src/sml2mqtt/config/operations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class HeartbeatAction(BaseModel):
9696
description='Interval'
9797
)
9898

99+
99100
# -------------------------------------------------------------------------------------------------
100101
# Math
101102
# -------------------------------------------------------------------------------------------------
@@ -108,7 +109,7 @@ class Offset(BaseModel):
108109

109110

110111
class Round(BaseModel):
111-
digits: int = Field(ge=0, le=6, alias='round', description='Round to the specified digits')
112+
digits: int = Field(ge=-4, le=6, alias='round', description='Round to the specified digits, negative for tens')
112113

113114

114115
# -------------------------------------------------------------------------------------------------

tests/config/test_default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_default() -> None:
5353
- negative on energy meter status: true # Set to "true" to enable or to "false" to disable workaround. If the default obis code for the energy meter is wrong set to the appropriate meter obis code instead
5454
- factor: 3 # Factor with which the value gets multiplied
5555
- offset: 100 # Offset that gets added on the value
56-
- round: 2 # Round to the specified digits
56+
- round: 2 # Round to the specified digits, negative for tens
5757
- type: change filter # Filter which passes only changes
5858
- refresh action: 600 # Refresh interval
5959
'''

tests/test_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def check_obj(model: BaseModel) -> None:
110110
setup_operations(DummyOperationParent(), HasOperationsModel(operations=[model]))
111111

112112
for file in (pytestconfig.rootpath / 'docs').iterdir():
113-
if file.suffix.lower() == '.rst':
113+
if file.suffix.lower() == '.rst' and file.name.lower() != 'smart_home_systems.rst':
114114
validate_yaml_blocks(file, func=check_obj)
115115

116116

0 commit comments

Comments
 (0)