Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemanspiff2007 committed Mar 25, 2024
1 parent 5f264f1 commit 693fbbe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
12 changes: 4 additions & 8 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,10 @@ Example
# If one operation blocks nothing will be reported for this frame
operations:
- negative on energy meter status: true # Make value negative based on an energy meter status. 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
- factor: 3 # Factor with which the value gets multiplied
- offset: 100 # Offset that gets added on the value
- round: 2 # Round to the specified digits
# A sequence of operations that will be evaluated one after another.
# The first value that gets returned by an operation will be used.
- or:
- type: change filter # Filter which passes only changes
- heartbeat filter: 120 # Filter which lets a value pass periodically every specified interval.
- factor: 3 # Factor with which the value gets multiplied
- offset: 100 # Offset that gets added on the value
- round: 2 # Round to the specified digits
- refresh action: 300 # Republish value every 300s
Configuration Reference
Expand Down
2 changes: 1 addition & 1 deletion docs/operations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ Examples
These are some examples for sml value configurations

Energy consumption today
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--------------------------------------

This will report the power consumption of today

Expand Down
12 changes: 6 additions & 6 deletions src/sml2mqtt/config/types.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Annotated, TypeAlias

from annotated_types import Interval
from pydantic import StrictFloat, StrictInt, StringConstraints
from pydantic import Strict, StrictFloat, StrictInt, StringConstraints


ObisHex = Annotated[
str,
StringConstraints(to_lower=True, strip_whitespace=True, pattern=r'[0-9a-fA-F]{12}')
StringConstraints(to_lower=True, strip_whitespace=True, pattern=r'[0-9a-fA-F]{12}', strict=True)
]

LowerStr = Annotated[
Expand All @@ -17,9 +17,9 @@

Number: TypeAlias = StrictInt | StrictFloat

PercentStr = Annotated[str, StringConstraints(strip_whitespace=True, pattern=r'^\d+\.?\d*\s*%$')]
PercentStr = Annotated[str, Strict(), StringConstraints(strip_whitespace=True, pattern=r'^\d+\.?\d*\s*%$')]

StrippedStr = Annotated[str, StringConstraints(strip_whitespace=True)]
StrippedStr = Annotated[str, Strict(), StringConstraints(strip_whitespace=True)]

MqttTopicStr = Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)]
MqttQosInt = Annotated[int, Interval(ge=0, le=2)]
MqttTopicStr = Annotated[str, Strict(), StringConstraints(strip_whitespace=True, min_length=1)]
MqttQosInt = Annotated[int, Strict(), Interval(ge=0, le=2)]

0 comments on commit 693fbbe

Please sign in to comment.