// WARNING: Please don't edit this file. It was generated by Python/WinRT v2.3.0

#include "py.Windows.Devices.Power.h"

namespace py::cpp::Windows::Devices::Power
{
    // ----- Battery class --------------------

    static PyObject* _new_Battery(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Power::Battery>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Power::Battery>::type_name);
        return nullptr;
    }

    static void _dealloc_Battery(py::wrapper::Windows::Devices::Power::Battery* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* Battery_FromIdAsync(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Power.Battery", L"FromIdAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                return py::convert(winrt::Windows::Devices::Power::Battery::FromIdAsync(param0));
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* Battery_GetDeviceSelector(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Power.Battery", L"GetDeviceSelector", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert(winrt::Windows::Devices::Power::Battery::GetDeviceSelector());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* Battery_GetReport(py::wrapper::Windows::Devices::Power::Battery* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Power.Battery", L"GetReport", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert(self->obj.GetReport());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* Battery_get_DeviceId(py::wrapper::Windows::Devices::Power::Battery* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.Battery", L"DeviceId");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.DeviceId());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* Battery_get_AggregateBattery(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.Battery", L"AggregateBattery");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(winrt::Windows::Devices::Power::Battery::AggregateBattery());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* Battery_add_ReportUpdated(py::wrapper::Windows::Devices::Power::Battery* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Devices.Power.Battery", L"ReportUpdated");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Devices::Power::Battery, winrt::Windows::Foundation::IInspectable>>(arg);

            return py::convert(self->obj.ReportUpdated(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* Battery_remove_ReportUpdated(py::wrapper::Windows::Devices::Power::Battery* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Devices.Power.Battery", L"ReportUpdated");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::event_token>(arg);

            self->obj.ReportUpdated(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_Battery(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Power::Battery>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_Battery(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Power::Battery>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_Battery[] = {
        { "get_report", reinterpret_cast<PyCFunction>(Battery_GetReport), METH_VARARGS, nullptr },
        { "add_report_updated", reinterpret_cast<PyCFunction>(Battery_add_ReportUpdated), METH_O, nullptr },
        { "remove_report_updated", reinterpret_cast<PyCFunction>(Battery_remove_ReportUpdated), METH_O, nullptr },
        { "_assign_array_", _assign_array_Battery, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_Battery), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_Battery[] = {
        { "device_id", reinterpret_cast<getter>(Battery_get_DeviceId), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_Battery[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_Battery) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_Battery) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_Battery) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_Battery) },
        { }
    };

    static PyType_Spec type_spec_Battery = {
        "winrt._winrt_windows_devices_power.Battery",
        sizeof(py::wrapper::Windows::Devices::Power::Battery),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_Battery};

    static PyGetSetDef getset_Battery_Static[] = {
        { "aggregate_battery", reinterpret_cast<getter>(Battery_get_AggregateBattery), nullptr, nullptr, nullptr },
        { }
    };

    static PyMethodDef methods_Battery_Static[] = {
        { "from_id_async", reinterpret_cast<PyCFunction>(Battery_FromIdAsync), METH_VARARGS, nullptr },
        { "get_device_selector", reinterpret_cast<PyCFunction>(Battery_GetDeviceSelector), METH_VARARGS, nullptr },
        { }
    };

    static PyType_Slot type_slots_Battery_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_Battery_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_Battery_Static) },
        { }
    };

    static PyType_Spec type_spec_Battery_Static =
    {
        "winrt._winrt_windows_devices_power.Battery_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_Battery_Static
    };

    // ----- BatteryReport class --------------------

    static PyObject* _new_BatteryReport(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Power::BatteryReport>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Power::BatteryReport>::type_name);
        return nullptr;
    }

    static void _dealloc_BatteryReport(py::wrapper::Windows::Devices::Power::BatteryReport* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* BatteryReport_get_ChargeRateInMilliwatts(py::wrapper::Windows::Devices::Power::BatteryReport* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.BatteryReport", L"ChargeRateInMilliwatts");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.ChargeRateInMilliwatts());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BatteryReport_get_DesignCapacityInMilliwattHours(py::wrapper::Windows::Devices::Power::BatteryReport* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.BatteryReport", L"DesignCapacityInMilliwattHours");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.DesignCapacityInMilliwattHours());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BatteryReport_get_FullChargeCapacityInMilliwattHours(py::wrapper::Windows::Devices::Power::BatteryReport* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.BatteryReport", L"FullChargeCapacityInMilliwattHours");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.FullChargeCapacityInMilliwattHours());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BatteryReport_get_RemainingCapacityInMilliwattHours(py::wrapper::Windows::Devices::Power::BatteryReport* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.BatteryReport", L"RemainingCapacityInMilliwattHours");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.RemainingCapacityInMilliwattHours());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* BatteryReport_get_Status(py::wrapper::Windows::Devices::Power::BatteryReport* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.BatteryReport", L"Status");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Status());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_BatteryReport(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Power::BatteryReport>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_BatteryReport(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Power::BatteryReport>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_BatteryReport[] = {
        { "_assign_array_", _assign_array_BatteryReport, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_BatteryReport), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_BatteryReport[] = {
        { "charge_rate_in_milliwatts", reinterpret_cast<getter>(BatteryReport_get_ChargeRateInMilliwatts), nullptr, nullptr, nullptr },
        { "design_capacity_in_milliwatt_hours", reinterpret_cast<getter>(BatteryReport_get_DesignCapacityInMilliwattHours), nullptr, nullptr, nullptr },
        { "full_charge_capacity_in_milliwatt_hours", reinterpret_cast<getter>(BatteryReport_get_FullChargeCapacityInMilliwattHours), nullptr, nullptr, nullptr },
        { "remaining_capacity_in_milliwatt_hours", reinterpret_cast<getter>(BatteryReport_get_RemainingCapacityInMilliwattHours), nullptr, nullptr, nullptr },
        { "status", reinterpret_cast<getter>(BatteryReport_get_Status), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_BatteryReport[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_BatteryReport) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_BatteryReport) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_BatteryReport) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_BatteryReport) },
        { }
    };

    static PyType_Spec type_spec_BatteryReport = {
        "winrt._winrt_windows_devices_power.BatteryReport",
        sizeof(py::wrapper::Windows::Devices::Power::BatteryReport),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_BatteryReport};

    // ----- PowerGridData class --------------------

    static PyObject* _new_PowerGridData(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Power::PowerGridData>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Power::PowerGridData>::type_name);
        return nullptr;
    }

    static void _dealloc_PowerGridData(py::wrapper::Windows::Devices::Power::PowerGridData* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* PowerGridData_get_IsLowUserExperienceImpact(py::wrapper::Windows::Devices::Power::PowerGridData* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.PowerGridData", L"IsLowUserExperienceImpact");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.IsLowUserExperienceImpact());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerGridData_get_Severity(py::wrapper::Windows::Devices::Power::PowerGridData* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.PowerGridData", L"Severity");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Severity());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_PowerGridData(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Power::PowerGridData>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_PowerGridData(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Power::PowerGridData>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_PowerGridData[] = {
        { "_assign_array_", _assign_array_PowerGridData, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_PowerGridData), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_PowerGridData[] = {
        { "is_low_user_experience_impact", reinterpret_cast<getter>(PowerGridData_get_IsLowUserExperienceImpact), nullptr, nullptr, nullptr },
        { "severity", reinterpret_cast<getter>(PowerGridData_get_Severity), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_PowerGridData[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_PowerGridData) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_PowerGridData) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_PowerGridData) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_PowerGridData) },
        { }
    };

    static PyType_Spec type_spec_PowerGridData = {
        "winrt._winrt_windows_devices_power.PowerGridData",
        sizeof(py::wrapper::Windows::Devices::Power::PowerGridData),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_PowerGridData};

    // ----- PowerGridForecast class --------------------

    static PyObject* _new_PowerGridForecast(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Devices::Power::PowerGridForecast>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Devices::Power::PowerGridForecast>::type_name);
        return nullptr;
    }

    static void _dealloc_PowerGridForecast(py::wrapper::Windows::Devices::Power::PowerGridForecast* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* PowerGridForecast_GetForecast(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_Size(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Devices.Power.PowerGridForecast", L"GetForecast", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert(winrt::Windows::Devices::Power::PowerGridForecast::GetForecast());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* PowerGridForecast_get_BlockDuration(py::wrapper::Windows::Devices::Power::PowerGridForecast* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.PowerGridForecast", L"BlockDuration");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.BlockDuration());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerGridForecast_get_Forecast(py::wrapper::Windows::Devices::Power::PowerGridForecast* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.PowerGridForecast", L"Forecast");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.Forecast());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerGridForecast_get_StartTime(py::wrapper::Windows::Devices::Power::PowerGridForecast* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Devices.Power.PowerGridForecast", L"StartTime");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert(self->obj.StartTime());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerGridForecast_add_ForecastUpdated(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Devices.Power.PowerGridForecast", L"ForecastUpdated");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>>(arg);

            return py::convert(winrt::Windows::Devices::Power::PowerGridForecast::ForecastUpdated(param0));
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* PowerGridForecast_remove_ForecastUpdated(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.Devices.Power.PowerGridForecast", L"ForecastUpdated");
            }

            if (!is_event_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "event is not available in this version of Windows");
                return nullptr;
            }

            auto param0 = py::convert_to<winrt::event_token>(arg);

            winrt::Windows::Devices::Power::PowerGridForecast::ForecastUpdated(param0);
            Py_RETURN_NONE;
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_PowerGridForecast(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Devices::Power::PowerGridForecast>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_PowerGridForecast(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Devices::Power::PowerGridForecast>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_PowerGridForecast[] = {
        { "_assign_array_", _assign_array_PowerGridForecast, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_PowerGridForecast), METH_O | METH_STATIC, nullptr },
        { }
    };

    static PyGetSetDef _getset_PowerGridForecast[] = {
        { "block_duration", reinterpret_cast<getter>(PowerGridForecast_get_BlockDuration), nullptr, nullptr, nullptr },
        { "forecast", reinterpret_cast<getter>(PowerGridForecast_get_Forecast), nullptr, nullptr, nullptr },
        { "start_time", reinterpret_cast<getter>(PowerGridForecast_get_StartTime), nullptr, nullptr, nullptr },
        { }
    };

    static PyType_Slot _type_slots_PowerGridForecast[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_PowerGridForecast) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_PowerGridForecast) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_PowerGridForecast) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_PowerGridForecast) },
        { }
    };

    static PyType_Spec type_spec_PowerGridForecast = {
        "winrt._winrt_windows_devices_power.PowerGridForecast",
        sizeof(py::wrapper::Windows::Devices::Power::PowerGridForecast),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_PowerGridForecast};

    static PyGetSetDef getset_PowerGridForecast_Static[] = {
        { }
    };

    static PyMethodDef methods_PowerGridForecast_Static[] = {
        { "get_forecast", reinterpret_cast<PyCFunction>(PowerGridForecast_GetForecast), METH_VARARGS, nullptr },
        { "add_forecast_updated", reinterpret_cast<PyCFunction>(PowerGridForecast_add_ForecastUpdated), METH_O, nullptr },
        { "remove_forecast_updated", reinterpret_cast<PyCFunction>(PowerGridForecast_remove_ForecastUpdated), METH_O, nullptr },
        { }
    };

    static PyType_Slot type_slots_PowerGridForecast_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_PowerGridForecast_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_PowerGridForecast_Static) },
        { }
    };

    static PyType_Spec type_spec_PowerGridForecast_Static =
    {
        "winrt._winrt_windows_devices_power.PowerGridForecast_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_PowerGridForecast_Static
    };

    // ----- Windows.Devices.Power Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Devices.Power");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_devices_power",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Devices::Power

PyMODINIT_FUNC PyInit__winrt_windows_devices_power(void) noexcept
{
    using namespace py::cpp::Windows::Devices::Power;

    if (py::import_winrt_runtime() == -1)
    {
        return nullptr;
    }

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto object_type = py::get_object_type();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_Battery_Static{PyType_FromSpec(&type_spec_Battery_Static)};
    if (!type_Battery_Static)
    {
        return nullptr;
    }

    py::pytype_handle Battery_type{py::register_python_type(module.get(), &type_spec_Battery, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_Battery_Static.get()))};
    if (!Battery_type)
    {
        return nullptr;
    }

    py::pytype_handle BatteryReport_type{py::register_python_type(module.get(), &type_spec_BatteryReport, object_bases.get(), nullptr)};
    if (!BatteryReport_type)
    {
        return nullptr;
    }

    py::pytype_handle PowerGridData_type{py::register_python_type(module.get(), &type_spec_PowerGridData, object_bases.get(), nullptr)};
    if (!PowerGridData_type)
    {
        return nullptr;
    }

    py::pyobj_handle type_PowerGridForecast_Static{PyType_FromSpec(&type_spec_PowerGridForecast_Static)};
    if (!type_PowerGridForecast_Static)
    {
        return nullptr;
    }

    py::pytype_handle PowerGridForecast_type{py::register_python_type(module.get(), &type_spec_PowerGridForecast, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_PowerGridForecast_Static.get()))};
    if (!PowerGridForecast_type)
    {
        return nullptr;
    }


    return module.detach();
}
