import { Switch } from '../types';
import { Base } from './base';

export class Shelly extends Base
{
    public async getStatus() : Promise<Switch> {
        return this.mqttWorker.getSwitchState();
    }
    
    public async getPowerUsage() 
    {
        /*
        let usage;

        try {
            usage = await connection.getDevicePowerUsage(deviceID);
            if (usage.error) {
                console.log(usage);
            }

        } catch (err) {
            console.log(err);
        }
        */
        return {
            monthly: 0,
            daily: 0,
        };

    }
    
    public async setState(state:Switch) : Promise<Switch> 
    {
        let status:boolean = false;
        
        if (state == Switch.ON) {
            status = true;
        }

        this.mqttWorker.setSwitchState(status);

        return state;
    }
}


