 
       data ->
         FarmbotCore.Logger.busy(1, "Applying OTA update")
-        Config.update_config_value(:bool, "settings", "firmware_needs_flash", true)
-        Config.update_config_value(:bool, "settings", "firmware_needs_open", false)
+        _ = set_firmware_needs_flash()
 
         spawn_link(fn -> NervesHub.update() end)
         {:reply, data, %{state | is_applying_update: true}}

  end

  def handle_cast({:handle_nerves_hub_fwup_message, {:progress, percent}}, state) do
    Config.update_config_value(:bool, "settings", "firmware_needs_flash", true)
    Config.update_config_value(:bool, "settings", "firmware_needs_open", false)

    _ = set_ota_progress(percent)
    {:noreply, state}
  end

  def handle_cast({:handle_nerves_hub_fwup_message, {:ok, _, _info}}, state) do
    Config.update_config_value(:bool, "settings", "firmware_needs_flash", true)
    Config.update_config_value(:bool, "settings", "firmware_needs_open", false)

    _ = set_ota_progress(100)
    {:noreply, state}
  end

    case Asset.fbos_config(:os_auto_update) do
      true ->
        FarmbotCore.Logger.busy(1, "Applying OTA update")
        _ = set_firmware_needs_flash()
        {:reply, :apply, %{state | is_applying_update: true, firmware_url: url}}

      _ ->
        FarmbotCore.Logger.info(1, "New Farmbot OS is available!")
        {:reply, :ignore, %{state | firmware_url: url}}
    end
  end

  def handle_call({:handle_nerves_hub_update_available, _data}, _from, state) do
    FarmbotCore.Logger.busy(1, "Applying OTA update")
    {:reply, :apply, %{state | is_applying_update: true}}
  end

