fix FitnessTracker Name
This commit is contained in:
parent
3228f76200
commit
ab1589480a
10
main.py
10
main.py
@ -354,14 +354,20 @@ class GadgetbridgeMQTTPublisher:
|
|||||||
self.logger.error(f"Failed to connect to MQTT broker: {e}")
|
self.logger.error(f"Failed to connect to MQTT broker: {e}")
|
||||||
|
|
||||||
def get_device_alias(self) -> str:
|
def get_device_alias(self) -> str:
|
||||||
"""Fetch ALIAS from DEVICE table for device_name"""
|
"""Fetch ALIAS from DEVICE table for device_name where NAME contains 'band' or 'watch' (case-insensitive)"""
|
||||||
if not os.path.exists(self.db_path):
|
if not os.path.exists(self.db_path):
|
||||||
self.logger.error(f"Database file not found: {self.db_path}")
|
self.logger.error(f"Database file not found: {self.db_path}")
|
||||||
return "fitness_tracker"
|
return "fitness_tracker"
|
||||||
try:
|
try:
|
||||||
conn = sqlite3.connect(self.db_path)
|
conn = sqlite3.connect(self.db_path)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute("SELECT ALIAS FROM DEVICE LIMIT 1")
|
cursor.execute(
|
||||||
|
"""
|
||||||
|
SELECT ALIAS FROM DEVICE
|
||||||
|
WHERE LOWER(NAME) LIKE '%band%' OR LOWER(NAME) LIKE '%watch%'
|
||||||
|
LIMIT 1
|
||||||
|
"""
|
||||||
|
)
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
if row and row[0]:
|
if row and row[0]:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user