mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-20 09:03:43 +02:00
Add MQTT smart plug support for energy monitoring (Issue #173)
Add support for MQTT-based smart plugs that subscribe to external MQTT topics and extract power/energy data from JSON payloads. This enables integration with Zigbee2MQTT, Shelly, Tasmota discovery, and other MQTT-enabled energy monitoring devices. Features: - New "mqtt" plug type alongside tasmota and homeassistant - Subscribe to any MQTT topic with configurable JSON paths - Extract power, energy, and state values using dot notation - Optional multiplier for unit conversion (mW to W, etc.) - Monitor-only mode (no on/off control) with teal color scheme - Reuses existing MQTT broker settings from network configuration - Energy data included in statistics and per-print tracking - Full backup/restore support for MQTT plug configurations Closes #173
This commit is contained in:
@@ -840,13 +840,19 @@ export interface CloudDevice {
|
||||
export interface SmartPlug {
|
||||
id: number;
|
||||
name: string;
|
||||
plug_type: 'tasmota' | 'homeassistant';
|
||||
plug_type: 'tasmota' | 'homeassistant' | 'mqtt';
|
||||
ip_address: string | null; // Required for Tasmota
|
||||
ha_entity_id: string | null; // Required for Home Assistant (e.g., "switch.printer_plug")
|
||||
// Home Assistant energy sensor entities (optional)
|
||||
ha_power_entity: string | null;
|
||||
ha_energy_today_entity: string | null;
|
||||
ha_energy_total_entity: string | null;
|
||||
// MQTT fields (required when plug_type="mqtt")
|
||||
mqtt_topic: string | null; // e.g., "zigbee2mqtt/shelly-working-room"
|
||||
mqtt_power_path: string | null; // e.g., "power_l1" or "data.power"
|
||||
mqtt_energy_path: string | null; // e.g., "energy_l1"
|
||||
mqtt_state_path: string | null; // e.g., "state_l1" for ON/OFF
|
||||
mqtt_multiplier: number; // Unit conversion (e.g., 0.001 for mW→W)
|
||||
printer_id: number | null;
|
||||
enabled: boolean;
|
||||
auto_on: boolean;
|
||||
@@ -877,13 +883,19 @@ export interface SmartPlug {
|
||||
|
||||
export interface SmartPlugCreate {
|
||||
name: string;
|
||||
plug_type?: 'tasmota' | 'homeassistant';
|
||||
plug_type?: 'tasmota' | 'homeassistant' | 'mqtt';
|
||||
ip_address?: string | null; // Required for Tasmota
|
||||
ha_entity_id?: string | null; // Required for Home Assistant
|
||||
// Home Assistant energy sensor entities (optional)
|
||||
ha_power_entity?: string | null;
|
||||
ha_energy_today_entity?: string | null;
|
||||
ha_energy_total_entity?: string | null;
|
||||
// MQTT fields (required when plug_type="mqtt")
|
||||
mqtt_topic?: string | null;
|
||||
mqtt_power_path?: string | null;
|
||||
mqtt_energy_path?: string | null;
|
||||
mqtt_state_path?: string | null;
|
||||
mqtt_multiplier?: number;
|
||||
printer_id?: number | null;
|
||||
enabled?: boolean;
|
||||
auto_on?: boolean;
|
||||
@@ -907,13 +919,19 @@ export interface SmartPlugCreate {
|
||||
|
||||
export interface SmartPlugUpdate {
|
||||
name?: string;
|
||||
plug_type?: 'tasmota' | 'homeassistant';
|
||||
plug_type?: 'tasmota' | 'homeassistant' | 'mqtt';
|
||||
ip_address?: string | null;
|
||||
ha_entity_id?: string | null;
|
||||
// Home Assistant energy sensor entities (optional)
|
||||
ha_power_entity?: string | null;
|
||||
ha_energy_today_entity?: string | null;
|
||||
ha_energy_total_entity?: string | null;
|
||||
// MQTT fields
|
||||
mqtt_topic?: string | null;
|
||||
mqtt_power_path?: string | null;
|
||||
mqtt_energy_path?: string | null;
|
||||
mqtt_state_path?: string | null;
|
||||
mqtt_multiplier?: number;
|
||||
printer_id?: number | null;
|
||||
enabled?: boolean;
|
||||
auto_on?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user