<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def local_get_state(self, device, id_override=None, type_override=None):
 """ Get device state via local API, and fall back to online API. Args: device (WinkDevice):
 The device the change is being requested for. id_override (String, optional):
 A device ID used to override the passed in device's ID. Used to make changes on sub-devices. i.e. Outlet in a Powerstrip. The Parent device's ID. type_override (String, optional):
 Used to override the device type when a device inherits from a device other than WinkDevice. Returns: response_json (Dict):
 The API's response in dictionary format """

        if ALLOW_LOCAL_CONTROL:
            if device.local_id() is not None:
                hub = HUBS.get(device.hub_id())
                if hub is not None and hub["token"] is not None:
                    ip = hub["ip"]
                    access_token = hub["token"]
                else:
                    return self.get_device_state(device, id_override, type_override)
            else:
                return self.get_device_state(device, id_override, type_override)
            _LOGGER.info("Getting local state")
            local_id = id_override or device.local_id()
            object_type = type_override or device.object_type()
            LOCAL_API_HEADERS['Authorization'] = "Bearer " + access_token
            url_string = "https://{}:8888/{}s/{}".format(ip,
                                                         object_type,
                                                         local_id)
            try:
                arequest = requests.get(url_string,
                                        headers=LOCAL_API_HEADERS,
                                        verify=False, timeout=3)
            except requests.exceptions.RequestException:
                _LOGGER.error("Error sending local control request. Sending request online")
                return self.get_device_state(device, id_override, type_override)
            response_json = arequest.json()
            _LOGGER.debug('%s', response_json)
            temp_state = device.json_state
            for key, value in response_json["data"]["last_reading"].items():
                temp_state["last_reading"][key] = value
            return temp_state
        else:
            return self.get_device_state(device, id_override, type_override)