package com.rdiot.yx485.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.rdiot.yx485.http.entity.BaseReplyBean;

import java.util.List;

public class HomeResultBean extends BaseReplyBean {

    public List<HomeInfo> data;

    public static class HomeInfo implements Parcelable {
        /**
         * record_id : 177jpg81w0td8nmauuwrmyt1k0spe93b
         * name : 家庭名称
         * province : 山东省
         * city : 济南市
         * district : 历下区
         * address : 123
         * ad_code :
         * gateway :
         * member : [{"record_id":"1pw4ums27dbd53orkrbzoe5110nvq7f5","home_id":"177jpg81w0td8nmauuwrmyt1k0spe93b","user_id":"1pw4ums27dbd53orkrbzoe5110nvq7f5","is_default":false,"user_name":"测试","remark":"","phone":"13361096420","photo":""}]
         * admin_id : 1pw4ums27dbd53orkrbzoe5110nvq7f5
         * admin_name : 测试
         * is_default : false
         * is_online : false
         * room : null
         * electric_id :
         * devices : null
         * creator :
         */

        public String record_id;
        public String name;
        public String province;
        public String city;
        public String district;
        public String address;
        public String ad_code;
        public String gateway;
        public String admin_id;
        public String admin_name;
        public boolean is_default;
        public boolean is_online;
        public String electric_id;
        public String creator;
        public List<RoomBean> room;
        public List<DevicesBeanX> devices;
        public List<MemberBean> member;

        protected HomeInfo(Parcel in) {
            record_id = in.readString();
            name = in.readString();
            province = in.readString();
            city = in.readString();
            district = in.readString();
            address = in.readString();
            ad_code = in.readString();
            gateway = in.readString();
            admin_id = in.readString();
            admin_name = in.readString();
            is_default = in.readByte() != 0;
            is_online = in.readByte() != 0;
            electric_id = in.readString();
            creator = in.readString();
        }

        public static final Creator<HomeInfo> CREATOR = new Creator<HomeInfo>() {
            @Override
            public HomeInfo createFromParcel(Parcel in) {
                return new HomeInfo(in);
            }

            @Override
            public HomeInfo[] newArray(int size) {
                return new HomeInfo[size];
            }
        };

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel parcel, int i) {
            parcel.writeString(record_id);
            parcel.writeString(name);
            parcel.writeString(province);
            parcel.writeString(city);
            parcel.writeString(district);
            parcel.writeString(address);
            parcel.writeString(ad_code);
            parcel.writeString(gateway);
            parcel.writeString(admin_id);
            parcel.writeString(admin_name);
            parcel.writeByte((byte) (is_default ? 1 : 0));
            parcel.writeByte((byte) (is_online ? 1 : 0));
            parcel.writeString(electric_id);
            parcel.writeString(creator);
        }

        public static class MemberBean implements Parcelable{
            /**
             * record_id : 1pw4ums27dbd53orkrbzoe5110nvq7f5
             * home_id : 177jpg81w0td8nmauuwrmyt1k0spe93b
             * user_id : 1pw4ums27dbd53orkrbzoe5110nvq7f5
             * is_default : false
             * user_name : 测试
             * remark :
             * phone : 13361096420
             * photo :
             */

            public String record_id;
            public String home_id;
            public String user_id;
            public boolean is_default;
            public String user_name;
            public String remark;
            public String phone;
            public String photo;
            public String created_at;

            protected MemberBean(Parcel in) {
                record_id = in.readString();
                home_id = in.readString();
                user_id = in.readString();
                is_default = in.readByte() != 0;
                user_name = in.readString();
                remark = in.readString();
                phone = in.readString();
                photo = in.readString();
                created_at = in.readString();
            }

            public static final Creator<MemberBean> CREATOR = new Creator<MemberBean>() {
                @Override
                public MemberBean createFromParcel(Parcel in) {
                    return new MemberBean(in);
                }

                @Override
                public MemberBean[] newArray(int size) {
                    return new MemberBean[size];
                }
            };

            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel parcel, int i) {
                parcel.writeString(record_id);
                parcel.writeString(home_id);
                parcel.writeString(user_id);
                parcel.writeByte((byte) (is_default ? 1 : 0));
                parcel.writeString(user_name);
                parcel.writeString(remark);
                parcel.writeString(phone);
                parcel.writeString(photo);
                parcel.writeString(created_at);
            }
        }
        public static class RoomBean implements Parcelable{
            /**
             * record_id : string
             * name : string
             * home_id : string
             * home_name : string
             * devices : [{"record_id":"string","name":"string","device_code":"string","type_id":"string","type_name":"string","icon":"string","is_master":true,"home_id":"string","room_id":"string","is_online":true,"power":0,"temperature":0,"humidity":0}]
             */

            public String record_id;
            public String name;
            public String home_id;
            public String home_name;
            public List<DevicesBean> devices;

            protected RoomBean(Parcel in) {
                record_id = in.readString();
                name = in.readString();
                home_id = in.readString();
                home_name = in.readString();
            }

            public static final Creator<RoomBean> CREATOR = new Creator<RoomBean>() {
                @Override
                public RoomBean createFromParcel(Parcel in) {
                    return new RoomBean(in);
                }

                @Override
                public RoomBean[] newArray(int size) {
                    return new RoomBean[size];
                }
            };

            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel parcel, int i) {
                parcel.writeString(record_id);
                parcel.writeString(name);
                parcel.writeString(home_id);
                parcel.writeString(home_name);
            }

            public static class DevicesBean implements Parcelable{
                /**
                 * record_id : string
                 * name : string
                 * device_code : string
                 * type_id : string
                 * type_name : string
                 * icon : string
                 * is_master : true
                 * home_id : string
                 * room_id : string
                 * is_online : true
                 * power : 0
                 * temperature : 0
                 * humidity : 0
                 */

                public String record_id;
                public String name;
                public String device_code;
                public String type_id;
                public String type_name;
                public String icon;
                public boolean is_master;
                public String home_id;
                public String room_id;
                public boolean is_online;
                public int power;
                public int temperature;
                public int humidity;

                protected DevicesBean(Parcel in) {
                    record_id = in.readString();
                    name = in.readString();
                    device_code = in.readString();
                    type_id = in.readString();
                    type_name = in.readString();
                    icon = in.readString();
                    is_master = in.readByte() != 0;
                    home_id = in.readString();
                    room_id = in.readString();
                    is_online = in.readByte() != 0;
                    power = in.readInt();
                    temperature = in.readInt();
                    humidity = in.readInt();
                }

                public static final Creator<DevicesBean> CREATOR = new Creator<DevicesBean>() {
                    @Override
                    public DevicesBean createFromParcel(Parcel in) {
                        return new DevicesBean(in);
                    }

                    @Override
                    public DevicesBean[] newArray(int size) {
                        return new DevicesBean[size];
                    }
                };

                @Override
                public int describeContents() {
                    return 0;
                }

                @Override
                public void writeToParcel(Parcel parcel, int i) {
                    parcel.writeString(record_id);
                    parcel.writeString(name);
                    parcel.writeString(device_code);
                    parcel.writeString(type_id);
                    parcel.writeString(type_name);
                    parcel.writeString(icon);
                    parcel.writeByte((byte) (is_master ? 1 : 0));
                    parcel.writeString(home_id);
                    parcel.writeString(room_id);
                    parcel.writeByte((byte) (is_online ? 1 : 0));
                    parcel.writeInt(power);
                    parcel.writeInt(temperature);
                    parcel.writeInt(humidity);
                }
            }
        }

        public static class DevicesBeanX implements Parcelable{
            /**
             * record_id : string
             * name : string
             * device_code : string
             * type_id : string
             * type_name : string
             * icon : string
             * is_master : true
             * home_id : string
             * room_id : string
             * is_online : true
             * power : 0
             * temperature : 0
             * humidity : 0
             */

            public String record_id;
            public String name;
            public String device_code;
            public String type_id;
            public String type_name;
            public String icon;
            public boolean is_master;
            public String home_id;
            public String room_id;
            public boolean is_online;
            public int power;
            public int temperature;
            public int humidity;

            protected DevicesBeanX(Parcel in) {
                record_id = in.readString();
                name = in.readString();
                device_code = in.readString();
                type_id = in.readString();
                type_name = in.readString();
                icon = in.readString();
                is_master = in.readByte() != 0;
                home_id = in.readString();
                room_id = in.readString();
                is_online = in.readByte() != 0;
                power = in.readInt();
                temperature = in.readInt();
                humidity = in.readInt();
            }

            public static final Creator<DevicesBeanX> CREATOR = new Creator<DevicesBeanX>() {
                @Override
                public DevicesBeanX createFromParcel(Parcel in) {
                    return new DevicesBeanX(in);
                }

                @Override
                public DevicesBeanX[] newArray(int size) {
                    return new DevicesBeanX[size];
                }
            };

            @Override
            public int describeContents() {
                return 0;
            }

            @Override
            public void writeToParcel(Parcel parcel, int i) {
                parcel.writeString(record_id);
                parcel.writeString(name);
                parcel.writeString(device_code);
                parcel.writeString(type_id);
                parcel.writeString(type_name);
                parcel.writeString(icon);
                parcel.writeByte((byte) (is_master ? 1 : 0));
                parcel.writeString(home_id);
                parcel.writeString(room_id);
                parcel.writeByte((byte) (is_online ? 1 : 0));
                parcel.writeInt(power);
                parcel.writeInt(temperature);
                parcel.writeInt(humidity);
            }
        }
    }
}
