    def to_dict(self):
        """Convert class to serialisable dict for dump_devices."""
        out = {}
        for var, val in vars(self).items():
            if var in ["options", "parent_device", "scanner_device"]:
                # skip certain vars that we don't want in the dump output.
                continue
            if var == "adverts":
                adout = {}
                for adtype, adarray in val.items():
                    out_adarray = []
                    for ad_data in adarray:
                        if adtype in ["manufacturer_data", "service_data"]:
                            for ad_key, ad_value in ad_data.items():
                                out_adarray.append({ad_key: cast(bytes, ad_value).hex()})
                        else:
                            out_adarray.append(ad_data)
                    adout[adtype] = out_adarray
                out[var] = adout
                continue
            out[var] = val
        return out
Convert class to serialisable dict for dump_devices.
custom_components/bermuda/bermuda_device_scanner.py