Exemplo n.º 1
0
    async public void View()
    {
        Clear();
        NetAtmo.Gadget gadget = new NetAtmo.Gadget(Config.Id, Config.Secret, Config.UserName, Config.Password);
        if (await gadget.ClientCredentials.ExecuteAsync())
        {
            if (await gadget.DeviceList.ExecuteAsync())
            {
                foreach (var device in gadget.DeviceList.Executed.Result.Data.Body.Devices)
                    WriteLine("Station={0}", device.StationName);

                foreach (var device in gadget.DeviceList.Executed.Result.Data.Body.Devices)
                    WriteLine("Name={0} Temp={1}", device.ModuleName, device.DashboardData.Temperature.ToString());

                foreach (var module in gadget.DeviceList.Executed.Result.Data.Body.Modules)
                    WriteLine("Name={0} Temp={1}", module.ModuleName, module.DashboardData.Temperature.ToString());
            }
            else if (gadget.DeviceList.Executed.IsException)
                WriteLine("Exception gadget.DeviceList {0}", gadget.DeviceList.Executed.Exception.ToString());
            else
                WriteLine("Error gadget.DeviceList");
        }
        else if (gadget.ClientCredentials.Executed.IsException)
            WriteLine("Exception gadget.ClientCredentials {0}", gadget.ClientCredentials.Executed.Exception.ToString());
        else
            WriteLine("Error gadget.ClientCredentials");
    }
Exemplo n.º 2
0
    async public void View()
    {
        Clear();
        NetAtmo.Gadget gadget = new NetAtmo.Gadget(Config.Id, Config.Secret, Config.UserName, Config.Password);
        if (await gadget.ClientCredentials.ExecuteAsync())
        {
            if (await gadget.DeviceList.ExecuteAsync())
            {
                foreach (var device in gadget.DeviceList.Executed.Result.Data.Body.Devices)
                {
                    WriteLine("Station={0}", device.StationName);
                }

                foreach (var device in gadget.DeviceList.Executed.Result.Data.Body.Devices)
                {
                    WriteLine("Name={0} Temp={1}", device.ModuleName, device.DashboardData.Temperature.ToString());
                }

                foreach (var module in gadget.DeviceList.Executed.Result.Data.Body.Modules)
                {
                    WriteLine("Name={0} Temp={1}", module.ModuleName, module.DashboardData.Temperature.ToString());
                }
            }
            else if (gadget.DeviceList.Executed.IsException)
            {
                WriteLine("Exception gadget.DeviceList {0}", gadget.DeviceList.Executed.Exception.ToString());
            }
            else
            {
                WriteLine("Error gadget.DeviceList");
            }
        }
        else if (gadget.ClientCredentials.Executed.IsException)
        {
            WriteLine("Exception gadget.ClientCredentials {0}", gadget.ClientCredentials.Executed.Exception.ToString());
        }
        else
        {
            WriteLine("Error gadget.ClientCredentials");
        }
    }