Skip to content

Commit

Permalink
Merge pull request #64 from mdegat01/add-symbol-length
Browse files Browse the repository at this point in the history
Add symbol length option for rtlamr
  • Loading branch information
mdegat01 authored Apr 26, 2022
2 parents 9c484ce + 6385352 commit 78453f9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions amr2mqtt/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,15 @@ watched meters.
Defaults to `homeassistant`. Set if you use a custom MQTT discovery prefix in
Home Assistant.

### Option: `rtlamr_symbol_length`

Sets symbollength in the rtlamr command used internally. If you are having issues
with high CPU usage, try lowering this number. Your goal should be to set it as
low as possible while still seeing results from your meter(s).

Valid values are: 8, 32, 40, 48, 56, 64, 72, 80, 88, 96. Default is 72. See [here][rtlamr-configuration]
for more information on rtlamr and this option.

## Home Assistant

If you enable discovery then on start-up this add-on will send MQTT messages telling
Expand Down Expand Up @@ -349,5 +358,6 @@ SOFTWARE.
[reddit-ll-issue]: https://www.reddit.com/r/RTLSDR/comments/bjc4mk/tweakstips_for_reading_meters_with_rtlamr/em8vnwn/
[releases]: https://github.com/mdegat01/addon-amr2mqtt/releases
[rtl-sdr-dongle]: https://www.amazon.com/s?k=RTL2832U
[rtlamr-configuration]: https://github.com/bemasher/rtlamr/wiki/Configuration
[rtlamr-protocols]: https://github.com/bemasher/rtlamr/wiki/Protocol
[semver]: http://semver.org/spec/v2.0.0
1 change: 1 addition & 0 deletions amr2mqtt/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ schema:
home_assistant_discovery_enabled: bool?
home_assistant_discovery_prefix: match(^[^+#]{1,65535}$)?
last_seen: list(ISO_8601|ISO_8601_local|epoch)?
rtlamr_symbol_length: list(8|32|40|48|56|64|72|80|88|96)?
1 change: 1 addition & 0 deletions amr2mqtt/rootfs/amr2mqtt/amr2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def start_rtlamr():
settings.RTLAMR,
f"-msgtype={settings.WATCHED_PROTOCOLS}",
"-format=json",
f"-symbollength={settings.SYMBOL_LENGTH}",
]

# Add ID filter if we have a list of IDs to watch
Expand Down
4 changes: 4 additions & 0 deletions amr2mqtt/rootfs/amr2mqtt/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def make_meters_map(meters, meter):
LAST_SEEN_FORMAT = os.environ.get("LAST_SEEN")
LAST_SEEN_ENABLED = LAST_SEEN_FORMAT != "disable"

# RTLAMR options
symbol_length = os.environ.get("SYMBOL_LENGTH")
SYMBOL_LENGTH = int(symbol_length) if bool(symbol_length) else 72

# Set up logging
EV_TO_LOG_LEVEL = {
"DEBUG": logging.DEBUG,
Expand Down
4 changes: 4 additions & 0 deletions amr2mqtt/rootfs/etc/services.d/amr2mqtt/run
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ fi
# --- OTHER SETTINGS ---
export "LAST_SEEN=$(bashio::config 'last_seen' 'disable')"

if bashio::config.exists 'rtlamr_symbol_length'; then
export "SYMBOL_LENGTH=$(bashio::config 'rtlamr_symbol_length')"
fi

# --- SET LOG LEVEL ---
case "$(bashio::config 'log_level')" in \
trace) ;& \
Expand Down

0 comments on commit 78453f9

Please sign in to comment.