Miraie AC

A production-ready Dart SDK for controlling Panasonic MirAIe (and compatible) air conditioners over MQTT.

pub package License: MIT

Features

  • Authentication — Login with email or phone number, token management
  • Device Discovery — Fetch home layout and all associated AC devices
  • Real-time Streaming — MQTT-based live device status with auto-reconnection
  • Full AC Control — Power, temperature, HVAC mode, fan speed, swing, display, preset modes, and convertible mode
  • Energy Consumption — Query power usage history (daily / weekly / monthly)
  • Session Persistence — Save and restore sessions for auto-authentication
  • Full telemetry — Access raw device status with 40+ diagnostic fields

Getting started

Prerequisites

  • Dart SDK >= 3.12.0
  • A MirAIe account (email or mobile login)

Installation

dependencies:
  miraie_ac_client: ^2.0.0

Usage

Quick start

import 'package:miraie_ac_client/miraie_ac_client.dart';

Future<void> main() async {
  final hub = MirAIeHub();
  final broker = MirAIeBroker();

  // Authenticate and discover devices
  await hub.init('email@example.com', 'your_password', broker);

  // Listen to device status updates
  for (final device in hub.home.devices) {
    device.onStatusChanged.listen((status) {
      print('${device.friendlyName}: ${status.temperature}°C');
    });
  }

  // Control a device
  final device = hub.home.devices.first;
  await device.turnOn();
  await device.setTemperature(24.0);
  await device.setHvacMode(HvacMode.cool);
  await device.setFanMode(FanMode.auto);
}

Session persistence (auto-login)

final hub = MirAIeHub();
final broker = MirAIeBroker();
final storage = FileMirAIeStorage('session.json');

// Try restoring a previous session
final restored = await hub.tryAutoAuthenticate(broker, storage);
if (!restored) {
  // First time — full login
  await hub.init('email@example.com', 'password', broker, storage: storage);
}

Energy consumption

final data = await hub.getEnergyConsumption(
  device: device,
  periodType: ConsumptionPeriodType.daily,
  fromDate: '2024-01-01',
  toDate: '2024-01-31',
);
print(data); // { '2024-01-01': 2.5, '2024-01-02': 3.1, ... }

Handling errors

try {
  await hub.init('email@example.com', 'wrong_password', broker);
} on MirAIeAuthException catch (e) {
  print('Auth failed: $e');
} on MirAIeApiException catch (e) {
  print('API error: $e (status: ${e.statusCode})');
} on MirAIeBrokerException catch (e) {
  print('MQTT error: $e');
}

Architecture

MirAIeHub              — Orchestrator: auth, home discovery, lifecycle
├── MirAIeBroker       — MQTT client with auto-reconnection
└── MirAIeDevice       — Individual AC unit (status stream + controls)
    └── DeviceStatus   — Immutable snapshot of current device state

Contributing

Issues and pull requests are welcome. Please ensure tests pass before submitting:

dart test
dart analyze

License

MIT — see LICENSE.

Libraries

miraie_ac_client