gateway
gateway copied to clipboard
Noticeable CPU load on low-power Pi
Describe the bug I'm running Theengs Gateway on a Raspberry Pi Zero, and getting pretty consistent CPU load of ~ 35%.
To Reproduce Steps to reproduce the behavior:
- Install TG in a venv on a Raspberry Pi Zero.
- Run it, observe CPU usage.
Expected behavior Way less CPU load (IMHO). From looking at the log, it's blasting out somewhere around 100 MQTT messages per second, and I only have one single plant sensor at the moment.
Environment
# Theengs Gateway Diagnostics
## Package Versions
| Name | Value |
|--------------------|--------|
| Theengs Gateway | 1.4.0 |
| Theengs Decoder | 1.7.2 |
| Bleak | 0.21.1 |
| Bluetooth Clocks | 0.2.0 |
| Bluetooth Numbers | 1.1.1 |
| Paho MQTT | 2.0.0 |
| Bluetooth Adapters | 0.18.0 |
## Python
| Name | Value |
|----------------|--------------------------------|
| Version | 3.11.2 |
| Implementation | CPython |
| Compiler | GCC 12.2.0 |
| Executable | /home/floe/theengs/bin/python3 |
## Operating System
| Name | Value |
|--------------|------------------------------------------|
| System | Linux |
| Release | 6.6.20+rpt-rpi-v6 |
| Version | #1 Raspbian 1:6.6.20-1+rpt1 (2024-03-07) |
| Machine type | armv6l |
| Distribution | Raspbian GNU/Linux 12 (bookworm) |
## Configuration
File: /home/floe/theengsgw.conf
{
"adapter": "",
"bindkeys": {},
"ble": 1,
"ble_scan_time": 5,
"ble_time_between_scans": 5,
"discovery": 1,
"discovery_device_name": "TheengsGateway",
"discovery_filter": [
"IBEACON"
],
"discovery_topic": "homeassistant",
"enable_tls": 0,
"enable_websocket": 0,
"general_presence": 0,
"hass_discovery": 1,
"host": "jarvis.lan",
"identities": {},
"log_level": "INFO",
"lwt_topic": "home/TheengsGateway/LWT",
"pass": "***",
"port": 1883,
"presence": 0,
"presence_topic": "home/TheengsGateway/presence",
"publish_advdata": 0,
"publish_all": 1,
"publish_topic": "home/TheengsGateway/BTtoMQTT",
"scanning_mode": "active",
"subscribe_topic": "home/+/BTtoMQTT/undecoded",
"time_format": 0,
"time_sync": [],
"tracker_timeout": 120,
"user": "***"
}
## Bluetooth adapters
Default adapter: hci0
### hci0
| Name | Value |
|--------------|-------------------------|
| address | B8:27:EB:XX:XX:XX |
| sw_version | fjordcam |
| hw_version | usb:v1D6Bp0246d0542 |
| passive_scan | False |
| manufacturer | Raspberry Pi Foundation |
| product | None |
| vendor_id | None |
| product_id | None |
Additional context
I assume that there is some config file or commandline switch I could use to slow it down - are the -sd
and -tb
options related to that?
Additional note: I tried with -pa 0 -tb 10 -sd 2
and that has definitely cut down the number of MQTT messages being sent, but doesn't seem to have had any noticeable impact on CPU load.