def default(self, obj):
        """Convert Home Assistant objects.

        Hand other objects to the original method.
        """
        if isinstance(obj, datetime):
            return obj.isoformat()
        elif hasattr(obj, 'as_dict'):
            return obj.as_dict()

        try:
            return json.JSONEncoder.default(self, obj)
        except __HOLE__:
            # If the JSON serializer couldn't serialize it
            # it might be a generator, convert it to a list
            try:
                return [self.default(child_obj)
                        for child_obj in obj]
            except TypeError:
                # Ok, we're lost, cause the original error
                return json.JSONEncoder.default(self, obj)
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/remote.py/JSONEncoder.default