From 73f7acfd8c3b61677eae4eb0089326f75b20026e Mon Sep 17 00:00:00 2001 From: Mike Geppert Date: Sun, 3 Aug 2025 21:49:38 -0500 Subject: [PATCH] Prepare for GitLab migration: Add README, .gitignore, and update TasmotaManager.py --- .gitignore | 35 +++++++++++++++++ README.md | 96 +++++++++++++++++++++++++++++++++++++++++++++++ TasmotaManager.py | 1 - 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..277dfc2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +# Python bytecode files +__pycache__/ +*.py[cod] +*$py.class + +# Distribution / packaging +dist/ +build/ +*.egg-info/ + +# Virtual environments +venv/ +env/ +ENV/ + +# IDE files +.idea/ +.vscode/ +*.swp +*.swo + +# Logs +*.log + +# Local configuration that might contain sensitive information +network_configuration.json + +# Backup files +*.backup + +# Generated data files with sensitive network information +current.json +deprecated.json +TasmotaDevices.json +*.json.backup \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..08d2fe2 --- /dev/null +++ b/README.md @@ -0,0 +1,96 @@ +# TasmotaManager + +A Python utility for discovering, monitoring, and managing Tasmota devices on a network using UniFi Controller. + +## Features + +- Discovers Tasmota devices on the network via UniFi Controller API +- Tracks device changes over time (new, moved, deprecated devices) +- Checks and updates MQTT settings on Tasmota devices +- Generates detailed device information including firmware versions + +## Requirements + +- Python 3.6+ +- UniFi Controller with API access +- Network with Tasmota devices + +## Dependencies + +- requests +- urllib3 +- Standard library modules (json, logging, os, sys, datetime, re, time, argparse) + +## Installation + +1. Clone this repository +2. Install required packages: + ```bash + pip install requests urllib3 + ``` +3. Create a configuration file (see below) + +## Configuration + +Create a `network_configuration.json` file with the following structure: + +```json +{ + "unifi": { + "host": "https://your-unifi-controller.local", + "username": "your-username", + "password": "your-password", + "site": "default", + "network_filter": { + "network_name": { + "name": "Human-readable name", + "subnet": "192.168.1", + "exclude_patterns": [ + "device-to-exclude*" + ], + "unknown_device_patterns": [ + "tasmota*", + "ESP-*" + ] + } + } + }, + "mqtt": { + "Host": "mqtt-broker.local", + "Port": 1883, + "User": "mqtt-user", + "Password": "mqtt-password", + "Topic": "%hostname_base%", + "FullTopic": "%prefix%/%topic%/", + "NoRetain": false + } +} +``` + +## Usage + +Basic usage: +```bash +python TasmotaManager.py +``` + +With options: +```bash +python TasmotaManager.py --config custom_config.json --debug --skip-unifi +``` + +Command-line options: +- `--config`: Path to configuration file (default: network_configuration.json) +- `--debug`: Enable debug logging +- `--skip-unifi`: Skip UniFi discovery and use existing current.json + +## Output Files + +The script generates several output files: +- `current.json`: List of currently active Tasmota devices +- `deprecated.json`: Devices that were previously active but are no longer present +- `TasmotaDevices.json`: Detailed information about each device + +## License + +This project is licensed under the MIT License - see the LICENSE file for details. \ No newline at end of file diff --git a/TasmotaManager.py b/TasmotaManager.py index 206f445..92081c4 100644 --- a/TasmotaManager.py +++ b/TasmotaManager.py @@ -7,7 +7,6 @@ from typing import Optional import requests from urllib3.exceptions import InsecureRequestWarning import re # Import the regular expression module -import telnetlib import time import argparse